Documentation
¶
Index ¶
Constants ¶
View Source
const ( BoardSideSize = 8 // TODO: actually make it so can play different size boards? BoardSize = BoardSideSize * BoardSideSize )
Variables ¶
View Source
var ( RedPieces = [...]BoardSlot{RedPiece, RedKing} BluePieces = [...]BoardSlot{BluePiece, BlueKing} )
View Source
var ( // blue goes down BlueDirCalcs = [...]int{downLeftCalc, downRightCalc} // red goes up RedDirCalcs = [...]int{upLeftCalc, upRightCalc} // TODO: maybe also flying kings for non American checkers? KingDirCalcs = [...]int{downLeftCalc, downRightCalc, upLeftCalc, upRightCalc} )
Functions ¶
Types ¶
type Board ¶
Board is a 2-d arrays, that's represented in a 1-d array. Given that 0 is the top left corner and going to higher index means right/down, these are true:
i = (cols_num * row) + col col = mod(i, cols_num) row = floor(i / cols_num)
TODO: this only needs to hold 32 slots (given that we don't care about Nas) TODO: should really be using bit-boards
type Game ¶
type Game struct {
State GameState
PlrTurn Player // who's the current player's turn
Board Board
TurnNumber int // number of half turns that finished
// this is to check draw condition
TimeSinceExcitingMove int // time since capture/non-king move
}
func (*Game) GetLegalMoves ¶
GetLegalMoves returns a slice of all legal moves in position
type Move ¶
func GetCapturesForSlotI ¶
get legal capturing moves
Click to show internal directories.
Click to hide internal directories.