AlphaZeroIncubator / AlphaZero

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

Model game input #37

Open PhilipEkfeldt opened 4 years ago

PhilipEkfeldt commented 4 years ago

Currently the model (PhilipNet) needs a game instance as input to get the width/height of the board. I think it's preferable to have width/height as arguments instead, to not have to initialize a game instance every time you want to create a model just to access the width/height, or some other solution. Any thoughts @abhon @charlesoblack ?

guidopetri commented 4 years ago

In principle, I agree; however, the width/height need to somehow be bound to a Game instance since we otherwise could create the model with different width/height dimensions than the Game itself.

It's also not necessarily always the same for a given game - we could for instance play connect4 with dimensions of 7x9, or 7x5, or whatever like that. If it were the same for a given game, then we could just move it to be a staticmethod / class property, but unfortunately if we want the flexibility we can't do that.

If you have any workarounds for this it would be great though, because I agree - instantiating a Game just to pass into the model (and then never be used again) seems silly.

homerours commented 4 years ago

I agree too. A possible workaround would be to use a dictionnary game_params containing:

PhilipEkfeldt commented 4 years ago

I agree too. A possible workaround would be to use a dictionnary game_params containing:

  • the width / height
  • the shape of the policy head. For tictactoe, the policy head has the same dimension than the game itselt, but not for Connect4, where it is just the number of columns. Then game_params is given as input to PhilipNet and to Connect4/TicTacToe.

I think this is a good solution, I can update this