-
Notifications
You must be signed in to change notification settings - Fork 0
/
strategic.py
59 lines (40 loc) · 1.35 KB
/
strategic.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
import math
class Player:
def __init__(self):
pass
# self.most_common = lambda : self.numbers.index(max(self.numbers)) + 1
def initcards(self,num1,num2,num3,num4,num_all):
self.numbers = [num1,num2,num3,num4]
self.num_all = num_all
self.common = self.numbers.index(max(self.numbers)) + 1
def guess(self):
prob = self.num_all / 4
ceil = math.ceil(prob)
floor = math.floor(prob)
prob = floor if abs(ceil - prob)> abs(floor - prob) else ceil
return {self.common :prob + max(self.numbers)}
def play(self):
guess_ansewr = self.guess()
return(guess_ansewr)
def play_one_round(cart_list,num_all):
player = Player()
player.initcards(cart_list.count(1),
cart_list.count(2),
cart_list.count(3),
cart_list.count(4),
num_all)
try:
player_guess = player.play()
print(player_guess)
except:
print('something wrong please try again')
l, num_all = get_input()
play_one_round(l,num_all)
def get_input():
l = input('list of my cart: ').split()
num_all = int(input('number of all cart: '))
l = list(map(int,l))
return l,num_all
if __name__ == '__main__':
l, num_all = get_input()
play_one_round(l,num_all)