com.phasmidsoftware.gambit.examples.connect4.Connect4
See theConnect4 companion object
case class Connect4 (
xBits :
Long ,
oBits :
Long ,
heights :
Vector [
Int ])
Connect Four board state using a column-major bitboard representation.
Two Longs (xBits, oBits) represent the pieces of each player. Bit index for cell (row, col) = col * 7 + row, where row 0 is the bottom. Sentinel bits at positions 6, 13, 20, 27, 34, 41, 48 are never set during play; they prevent horizontal win detection from wrapping across columns.
heights tracks the next available row index per column (0..5). A column is full when heights(col) == Connect4.rows.
You can read more about the game here: https://en.wikipedia.org/wiki/Connect_Four
Value parameters
heights
next available row per column
oBits
bit positions of O's pieces
xBits
bit positions of X's pieces
Attributes
Companion
object
Graph
Reset zoom Hide graph Show graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
Members list
Drop a piece into the given column. The piece lands on the lowest open row. Does not validate that the column is open — callers should check open.
Drop a piece into the given column. The piece lands on the lowest open row. Does not validate that the column is open — callers should check open.
Value parameters
col
the column index (0..6).
isX
true if X is playing, false if O.
Attributes
Returns
the new Connect4 state.
Render the board as a String, top row first. X = X, O = 0, empty = .
Render the board as a String, top row first. X = X, O = 0, empty = .
Attributes
Returns a string representation of the object.
Returns a string representation of the object.
The default representation is platform dependent.
Attributes
Returns
a string representation of the object.
Definition Classes
Any
Attributes
Inherited from:
Product
Attributes
Inherited from:
Product
Whether the board is full (draw condition, assuming no winner).
Whether the board is full (draw condition, assuming no winner).
Attributes
The open (non-full) column indices, in order 0..6.
The open (non-full) column indices, in order 0..6.
Attributes
The player who just moved to create this state. true = X just moved (odd number of total pieces). false = O just moved or empty board (even number).
The player who just moved to create this state. true = X just moved (odd number of total pieces). false = O just moved or empty board (even number).
Attributes
The winner of this position, if any. Some(true) = X wins, Some(false) = O wins, None = no winner yet.
The winner of this position, if any. Some(true) = X wins, Some(false) = O wins, None = no winner yet.
Attributes