games.go.models¶
Go game data models.
- This module provides Pydantic models for representing Go game concepts:
Move coordinates and validation
Player decisions
Position analysis and evaluation
Territory control tracking
Example
>>> from haive.games.go.models import GoMoveModel, GoAnalysis
>>>
>>> # Create and validate a move
>>> move = GoMoveModel(move=(3, 4), board_size=19)
>>> move.to_tuple()
(3, 4)
>>>
>>> # Create a position analysis
>>> analysis = GoAnalysis(
... territory_control={"black": 45, "white": 40},
... strong_positions=[(3, 3), (15, 15)],
... weak_positions=[(0, 0)],
... suggested_strategies=["Strengthen the center group"]
... )
Classes¶
A model for storing Go position analysis. |
|
A model representing a move in Go. |
|
A model representing a player's move decision. |
Module Contents¶
- class games.go.models.GoAnalysis(/, **data)¶
Bases:
pydantic.BaseModel
A model for storing Go position analysis.
This model captures a comprehensive analysis of a Go position, including territory control, key positions, and strategic advice.
- Parameters:
data (Any)
Example
>>> analysis = GoAnalysis( ... territory_control={"black": 45, "white": 40}, ... strong_positions=[(3, 3), (15, 15)], ... weak_positions=[(0, 0)], ... suggested_strategies=[ ... "Strengthen the center group", ... "Consider invading the top right" ... ] ... )
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 games.go.models.GoMoveModel(/, **data)¶
Bases:
pydantic.BaseModel
A model representing a move in Go.
This model validates and stores move coordinates, ensuring they are within the bounds of the game board.
- Parameters:
data (Any)
Example
>>> move = GoMoveModel(move=(3, 4)) >>> move.validate_move((3, 4), {"board_size": 19}) (3, 4) >>> move.to_tuple() (3, 4) >>> >>> # Invalid move raises error >>> GoMoveModel(move=(19, 19)) # Out of bounds ValueError: Move (19, 19) is out of bounds for a 19x19 board.
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.
- to_tuple()¶
Convert the move to a simple coordinate tuple.
- classmethod validate_move(move, values)¶
Validate that a move is within board bounds.
- class games.go.models.GoPlayerDecision(/, **data)¶
Bases:
pydantic.BaseModel
A model representing a player’s move decision.
This model encapsulates a player’s decision about their next move, including validation of the move coordinates.
- Parameters:
data (Any)
- move¶
The chosen move coordinates and validation.
- Type:
Example
>>> decision = GoPlayerDecision( ... move=GoMoveModel(move=(3, 4)) ... ) >>> decision.move.to_tuple() (3, 4)
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.