In this short notebook, we introduce how the class method should be called in our experiment code.
In [1]:
from game import Game2048
In [2]:
g = Game2048(game_mode=False) # False means AI mode
In [3]:
g.print_game()
g.active_player
Out[3]:
In [4]:
moves = g.moves_available()
moves
Out[4]:
In [5]:
# We can perform an action for the "Agent"
g.perform_move(moves[0])
Out[5]:
In [6]:
g.print_game()
g.active_player # switched
Out[6]:
In [7]:
# Computer's turn, no need for a move input
g.perform_move() # Return whether the board changed
Out[7]:
In [8]:
g.print_game()
In [9]:
# Again, we can perform an action for the "Agent"
moves = g.moves_available()
g.perform_move(moves[0])
Out[9]:
In [10]:
g.print_game()
g.active_player
Out[10]:
In [11]:
g.perform_move()
g.print_game()
g.active_player
Out[11]:
We expect that moves is [0, 1, 2, 3] here.
In [12]:
g = Game2048('', game_mode=False)
g.board = [
[2, 0, 0, 0],
[2, 0, 0, 0],
[2, 0, 0, 0],
[2, 0, 0, 0]
]
g.print_game()
g.active_player
Out[12]:
We expect g.moves_available() return [1, 2, 3].
In [13]:
g.moves_available()
Out[13]:
In [ ]: