A Matchbox represents one position in the MENACE machine. It holds a bead count for each legal move (open cell index 0..8). Weighted random selection picks a move proportional to bead counts. After a game, beads are added (win) or removed (loss), with a floor of 1.
Value parameters
- beads
-
a Map from cell index (0..8, row-major) to bead count.
Attributes
- Companion
- object
- Graph
-
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Members list
Value members
Concrete methods
The number of distinct moves this matchbox knows about.
The number of distinct moves this matchbox knows about.
Attributes
Penalise: remove delta beads from the given cell, floored at floor. Used after a loss.
Penalise: remove delta beads from the given cell, floored at floor. Used after a loss.
Value parameters
- cell
-
the cell index that was played.
- delta
-
the number of beads to remove (typically 1 for a loss).
- floor
-
the minimum bead count (default 1, so a move is never impossible).
Attributes
- Returns
-
a new Matchbox with updated beads.
Reward: add delta beads to the given cell. Used after a win.
Reward: add delta beads to the given cell. Used after a win.
Value parameters
- cell
-
the cell index that was played.
- delta
-
the number of beads to add (typically 3 for a win).
Attributes
- Returns
-
a new Matchbox with updated beads.
Select a move by weighted random sampling over the bead counts. Returns None if the matchbox is empty (should not happen in normal play).
Select a move by weighted random sampling over the bead counts. Returns None if the matchbox is empty (should not happen in normal play).
Value parameters
- random
-
a Random instance for reproducibility.
Attributes
- Returns
-
Some(cellIndex) or None.
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
Total beads across all moves.
Total beads across all moves.
Attributes
Inherited methods
Attributes
- Inherited from:
- Product
Attributes
- Inherited from:
- Product