haive.games.chess.modelsΒΆ

Chess game models module.

This module provides data models for the chess game, including:
  • Move representation

  • Player decisions

  • Position analysis

  • Structured output models for LLMs

ClassesΒΆ

ChessAnalysis

Model for chess position analysis.

ChessMoveModel

Model for chess moves with validation.

ChessMoveValidation

Model for chess move validation results.

ChessPlayerDecision

Model for chess player decisions.

SegmentedAnalysis

Structured analysis of a chess position in segments.

Module ContentsΒΆ

class haive.games.chess.models.ChessAnalysis(/, **data)ΒΆ

Bases: pydantic.BaseModel

Model for chess position analysis.

This class represents a detailed analysis of a chess position:
  • Material evaluation

  • Positional assessment

  • Tactical opportunities

  • Strategic plans

Parameters:

data (Any)

material_evalΒΆ

Material evaluation in pawns

Type:

float

position_evalΒΆ

Qualitative position assessment

Type:

str

tacticsΒΆ

List of tactical opportunities

Type:

List[str]

strategyΒΆ

Long-term strategic plan

Type:

str

best_movesΒΆ

Suggested best moves

Type:

List[str]

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.chess.models.ChessMoveModel(/, **data)ΒΆ

Bases: pydantic.BaseModel

Model for chess moves with validation.

This class represents a chess move with:
  • UCI notation (e.g., β€œe2e4”)

  • Optional explanation

  • Move validation

Parameters:

data (Any)

moveΒΆ

Move in UCI notation

Type:

str

explanationΒΆ

Explanation of the move’s purpose

Type:

Optional[str]

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.

classmethod from_move(move, explanation=None)ΒΆ

Create from a chess.Move object.

Parameters:
  • move (chess.Move)

  • explanation (str | None)

Return type:

ChessMoveModel

to_move()ΒΆ

Convert to a chess.Move object.

Return type:

chess.Move

classmethod validate_move(v)ΒΆ

Validate the move format.

Parameters:

v (str) – The move string to validate

Returns:

The validated move string

Raises:

ValueError – If move is not a string or too short

Return type:

str

class haive.games.chess.models.ChessMoveValidation(/, **data)ΒΆ

Bases: pydantic.BaseModel

Model for chess move validation results.

This class represents the validation of a chess move:
  • Move legality

  • Error messages

  • Resulting position

Parameters:

data (Any)

is_validΒΆ

Whether the move is legal

Type:

bool

error_messageΒΆ

Error message if move is invalid

Type:

Optional[str]

resulting_fenΒΆ

FEN of position after move

Type:

Optional[str]

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.chess.models.ChessPlayerDecision(/, **data)ΒΆ

Bases: pydantic.BaseModel

Model for chess player decisions.

This class represents a player’s decision-making process:
  • Move selection

  • Position evaluation

  • Alternative moves considered

  • Reasoning process

Parameters:

data (Any)

selected_moveΒΆ

Chosen move with explanation

Type:

ChessMoveModel

position_evalΒΆ

Player’s assessment of the position

Type:

str

alternativesΒΆ

Alternative moves considered

Type:

List[ChessMoveModel]

reasoningΒΆ

Detailed reasoning for the move choice

Type:

str

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.chess.models.SegmentedAnalysis(/, **data)ΒΆ

Bases: pydantic.BaseModel

Structured analysis of a chess position in segments.

This class breaks down position analysis into distinct categories:
  • Numerical position score

  • Attacking chances

  • Defensive needs

  • Strategic plans

Parameters:

data (Any)

position_scoreΒΆ

The score evaluation of the position

Type:

float

attacking_chancesΒΆ

Likelihood of a successful attack

Type:

str

suggested_plansΒΆ

Recommended next plans

Type:

List[str]

defensive_needsΒΆ

Defensive needs and counterplay ideas

Type:

Optional[str]

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.