haive.games.common.voting_system¶

Generalized AI Voting System for Game Winner Determination.

This module provides a reusable voting system that can evaluate game performance across different game types using AI judges with specialized perspectives.

Classes¶

AIGameJudge

AI judge that can evaluate any game type.

ChessEvaluator

Evaluator for chess games.

DebateEvaluator

Evaluator for debate games.

GameEvaluator

Protocol for game-specific evaluation logic.

GameVotingSystem

Generalized voting system for any game type.

JudgePersonality

Different AI judge personalities for game evaluation.

VoteChoice

A judge's vote choice with reasoning.

VotingResult

Complete voting results from multiple judges.

Functions¶

create_voting_system([game_type, num_judges])

Create appropriate voting system for game type.

Module Contents¶

class haive.games.common.voting_system.AIGameJudge(name, personality=JudgePersonality.BALANCED, expertise_area=None, focus_weight=0.5)¶

AI judge that can evaluate any game type.

Parameters:
async evaluate(topic, options, game_data, criteria)¶

Evaluate the game and return a vote choice.

Parameters:
Return type:

VoteChoice

class haive.games.common.voting_system.ChessEvaluator¶

Evaluator for chess games.

class haive.games.common.voting_system.DebateEvaluator¶

Evaluator for debate games.

class haive.games.common.voting_system.GameEvaluator¶

Bases: Protocol

Protocol for game-specific evaluation logic.

format_game_data(game_data)¶

Format game data for judge evaluation.

Parameters:

game_data (Any)

Return type:

str

get_evaluation_context()¶

Get context-specific information for judges.

Return type:

str

get_evaluation_criteria()¶

Get the criteria this game should be judged on.

Return type:

list[str]

class haive.games.common.voting_system.GameVotingSystem(judges)¶

Generalized voting system for any game type.

Parameters:

judges (list[AIGameJudge])

classmethod create_game_specific_judges(game_type, num_judges=3)¶

Create judges specialized for a specific game type.

Parameters:
  • game_type (str) – Type of game to create judges for

  • num_judges (int) – Number of judges to create (default: 3)

Return type:

GameVotingSystem

classmethod create_standard_judges(num_judges=3)¶

Create standard judge panel with configurable size and randomized. personalities.

Parameters:

num_judges (int) – Number of judges to create (default: 3 to avoid ties) Odd numbers recommended to prevent tie votes.

Return type:

GameVotingSystem

async vote(topic, options, game_data, criteria, evaluator=None)¶

Conduct voting with all judges.

Parameters:
Return type:

VotingResult

class haive.games.common.voting_system.JudgePersonality¶

Bases: str, enum.Enum

Different AI judge personalities for game evaluation.

Initialize self. See help(type(self)) for accurate signature.

class haive.games.common.voting_system.VoteChoice(/, **data)¶

Bases: pydantic.BaseModel

A judge’s vote choice with reasoning.

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.

Parameters:

data (Any)

class haive.games.common.voting_system.VotingResult(/, **data)¶

Bases: pydantic.BaseModel

Complete voting results from multiple judges.

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.

Parameters:

data (Any)

haive.games.common.voting_system.create_voting_system(game_type='general', num_judges=3)¶

Create appropriate voting system for game type.

Parameters:
  • game_type (str) – Type of game (“general”, “chess”, “debate”, “poker”, “go”)

  • num_judges (int) – Number of judges (default: 3 to avoid ties)

Return type:

GameVotingSystem