-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTemp.py
127 lines (111 loc) · 3.93 KB
/
Temp.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
from collections import Counter
from itertools import product
import random as r
#-----------------Generating score options--------------------------
def score_options_generator(previous_options):
options_dices_temp = dict()
for op1 in previous_options.keys():
options_dices_temp[op1] = previous_options[op1]
for op2 in previous_options.keys():
if len(op1) + len(op2) <= 6:
op3 = op1 + op2
op3 = sorted(op3)
op3 = tuple(op3)
if op3 not in options_dices_temp:
options_dices_temp[op3] = previous_options[op1] + previous_options[op2]
return options_dices_temp
score_options = {
tuple([1]):100, (1, 1):200, (1, 1, 1):1000, (1, 1, 1, 1):2000, (1, 1, 1, 1, 1):3000, (1, 1, 1, 1, 1, 1):4000,
(2, 2, 2):200, (2, 2, 2, 2):400, (2, 2, 2, 2, 2):600, (2, 2, 2, 2, 2, 2):800,
(3, 3, 3):300, (3, 3, 3, 3):600, (3, 3, 3, 3, 3):900, (3, 3, 3, 3, 3, 3):1200,
(4, 4, 4):400, (4, 4, 4, 4):800, (4, 4, 4, 4, 4):1200, (4, 4, 4, 4, 4, 4):1600,
tuple([5]):50, (5, 5):100 ,(5, 5, 5):500, (5, 5, 5, 5):1000, (5, 5, 5, 5, 5):1500, (5, 5, 5, 5, 5, 5):2000,
(6, 6, 6):600, (6, 6, 6, 6):1200, (6, 6, 6, 6, 6):1800, (6, 6, 6, 6, 6, 6):2400, (1, 2, 3, 4, 5, 6):1500,
(1, 1, 2, 2, 3, 3):750, (1, 1, 2, 2, 4, 4):750, (1, 1, 2, 2, 5, 5):750, (1, 1, 2, 2, 6, 6):750,
(1, 1, 3, 3, 4, 4):750, (1, 1, 3, 3, 5, 5):750, (1, 1, 3, 3, 6, 6):750, (1, 1, 4, 4, 5, 5):750,
(1, 1, 4, 4, 6, 6):750, (1, 1, 5, 5, 6, 6):750, (2, 2, 3, 3, 4, 4):750, (2, 2, 3, 3, 5, 5):750,
(2, 2, 3, 3, 6, 6):750, (2, 2, 4, 4, 5, 5):750, (2, 2, 4, 4, 6, 6):750, (2, 2, 5, 5, 6, 6):750,
(3, 3, 4, 4, 5, 5):750, (3, 3, 4, 4, 6, 6):750, (3, 3, 5, 5, 6, 6):750, (4, 4, 5, 5, 6, 6):750,
}
while True:
score_options_new = score_options_generator(score_options)
if score_options_new == score_options:
break
score_options = score_options_new
#------------------------------------------------Generating all options from all dicenum-----------------------------
def combinations_generator(dice_num):
return_combinations = Counter()
for roll in product([1, 2, 3, 4, 5, 6], repeat=dice_num):
roll = list(roll)
roll.sort()
roll = tuple(roll)
return_combinations[roll]+= 1
return return_combinations
def options_generator(dice_num):
return_options = Counter()
rolls = combinations_generator(dice_num)
for roll in rolls.keys():
options_set = []
for option in score_options.keys():
if not Counter(option) - Counter(roll):
options_set.append(option)
options_set = tuple(options_set)
return_options[options_set] += rolls[roll]
return return_options
def generate_options_superset():
options = {}
for i in range(1, 6):
options[str(i)] = options_generator(i)
return(options)
superset = generate_options_superset()
print(superset["2"])
# ---------------------------------------------Search programm--------------------------------------------------------
def choose_from_weigthed(dict):
return(r.choices(*zip()))
#
# class Dice_num:
#
# def __init__():
# parent = None
# children = []
# points = 0
# dice_num = 0
#
# def score_from_children(): pass
# def gen_children(): pass
#
# class Option_set:
#
# def __init__():
# parent = None
# children = []
# points = 0
# options_set = {}
# weight = 0
#
# def score_from_children(): pass
# def gen_children(): pass
#
#
#
# class Roll:
#
# def __init__():
# parent = None
# children = []
# points = 0
# dice_num = 0
#
# def score_from_children(): pass
# def gen_children(): pass
#
# class Keep:
#
# def __init__():
# parent = None
# children = []
# points = 0
# dice_num = 0
#
# def score_from_children(): pass
# def gen_children(): pass