Members
(constant) compartment_square :BoxedUp.Shape
- Description:
This helper builds the 3×3 square of offsets used by compartments.
- Source:
This helper builds the 3×3 square of offsets used by compartments.
Type:
Methods
all_positions(board) → {Array.<BoxedUp.Position>}
- Description:
This helper returns every position on a board.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
board |
BoxedUp.Board | The board. |
Returns:
All [row, column] positions on the board.
- Type
- Array.<BoxedUp.Position>
compartment_owner(board) → {function}
- Description:
This helper decides who owns a fully covered compartment: the player with more cells in it, or
0if they are level.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
board |
BoxedUp.Board | The board the compartment belongs to. |
Returns:
From a compartment to its owner.
- Type
- function
covered_specials(player, board, positions) → {number}
- Description:
This helper counts how many of the given special cells are covered by a player's pieces.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
player |
BoxedUp.Player | The player whose pieces to look for. |
board |
BoxedUp.Board | The board to inspect. |
positions |
Array.<BoxedUp.Position> | The special cells to check. |
Returns:
How many of those cells the player covers.
- Type
- number
fill_cell(token) → {function}
- Description:
This helper writes a token into one cell of a board, returning a new board.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
token |
BoxedUp.Cell | The token to write. |
Returns:
Reducer from a board and a position to a new board.
- Type
- function
first_best(is_better, list)
- Description:
This helper folds a list to its first maximal element: later elements only replace the current best if strictly better, keeping the chef deterministic.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
is_better |
function | Whether the first argument beats the second. |
list |
Array | The (non-empty) list to fold. |
Returns:
The first maximal element.
fits_somewhere_on(board) → {function}
- Description:
This helper returns whether a shape, in any of its orientations, fits anywhere on a board.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
board |
BoxedUp.Board | The board to test. |
Returns:
A predicate on shapes.
- Type
- function
lead_after(game) → {function}
- Description:
This helper scores a ply for the head chef: the chef's score lead over its opponent after making the ply, including any compartment bonuses gained or conceded.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
game |
BoxedUp.Game | The game the ply is made on. |
Returns:
From a ply to its resulting score lead.
- Type
- function
normalised(shape) → {BoxedUp.Shape}
- Description:
This helper shifts a shape so its offsets are relative to [0, 0], and sorts them, giving each shape one canonical form.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
shape |
BoxedUp.Shape | The shape to normalise. |
Returns:
The normalised shape.
- Type
- BoxedUp.Shape