Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 16 additions & 15 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ def move(self, direction: int, print_board: bool = True, illegal_warn: bool = Tr
}
self.prime_tracker *= prime_direction_dict[direction]
if print_board:
self.print_board()
self.display_updated_board()

self.num_moves += 1
return True
Expand Down Expand Up @@ -418,13 +418,13 @@ def game_over_check(self) -> bool:

def run_game(track_primes=False):
# new start
# window = tk.Tk()
# window.title("2048 Game")
window = tk.Tk()
window.title("2048 Game")

running_game = Game(track_primes=track_primes)
print(f"on any move, enter 'p' to return prime tracker")
running_game.setup_board()
running_game.print_board()
running_game.display_updated_board()
# new end

# running_game = Game(track_primes)
Expand All @@ -445,10 +445,10 @@ def run_game(track_primes=False):
running_game.left()
elif move == "d":
running_game.right()

elif move == "p":
print(running_game.return_prime())

elif move == "exit":
exit()

def save_game_result_to_csv(file_name, model, score, duration, board):
import numpy as np
Expand Down Expand Up @@ -493,20 +493,21 @@ def save_game_result_to_csv(file_name, model, score, duration, board):


if __name__ == '__main__':
from AI import MC2, MC3, MC4
# from AI import MC2

# g = Game()
# g.setup_board()
# m = MC2(g, verbose=True, sims_per_turn=100)
# m.run()
# g.board.window.mainloop()
# run_game()
import time
start_time = time.time()
g = Game()
g.setup_board()
m = MC4(g, verbose=True, sims_per_turn=100)
m.run()
print(f"IT TOOK {time.time() - start_time}s to run")
g.board.window.mainloop()
# import time
# start_time = time.time()
# g = Game()
# g.setup_board()
# m = MC2(g, verbose=True, sims_per_turn=100)
# m.run()
# print(f"IT TOOK {time.time() - start_time}s to run")
# g.board.window.mainloop()
run_game()