dannyhammer / TwoPlayerGames

Undergraduate research into the mechanics of simple two-player games.
3 stars 2 forks source link

Clean up the code in the Game's play() method #94

Closed dannyhammer closed 2 years ago

dannyhammer commented 3 years ago

The code inside game.py's play() method is functional but unsatisfactory. Specifically in regards to determining a winner.

Currently, there are two cases where a winner can be declared:

  1. The current player made an illegal move, meaning the opponent wins
  2. The current player made a move that put the board into an end-game state, meaning the player wins

The declare_winner() method from the referee is called once the game is over. This may be able to be rewritten to be cleaner, as declare_winner() must execute at the end of the game, but should not attempt to update the winner of the game if case 1 triggered the end of the game.

This may extend to editing the code inside referee.py's declare_winner() method as well. That method should also update the winner and loser's win and loss counters, respectively. To do this, it must know who the winner and loser are.