Connect4

com.phasmidsoftware.gambit.examples.connect4.Connect4
See theConnect4 companion class
object Connect4

Attributes

Companion
class
Graph
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Connect4.type

Members list

Type members

Inherited and Abstract types

type MirroredElemLabels <: Tuple

The names of the product elements

The names of the product elements

Attributes

Inherited from:
Mirror
type MirroredLabel <: String

The name of the type

The name of the type

Attributes

Inherited from:
Mirror

Value members

Concrete methods

def columnMask(col: Int): Long

Bitmask for all cells in the given column.

Bitmask for all cells in the given column.

Value parameters

col

the column index (0..6).

Attributes

Returns

a Long with bits set for all rows in that column.

def parse(s: String): Connect4

Parse a Connect4 position from a string representation. The string is read top-to-bottom, left-to-right. 'X' = X, '0' or 'O' = O, '.' or ' ' = empty. Newlines and '-' are stripped. Must contain exactly rows*cols meaningful characters.

Parse a Connect4 position from a string representation. The string is read top-to-bottom, left-to-right. 'X' = X, '0' or 'O' = O, '.' or ' ' = empty. Newlines and '-' are stripped. Must contain exactly rows*cols meaningful characters.

Value parameters

s

the string to parse.

Attributes

Returns

a Connect4 position.

Concrete fields

val boardMask: Long

Bitmask covering all valid (non-sentinel) cell positions. Must be defined after columnMask.

Bitmask covering all valid (non-sentinel) cell positions. Must be defined after columnMask.

Attributes

val cols: Int

Number of columns.

Number of columns.

Attributes

val rows: Int

Number of rows.

Number of rows.

Attributes

The empty starting position.

The empty starting position.

Attributes

val stride: Int

Column stride in the bitboard: rows + 1 sentinel bit per column. The sentinel bit at position col*stride + rows is never set during play, preventing horizontal win detection from wrapping across columns.

Column stride in the bitboard: rows + 1 sentinel bit per column. The sentinel bit at position col*stride + rows is never set during play, preventing horizontal win detection from wrapping across columns.

Attributes

val winShifts: Seq[Int]

Shift amounts for win detection in each of the four directions: stride = horizontal (one column apart) 1 = vertical (one row apart) stride - 1 = diagonal / stride + 1 = diagonal \

Shift amounts for win detection in each of the four directions: stride = horizontal (one column apart) 1 = vertical (one row apart) stride - 1 = diagonal / stride + 1 = diagonal \

Attributes