akaps / hanabi_ai

AI competition of the card game Hanabi, where the best AI is measured as the most cooperative and contributes to the highest scoring games
MIT License
1 stars 2 forks source link

RFC: use class for game_info instead of dictionary #75

Closed C-Saunders closed 5 years ago

C-Saunders commented 5 years ago

Is your feature request related to a problem? Please describe. game_info dictionaries have a lot of fields, and we currently get no compile time checks or hints for the field names. This increases the odds of runtime errors and makes development (internal as well as of bots) less ergonomic.

Describe the solution you'd like A class that has fields for each of the current dictionary keys might be a good solution.

I believe the current dictionary is only created by info_for_player in hanabi_table.py, but this shape of dictionary is used in many places, so the refactoring could be substantial.

Describe alternatives you've considered I'm not sure what other abstractions (available in Python) that would serve this purpose, so I haven't considered anything else.

Additional context I really like types and letting my tools help me (meaning compiler errors and hints from my editor). It's possible this suggestion isn't "Pythonic", but I do most of my programming in typed languages, so I figured I'd put it out there for consideration.

akaps commented 5 years ago

Big fan of this. I had done this as a "simpler" way of how Ants AI gives info to the player (actually, they send a class)

akaps commented 5 years ago

Playing with a solution, will hopefully get a PR out soon