コード例 #1
0
    for i in range(size):
        for j in range(size):
            pygame.draw.line(window, (255, 0, 0), (i * 800 // size, 0),
                             (i * 800 // size, 600))
            pygame.draw.line(window, (255, 0, 0), (0, j * 600 // size),
                             (800, j * 600 // size))
            img = font.render(str(board[j][i]) + "", True, (200, 200, 200))
            window.blit(img, (i * 800 // size, j * 600 // size))


pygame.init()
window = pygame.display.set_mode((800, 600))
pygame.display.set_caption("Max Profit Path Finder")
player = Player()
h = Heuristic(5)
h.calculate_max_profit_path()
path_stack = h.recover_path()
run = True
show = False
player_turn = True
printWinner = False
while run:
    for event in pygame.event.get():
        pos = pygame.mouse.get_pos()
        if event.type == pygame.QUIT:
            run = False
        if event.type == pygame.MOUSEBUTTONDOWN and player_turn:
            current_location = player.current_square(pos, h.board_size)
            if player.is_legal(current_location):
                player.move(current_location, h.board)