5class Modulo3Incrementer:
12 return int((self.x + a) % 3)
15 return int((self.x + 333 - a) % 3)
17 def __iadd__(self, other):
18 self.x = (self.x + other) % 3
21 def __isub__(self, other):
22 self.x = (self.x + 333 - other) % 3
32 def __init__(self, id, istrump=False):
36 def __lt__(self, other):
37 return (self.suit + 1) * 100 + self.rating < (other.suit + 1) * 100 + other.rating
43 elif self.rating == 1:
45 elif self.rating == 2:
47 elif self.rating == 3:
49 elif self.rating == 4:
51 elif self.rating == 5:
53 elif self.rating == 6:
55 elif self.rating == 7:
69 def __init__(self, hand):
70 self.deck = list(map(lambda x: Card(x), hand))
73 return ' '.join(map(str, sorted(self.deck)))
75 def __getitem__(self, key):
85 def __init__(self, name, id):
92 def IncTricksAmount(self):
93 self.tricks_amount += 1
95 def updateDeck(self, deck):
99 return 'name=' + str(self.name) + ' id=' + str(self.id) + ' deck:' + str(self.deck)
101 def GetBarg(self, shedule, leftDeccision, rightDeccision):
102 xx = shedule.GetFreeList()
103 # print(''.join(xx[0]))
105 return ("Game", xx[0])
111 self.deck = self.deck[:id] + self.deck[id+1:]
114 # self.table, playerleft.get_hand(), playerright.get_hand()
115 def get_card(self, table, lefthand, righthand):
124class AnswerType: # данный класс - это ответ игрока при торгах
129 PlayChoose = (-1, -1)
148 def __init__(self, typeOfAction): #define ПАС/ ВИСТ
149 if typeOfAction == AnswerType.Action.Mizer():
151 elif type(typeOfAction) is tuple:
153 self.PlayChoose = typeOfAction[1]
154 elif typeOfAction == AnswerType.Action.Vist():
156 elif typeOfAction == AnswerType.Action.Pass():
162 return y[1][0] + y[1][1]
171 self.masks = ['6', '7', '8', '9', '10']
172 self.masks1 = ['♠', '♣', '♦', '♥', 'БК']
173 self.alls = [(i, j) for i in self.masks for j in self.masks1]
174 self.used = {i: False for i in self.alls}
177 def GetIdMask1(self, c):
178 for i in enumerate(self.masks1):
185 x1 = Shedule.GetIdMask1(Shedule(), a[1])
186 x2 = Shedule.GetIdMask1(Shedule(), b[1])
187 return int(a[0]) * 100 + x1 - int(b[0]) * 100 - x2
189 def SetUsed(self, cnt, typeX):
191 ans = list(filter(lambda x: self.used[x] == False, self.used.keys()))
192 ans = list(sorted(ans, cmp=self.cmp))
193 for i in range(len(ans)):
195 for j in range(i + 1):
196 self.used[ans[j]] = True
198 def IsUsed(self, cnt, typeX):
199 return self.used[(cnt, typeX)]
201 def GetFreeList(self):
202 ans = list(filter(lambda x: self.used[x] == False, self.used.keys()))
203 ans = list(sorted(ans, cmp=self.cmp))
204 # print(' '.join(map(lambda x: str(x[0])+str(x[1]), ans)))
208 return "Locked: " + ' '.join(map(str, filter(lambda x: self.used[x] == True, self.used.keys())))
217 allCards = np.arange(32) # crea
219 def MakeOneCircle(self, manager_id, players, trump='♠', amount_cnt=6):
221 for manager in range(3):
222 id_man = (manager + manager_id) % 3
223 player = players[id_man]
224 playerleft = players[(id_man + 3 - 1) % 3]
225 playerright = players[(id_man + 3 + 1) % 3]
226 card = player.get_card(self.table, playerleft.get_hand(), playerright.get_hand()) # самое главное - сделать ход
227 tripleset.append((card, id_man))
228 self.table = tripleset
229 tripleset = list(sorted(tripleset, key=lambda x: x[0], reverse=True))
230 winner_id = tripleset[0][1]
231 players[winner_id].IncTricksAmount()
234 def __init__(self, players, manager_id):
236 self.players = players
237 self.manager_id = manager_id
238 self.allCards = np.arange(32) # creating a deck
239 np.random.shuffle(self.allCards)
240 xDecks = (Hand(self.allCards[:10]), Hand(self.allCards[10:20]), Hand(self.allCards[20:30]))
241 self.talon = Hand(self.allCards[30:])
242 for P, D in zip(self.players, xDecks):
245 def MakeBargs(self, players, manager_id):
246 manager_id = Modulo3Incrementer(manager_id)
248 freeList = shedule.GetFreeList()
249 answers = [-1, -1, -1]
250 # первый круг голосов - возможны распасы
252 ans = players[(manager_id + 0) % 3].GetBarg(shedule, answers[(manager_id + 3 - 1) % 3], answers[(manager_id + 1) % 3])
253 answers[(manager_id + 0) % 3] = ans
254 if AnswerType(ans).isPlay:
255 shedule.SetUsed(ans[1][0], ans[1][1])
256 elif AnswerType(ans).isMiser:
257 shedule.SetUsed('8', 'БК')
259 # print(' '.join(map(lambda x: str(x[0])+str(x[1]), answers)))
260 # первый круг голосов пройден
261 while True: # пока есть свободные ячейки в таблице
262 if len(list(filter(lambda x: AnswerType(x).isPass is True, answers))) == 2: # если хотя бы два не играют
265 ans = players[(manager_id + 0) % 3].GetBarg(shedule, answers[(manager_id + 3 - 1) % 3],
266 answers[(manager_id + 1) % 3])
267 answers[(manager_id + 0) % 3] = ans
269 if AnswerType(ans).isPlay:
270 shedule.SetUsed(ans[1][0], ans[1][1])
271 elif AnswerType(ans).isMiser:
272 shedule.SetUsed('8', 'БК')
273 manager_id += 1 # modulo 3
279 return 'Player {0}: {1}, \nPlayer {2}: {3}, \nPlayer {4}: {5}, TALON: {6}\n'.format(self.players[0].name,
280 ' '.join(map(str, self.players[0].deck)),
281 self.players[1].name,
285 self.players[2].name,
296 def __init__(self, name1="Trus", name2="Balbes", name3="Bivaliy"):
297 self.players.append(Player(name1, 0))
298 self.players.append(Player(name2, 1))
299 self.players.append(Player(name3, 2))
301 r = Round(self.players, self.manager)
302 self.answers = r.MakeBargs(self.players, self.manager)
304 print(' '.join(map(lambda x: AnswerType(x).Tostr(x), self.answers)))
306 for i in self.answers:
307 if not AnswerType(i).isPass:
310 print("RASPASI!!!)!)!)!)!)!)!))!)!)!)!)!)!)!)!)")
311 elif AnswerType(notPass).isMiser:
312 print("MIZER TIMEEEOJOJOSNDVOJDNVIOJSNFOEJFNEOJN")
314 while any(self.players[0].deck):
315 self.manager = r.MakeOneCircle(self.manager, self.players, notPass[1][1], int(notPass[1][0]))
318 #while any(filter(lambda x: x.bullet < self.maxBullet, self.players)):
319 # r = Round(self.players, self.manager)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list