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

Restructure the Player enum #3

Open
edre opened this issue Feb 1, 2021 · 1 comment
Open

Restructure the Player enum #3

edre opened this issue Feb 1, 2021 · 1 comment

Comments

@edre
Copy link

edre commented Feb 1, 2021

I've been writing a Hive AI using this crate and I like the interfaces provided between game representation and engine. However, I'm confused about the purpose of the Player type. This is meant to signal whose turn it is, and it is passed to generate_moves, but either the State or the Move type also needs to encode whose turn it is. Otherwise Move::apply would not have enough information.

The names Computer and Opponent are also confusing because they are not logically linked to say black or white in the game. In order to implement get_winner, you need to know which player is the Computer, but if both sides are being played by the AI, it's not clear what that's supposed to mean.

I think a simpler abstraction would be to require the State to keep track of whose turn it is, don't pass Player to generate_moves, and have get_winner return None, Draw, Victory, SelfDefeat to clarify that it is in terms of which player just played.

@edre
Copy link
Author

edre commented Feb 4, 2021

I implemented this proposal in my fork. I think it's a simplicity win by encapsulating the current player into the Game::State implementation.

edre@9195125

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

No branches or pull requests

1 participant