Documentation
¶
Index ¶
Constants ¶
View Source
const Inf = math.MaxInt64 - 1
Variables ¶
This section is empty.
Functions ¶
func Negamax ¶
Negamax implements depth-limited negamax with alpha-beta pruning and transposition tables. It returns the index of the optimal state from the array generated by NextMoves. This assumes the player who needs to play next will be the maximizing player.
depth is the maximum depth to examine alpha represents the minimum score that the maximizing player is assured of beta represents the maximum score that the minimizing player is assured of Initially, alpha should be set to negative infinity and beta positive infinity.
Types ¶
type GameState ¶
type GameState interface { // IsGameOver returns true when the game is over, win lose or draw. IsGameOver() bool // Evaluate returns a positive value if the color is winning, negative if losing. Evaluate(color int) int // NextMoves returns a list of all possible next moves. NextMoves() []int // Play takes a move and applies it to the state. Play(move, color int) // Undo rolls the state back before the move happened. Undo(move, color int) // Hash returns a hashable value for the game state so that // repeated states can be found by a map lookup. Google "Zobrist Hash". Hash(color int) uint64 }
Click to show internal directories.
Click to hide internal directories.