carlofazioli / cardiathena

A project to study strategies in the game of hearts, using distributed computing, AI, and data analytics.
GNU General Public License v3.0
6 stars 1 forks source link

Keep GameManager abstract from current save_game() implementation #70

Closed davidjha closed 4 years ago

davidjha commented 4 years ago

Description

The project could derive game specific game managers, however the only thing that really differentiates the derived game managers would be in the save_game() method. Currently, the save_game() method in GameManager (base.py) is tailored towards Hearts or other games of that kind.

Possible solutions is to move save_game() out of GameManager. Another possible solution is to have save_game() serve as a dummy method which can then call a more game specific save_game(game_type).

aphelps4 commented 4 years ago

I do not know how useful this is but when I had our adjudicator saving to an excel sheet, I had a function outside of base.py that returned a list of all the data we wanted to store. Basically, I made a function in the state that returned a list of important values and the game manager looped through the stored states and had each of them call that function to get that data to store.

davidjha commented 4 years ago

Alright thanks! I think I remember seeing that somewhere, I'll take a look.

davidjha commented 4 years ago

Hearts and database specific processing has been moved out of the game manager and its save_game() method. The game manager now calls a method in state.py: save_state(player_action) and caches the state data into a list: state_data. At the end of the game, play_hearts.py calls save_game() which returns this list. Play_hearts.py now does the processing of the data to store into the database. mysql-on-argo branch as been updated with the changes.