Open jkomoros opened 7 years ago
Ideally you'd just be able to write scoring functions and then the whole thing would explore forward based on the moves that are legal, creating games (that don't go to storage layer)
Actualy, it doesn't even need to create games. We'd just have a routine that will take a state as a starting point, a manager, and who it's playing as. Then it just creates and manages its own states, applying fixUp moves itself by conferring with delegate.
package minmax
type MinMaxAgent interface {
//ScoreForState should return an int based on how good the game state is for the given player.
ScoreForState(state boardgame.State, proposer boardgame.PlayerIndex) int
}
//MinMax takes a Game, but won't modify it. It will use the manager, delegate, and currentState as a starting point and return a Move that should be applied now, or nil if no move exists (for example, if it is not that player's turn)
func MinMax(a MinMaxAgent, game *boardgame.Game, targetPlayer boardgame.PlayerIndex) boardgame.Move {
//Grab CurrentState, then start building out a tree of scores by calling ScoreForState
}
Hmm, we'd need a way for moves to define the min and max legal values of e.g. an int property so we know which branches to try. Could have moves enumerate all other legal moves at the property state, or have an IntBounds(propName, state) low, high method. PlayerIndexes are always known what their legal bounds are.
Take a context with deadline to MinMax, so the system can know how many plys deep to go automatically
... Does minmax only work for 2 player games?