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

Associate Moves with a Game #45

Closed
jkomoros opened this issue Feb 1, 2017 · 3 comments
Closed

Associate Moves with a Game #45

jkomoros opened this issue Feb 1, 2017 · 3 comments

Comments

@jkomoros
Copy link
Owner

jkomoros commented Feb 1, 2017

We want a way for Game or CLI to be able to enumerate moves, ideally with a description, and create a new one.

One way is to have all Moves have a Copy(). So we keep a list of instainiated base moves of all of the types, and when seeing which ones are legal, we go through and Copy() them. Then they can all have a Description() and Name() field, and InitalizeWithState(payload) on them.

Another approach is to have game just have a list of functions that take a state payload and return an initialized move or nil if the game state doesn't permit one to exist. Moves could still have Description() and Name(), and then we'd only be able to list ones that were at least vaguely plausible at that state in the game.

The latter seems cleaner, although there are definitely some instances when I want to enumerate all of the moves in the game, even if I can't do anything with them right now.

So maybe it's Move.Copy()InitForState(state) error. Where if it returns error that means it's not even conceivable right now (let alone legal).

... Is there a distinct concept of "Conceivable at this game state" and "Legal at this game state"? The former is only useful to the extent the move is not yet filled in with all of its fields yet, but otherwise is basically the same. Conceivable seems like it could be an albatross, because it's basically a bespoke version of Legal(), which will be finicky logic.

OK, so it's a list of instantiated Moves(). We can enumerate them for Name() And Description(). If we find one we like, we call Copy().DefaultsForState(state), which always does the best it can to set the properties it can default reasonably. (like TargetPlayerIndex == CurrentPlayer)

Necessary to fix #26

@jkomoros
Copy link
Owner Author

jkomoros commented Feb 1, 2017

A notion of PlayerMoves and MetaMoves. PlayerMoves are any moves that may be applied by a player. MetaMoves are any moves that may only be applied as FixUp moves. This will help us print out only moves that individual players can legally apply.

Probably OK to do later when necessary.

@jkomoros
Copy link
Owner Author

jkomoros commented Feb 1, 2017

When a Move is applied we check to verify it's been added to AddMove. (Or at least one with that Name() has been)

@jkomoros
Copy link
Owner Author

jkomoros commented Feb 1, 2017

Now that we've captured the two sub Issues in #48 and #49, as of 423cbea this is fixed.

@jkomoros jkomoros closed this as completed Feb 1, 2017
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