haive.games.reversi.models¶

Comprehensive data models for Reversi (Othello) strategic board game.

This module defines the complete set of data structures for the classic Reversi game, providing models for move validation, strategic analysis, and board position evaluation. The implementation supports standard 8x8 Reversi with traditional disc-flipping mechanics.

Reversi is a strategic board game involving: - 8x8 board with alternating black and white disc placement - Disc-flipping mechanics with line capture rules - Strategic corner and edge control - Endgame optimization for maximum disc count

Key Models:

Position: Board coordinate representation (row, col) ReversiMove: Player’s disc placement action ReversiAnalysis: Strategic evaluation for AI decision-making

Examples

Working with positions:

from haive.games.reversi.models import Position

# Corner positions (strategic)
corner = Position(row=0, col=0)
opposite_corner = Position(row=7, col=7)

# Center positions (opening)
center = Position(row=3, col=3)
adjacent = Position(row=4, col=4)

Making moves:

from haive.games.reversi.models import ReversiMove

# Black player opening move
move = ReversiMove(row=3, col=2, player="B")

# White player response
counter_move = ReversiMove(row=2, col=2, player="W")

Strategic analysis:

from haive.games.reversi.models import ReversiAnalysis

analysis = ReversiAnalysis(
    mobility=12,
    stability=8,
    corner_control=2,
    edge_control=5,
    evaluation_score=0.3,
    strategy="Focus on corner control and edge stability"
)

The models provide comprehensive strategic analysis capabilities for AI-driven Reversi gameplay with position evaluation and move optimization.

Classes¶

Position

A coordinate on the Reversi board.

ReversiAnalysis

Strategy and evaluation report for a Reversi position.

ReversiMove

Represents a single Reversi move.

Module Contents¶

class haive.games.reversi.models.Position(/, **data)[source]¶

Bases: pydantic.BaseModel

A coordinate on the Reversi board.

Parameters:

data (Any)

row¶

Row index (0-7).

Type:

int

col¶

Column index (0-7).

Type:

int

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.reversi.models.ReversiAnalysis(/, **data)[source]¶

Bases: pydantic.BaseModel

Strategy and evaluation report for a Reversi position.

Parameters:

data (Any)

mobility¶

Number of legal moves available.

Type:

int

frontier_discs¶

Count of discs adjacent to at least one empty space.

Type:

int

corner_discs¶

Number of corners occupied by the player.

Type:

int

stable_discs¶

Discs that cannot be flipped.

Type:

int

positional_score¶

Positional heuristic score.

Type:

int

position_evaluation¶

Assessment of advantage (e.g., ‘winning’, ‘equal’).

Type:

str

recommended_moves¶

Preferred moves based on analysis.

Type:

List[Position]

danger_zones¶

High-risk positions to avoid.

Type:

List[Position]

strategy¶

Summary of strategic approach.

Type:

str

reasoning¶

Detailed explanation of analysis.

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.reversi.models.ReversiMove(/, **data)[source]¶

Bases: pydantic.BaseModel

Represents a single Reversi move.

Parameters:

data (Any)

row¶

Row position of the move (0-7).

Type:

int

col¶

Column position of the move (0-7).

Type:

int

player¶

The player making the move (‘B’ or ‘W’).

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.