Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make initial build phase tick-able (and replay-able). Replay game functionality. #30

Merged
merged 7 commits into from
Oct 23, 2020

Conversation

bcollazo
Copy link
Owner

@bcollazo bcollazo commented Oct 4, 2020

For machine learning, we need to be able to iterate over all the states of a game. Saving the state and game object to the database on every tick proved to be too slow (increase avg finish time of a game from ~5 secs to ~1 min). So we instead make the refactors necessary to be able to have a function replay_game that given a game, can yield all the states of that game. In particular, we had to make the Initial Building Phase to go through the game.execute(action) mechanism like everything else.

As such, we created new ActionTypes that tell the .execute function not to charge for initial roads for example.

Similarly, we change the Discard logic to be just another branching spot in the game logic, so that a tree-exploring algorithm can decide with the same API as the rest of the decisions.

Another item necessary to replay games was to seed the game (to ensure e.g. card-stealing happens in the same way).

We refactored the database layer to allow storing game_states as opposed to finalized games, as we first tried to save the state on each tick. This proved to be too slow, but we keep the extra power for now.

@bcollazo bcollazo self-assigned this Oct 4, 2020
@coveralls
Copy link

coveralls commented Oct 4, 2020

Pull Request Test Coverage Report for Build 288369763

  • 125 of 135 (92.59%) changed or added relevant lines in 3 files are covered.
  • 4 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+1.002%) to 95.961%

Changes Missing Coverage Covered Lines Changed/Added Lines %
catanatron/game.py 86 96 89.58%
Files with Coverage Reduction New Missed Lines %
catanatron/models/player.py 1 88.57%
catanatron/game.py 3 92.12%
Totals Coverage Status
Change from base Build 287769867: 1.002%
Covered Lines: 879
Relevant Lines: 916

💛 - Coveralls

@bcollazo bcollazo merged commit b3c0c9c into master Oct 23, 2020
@bcollazo bcollazo deleted the feature/feature-matrix-etl branch March 19, 2023 02:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants