haive.games.single_player.flow_free.state¶
State model for Flow Free game.
This module defines the game state for Flow Free, tracking the board, flows, and game progress.
Classes¶
A cell on the Flow Free board. |
|
A flow in Flow Free, consisting of two endpoints and a path of pipes. |
|
An endpoint (colored dot) in Flow Free. |
|
State for the Flow Free game. |
Module Contents¶
- class haive.games.single_player.flow_free.state.Cell(/, **data)[source]¶
Bases:
pydantic.BaseModel
A cell on the Flow Free board.
- Parameters:
data (Any)
- position¶
Position of the cell.
- flow_id¶
ID of the flow occupying this cell, if any.
- is_endpoint¶
Whether this cell contains an endpoint.
- pipe_direction¶
Direction of the pipe in this cell, if any.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- class haive.games.single_player.flow_free.state.Flow(/, **data)[source]¶
Bases:
pydantic.BaseModel
A flow in Flow Free, consisting of two endpoints and a path of pipes.
- Parameters:
data (Any)
- id¶
Unique identifier for the flow.
- color¶
Color of the flow.
- start¶
Starting endpoint.
- end¶
Ending endpoint.
- path¶
List of positions forming the path between endpoints.
- completed¶
Whether the flow is complete (endpoints connected).
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- class haive.games.single_player.flow_free.state.FlowEndpoint(/, **data)[source]¶
Bases:
pydantic.BaseModel
An endpoint (colored dot) in Flow Free.
- Parameters:
data (Any)
- position¶
Position of the endpoint on the board.
- is_start¶
Whether this is the start endpoint (otherwise it’s the end).
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- class haive.games.single_player.flow_free.state.FlowFreeState(/, **data)[source]¶
Bases:
haive.games.single_player.base.SinglePlayerGameState
State for the Flow Free game.
- Parameters:
data (Any)
- rows¶
Number of rows in the grid.
- cols¶
Number of columns in the grid.
- grid¶
2D grid of cells.
- flows¶
Dictionary of flows by ID.
- current_flow_id¶
ID of the currently selected flow.
- puzzle_id¶
Identifier for the current puzzle.
- hints_used¶
Number of hints used.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- get_adjacent_positions(position)[source]¶
Get all valid adjacent positions.
- Parameters:
position (haive.games.single_player.flow_free.models.Position) – Position to get adjacent positions for.
- Returns:
List of adjacent positions.
- Return type:
- get_cell(position)[source]¶
Get the cell at the specified position.
- Parameters:
position (haive.games.single_player.flow_free.models.Position) – Position to get the cell for.
- Returns:
The cell at the position, or None if out of bounds.
- Return type:
Cell | None
- is_cell_empty(position)[source]¶
Check if a cell is empty.
- Parameters:
position (haive.games.single_player.flow_free.models.Position) – Position to check.
- Returns:
True if the cell is empty, False otherwise.
- Return type:
- is_cell_endpoint(position)[source]¶
Check if a cell contains an endpoint.
- Parameters:
position (haive.games.single_player.flow_free.models.Position) – Position to check.
- Returns:
True if the cell contains an endpoint, False otherwise.
- Return type:
- to_display_string()[source]¶
Generate a string representation of the board for display.
- Returns:
A formatted string representation of the board.
- Return type:
- property board_fill_percentage: float¶
Calculate the percentage of the board that is filled.
- Return type: