dodal funkcijo za generiranje uteži
parent
18222ed6a0
commit
94f0fd7f41
48
test.py
48
test.py
|
@ -1,4 +1,4 @@
|
|||
from random import randint
|
||||
from random import randint, choices
|
||||
# item
|
||||
#collection
|
||||
clltn = []
|
||||
|
@ -21,8 +21,9 @@ def generate_clltn (n_of_cards):
|
|||
|
||||
# USER
|
||||
## config
|
||||
deck_size = 3
|
||||
max_due = 2
|
||||
max_new = 1
|
||||
max_deck_size = max_new + max_due
|
||||
# setup
|
||||
user_clltn = generate_clltn(100)
|
||||
|
||||
|
@ -38,7 +39,7 @@ def get_due(user_clltn, n_of_cards):
|
|||
pass
|
||||
|
||||
|
||||
def generate_deck_sr(user_clltn, max_new, deck_size):
|
||||
def generate_deck_sr(user_clltn, max_new, max_deck_size):
|
||||
pass
|
||||
|
||||
|
||||
|
@ -46,14 +47,45 @@ def run_sr():
|
|||
pass
|
||||
|
||||
#2 Probabilistic
|
||||
## problem je, da pri probabilističnem težko nardiš, da pač en dan ni nič v decku...
|
||||
## problem je, da pri probabilističnem težko nardiš, da pač en dan ni nič v decku, ker pač vedno izbere glede določeno število pač glede na uteži
|
||||
|
||||
def generate_weights(user_clltn, max_deck_size):
|
||||
"""generiramo uteži za due in new cards posebej; vrne tuple dveh listov za weightse..."""
|
||||
|
||||
weights_due = []
|
||||
weights_new = []
|
||||
for card in user_clltn:
|
||||
#problem je edgecase, ko ni populacije kar propade...
|
||||
if len(user_clltn)<max_deck_size:
|
||||
max_deck_size = len(user_clltn) # lame fast hack...
|
||||
|
||||
_, _, due, _, _, _ = card
|
||||
|
||||
if due > 0:
|
||||
weights_due.append(due)
|
||||
weights_new.append(0)
|
||||
else:
|
||||
weights_due.append(0)
|
||||
weights_new.append(1)
|
||||
|
||||
return weights_new, weights_due
|
||||
|
||||
#TODO
|
||||
def generate_deck_prob(user_clltn, deck_size, max_new):
|
||||
def generate_deck_prob(user_clltn, max_deck_size, max_new):
|
||||
deck = []
|
||||
for c in range(deck_size):
|
||||
for c in range(max_deck_size):
|
||||
deck.append(user_clltn[c]) # tu vzame prvic ampak moralo bi random c brez ponavljanja obteženih z "due". rabimo tudi naključnih/najnovejših? max_new novih cardov.
|
||||
|
||||
"""
|
||||
if sum(weights_due)>0:
|
||||
#due
|
||||
dck = choices(user_clltn, cum_weights=weights_new, k=max_due)
|
||||
dck_new = choices(user_clltn, k=max)
|
||||
#new
|
||||
#??
|
||||
else:
|
||||
dck = choices(user_clltn, k=max_new)
|
||||
"""
|
||||
return deck
|
||||
|
||||
|
||||
|
@ -89,3 +121,7 @@ def run_prob(deck, user_clltn):
|
|||
# random python stuff
|
||||
## kako najt tuple v listu in ga spremeniti?
|
||||
## kako vzet weight iz tuple in ga assignat pri izbiranju?
|
||||
|
||||
|
||||
|
||||
print(generate_weights(user_clltn, max_deck_size))
|
Loading…
Reference in New Issue