Documentation
¶
Overview ¶
Minimax player with Alpha-beta pruning for Oxo3d
Heuristic player for Oxo3d ¶
Minimax player for Oxo3d ¶
Player interface for Oxo3d ¶
Random player for Oxo3d
Index ¶
- Constants
- Variables
- type NewPlayer
- type Oxo3d
- func (o *Oxo3d) Board(Go int) int
- func (o *Oxo3d) GameOver() bool
- func (o *Oxo3d) IsMyGo() bool
- func (o *Oxo3d) Marked(Go int) bool
- func (o *Oxo3d) MyGo(Go int)
- func (o *Oxo3d) Play(Go int, myGo bool)
- func (o *Oxo3d) String() string
- func (o *Oxo3d) UnPlay()
- func (o *Oxo3d) ValidMove(Go int) bool
- func (o *Oxo3d) WhoWon() int
- func (o *Oxo3d) YourGo(Go int)
- type Oxo3dAlphaBeta
- type Oxo3dHeuristic
- type Oxo3dMinimax
- type Oxo3dRandom
- type Player
Constants ¶
View Source
const ( // We keep count of how many X and O there are on each line by encoding them like this // numberOfXs * 5 + numberOfOs // Since Xs and Os are both 0..4 the max value here is 24 XS = 5 OS = 1 // players NOONE = 0 ME = 1 YOU = -1 DRAW = 2 // A score larger than any possible score INF = 0x7FFFFFFF )
View Source
const ( // Names for costs NONE = 0 // Nothing O1 = 1 // 1 * O O2 = 2 // 2 * O O3 = 3 // 3 * O O4 = 4 // 4 * O X1 = 5 // 1 * X X2 = 6 // 2 * X X3 = 7 // 3 * X X4 = 8 // 4 * X O11 = 9 // An empty square with 1 * O and 1 * O O12 = 10 // An empty square with 1 * O and 2 * O O22 = 11 // An empty square with 2 * O and 2 * O X11 = 12 // An empty square with 1 * X and 1 * X X12 = 13 // An empty square with 1 * X and 2 * X X22 = 14 // An empty square with 2 * X and 2 * X JUNK = 15 // A line with both Os and Xs )
Constants
Variables ¶
View Source
var Players = map[string]NewPlayer{}
Registry of players
Functions ¶
This section is empty.
Types ¶
type Oxo3d ¶
type Oxo3d struct {
// contains filtered or unexported fields
}
func (*Oxo3d) Board ¶
Board returns the state of the board at that position, either ME, YOU or NOONE
func (*Oxo3d) Marked ¶
Marked returns a flag as to whether the position should be higlighted. This will highlight the last move and any winning lines.
func (*Oxo3d) UnPlay ¶
func (o *Oxo3d) UnPlay()
Unplay the last move keeping internal state up to date
type Oxo3dAlphaBeta ¶
type Oxo3dAlphaBeta struct {
Oxo3dMinimax
}
func (*Oxo3dAlphaBeta) CalculateMyGo ¶
func (p *Oxo3dAlphaBeta) CalculateMyGo() int
Do the computer move
type Oxo3dHeuristic ¶
type Oxo3dHeuristic struct {
// contains filtered or unexported fields
}
Oxo3d Heuristic player
func (*Oxo3dHeuristic) CalculateMyGo ¶
func (p *Oxo3dHeuristic) CalculateMyGo() int
Calculate the computer move
type Oxo3dMinimax ¶
type Oxo3dMinimax struct {
// contains filtered or unexported fields
}
func (*Oxo3dMinimax) CalculateMyGo ¶
func (p *Oxo3dMinimax) CalculateMyGo() int
Do the computer move
type Oxo3dRandom ¶
type Oxo3dRandom struct {
// contains filtered or unexported fields
}
Click to show internal directories.
Click to hide internal directories.