def process_input(self, events):
if not self.end_state[0]:
for event in events:
if event.type == pygame.MOUSEBUTTONDOWN:
if event.button == 1:
mouse_position = pygame.mouse.get_pos()
x = int(mouse_position[0] / self.square_width)
y = int(mouse_position[1] / self.square_width)
if (x, y) not in self.players[1].positions:
if self.players[0].add_position(x, y, self.minimax_board):
computer_position = pruned_minimax(self.minimax_board)
if not end_state(self.minimax_board)[0]:
self.players[1].add_position(computer_position[0][0], computer_position[0][1],
self.minimax_board, 1)
else:
for event in events:
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_RETURN:
self.clear()
elif event.key == pygame.K_SPACE:
self.clear(True)
# the update method checks if the board is in an end state:
TicTacToe.py 文件源码
python
阅读 32
收藏 0
点赞 0
评论 0
评论列表
文章目录