AlphaZeroIncubator / AlphaZero

Our implementation of AlphaZero for simple games such as Tic-Tac-Toe and Connect4.
0 stars 0 forks source link

Tic Tac Toe in an OOP format #2

Closed guidopetri closed 4 years ago

guidopetri commented 4 years ago

For future-proofing our code, and to start out with tic-tac-toe, we should have a game class that implements things like getting all possible moves, as well as win conditions, for instance.

The reason why we should do this as a class is so that we can easily pass in other games to our NN architecture. Maybe tic-tac-toe should be a subclass of a more general Game class that leaves implementation of specific methods for the subclasses? That way all our games can subclass Game and we can ensure that the games are all implemented fully.

PhilipEkfeldt commented 4 years ago

I agree with subclassing from a generic Game class. Some functions I was thinking could be useful for this class:

GetInitialBoard() -> array/tensor (board) GetLegalMoves(current_player (int?), current_board (array/tensor)) -> Array[Bool] MakeMove(move (int/binary array?), board (array/tensor)) -> board (array/tensor)' IsFinal(board) -> Bool, int (-1,0,1)

Another thing that could be useful is to handle different settings for the same game by having to initiate an object with certain settings to "use" the game, i.e. the methods wouldn't be static, e.g.:

connect4_big = Connect4(width = 10, height = 8, winning_len = 5)

guidopetri commented 4 years ago

Working on this in #8 . The game itself is there, but I'm writing tests for it too.

guidopetri commented 4 years ago

Closed through #8 .