def _cpu_move(self):
"""Performs a move by the AI."""
#self.game.call(self.cpu)
decision = random.randrange(4)
if decision == 1 and self.game.lastraise == 0: #shouldn't call. check instead.
decision = 0
elif decision == 0 and self.cpu.bid < self.game.lastraise: #can't check. call instead.
decision = 1
if decision == 0:
self.game.check(self.cpu)
self._set_text(self.prompt, self.cpu.name + " checked.")
elif decision == 1:
self.game.call(self.cpu)
self._set_text(self.prompt, self.cpu.name + " called.")
elif decision >= 2:
bid_amount = random.randrange(self.game.lastraise, self.game.lastraise*2+1)
bid_amount += 50 - (bid_amount % 50)
self.game.make_bid(self.cpu, bid_amount)
self._set_text(self.prompt, self.cpu.name + " raised the bet to " \
+ locale.format("%d", self.game.bid, grouping=True) + ".")
self._update_display(False)
if self.game.is_next(self.cpu) and not self.game.finished:
self._cpu_move()
评论列表
文章目录