com.phasmidsoftware.gambit.examples.connect4
Members list
Type members
Classlikes
Connect Four board state using a column-major bitboard representation.
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
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
Factory for a Connect Four GameRunner.
Factory for a Connect Four GameRunner.
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
Connect4GameRunner.type
State[Connect4, Connect4] typeclass instance for Connect4.
State[Connect4, Connect4] typeclass instance for Connect4.
P = S = Connect4: the proto-state and state are the same type. construct takes (newState, previousState) and returns newState.
Attributes
- Supertypes
- Self type
-
Connect4State.type
Runs a round-robin tournament between all Connect Four player types and prints the league table to stdout.
Runs a round-robin tournament between all Connect Four player types and prints the league table to stdout.
Player parameters (depths, iteration counts, exploration constant) are read from application.conf via com.phasmidsoftware.gambit.game.GambitConfig. Edit the config file to tune contestants without recompiling.
Players entered:
- RandomPlayer
- HeuristicPlayer (one-ply greedy)
- AlphaBeta(d=d1) (minimax, depth from config)
- AlphaBeta(d=d2) (minimax, deeper depth from config)
- MCTS(i=i1) (Monte Carlo, iteration count from config)
- MCTS(i=i2) (Monte Carlo, higher iteration count from config)
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
Connect4Tournament.type
Value members
Concrete methods
Demonstrates Connect4 games between player types, printing the board state and heuristic score after each move.
Demonstrates Connect4 games between player types, printing the board state and heuristic score after each move.
Each matchup is played twice — home (X) and away (O) — to account for the first-mover advantage X enjoys in Connect Four.
Matchups: MCTS vs Random, MCTS vs Heuristic, Heuristic vs Random.
Attributes
Play a single Connect4 game, printing each move with board and heuristic.
Play a single Connect4 game, printing each move with board and heuristic.
Attributes
Render a Connect4 board with its heuristic score. Adds column index header for readability.
Render a Connect4 board with its heuristic score. Adds column index header for readability.
Attributes
Givens
Givens
The Game typeclass instance for Connect Four.
The Game typeclass instance for Connect Four.
S = Connect4 M = Int (column index, 0..6) Pl = Boolean (true = X, moves first; false = O, moves second)