haive.games.mastermind.demo¶
Standalone demo for the Mastermind game with Rich UI.
This script demonstrates the Mastermind game without requiring the full Haive framework.
Classes¶
Color code for Mastermind game. |
|
Feedback for a guess in Mastermind. |
|
State for the Mastermind game. |
|
Rich terminal UI for the Mastermind game. |
Functions¶
|
Calculate feedback for a guess. |
|
Run the Mastermind game. |
Module Contents¶
- class haive.games.mastermind.demo.ColorCode(/, **data)[source]¶
Bases:
pydantic.BaseModel
Color code for Mastermind game.
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.mastermind.demo.Feedback(/, **data)[source]¶
Bases:
pydantic.BaseModel
Feedback for a guess in Mastermind.
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.mastermind.demo.MastermindState(/, **data)[source]¶
Bases:
pydantic.BaseModel
State for the Mastermind game.
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.mastermind.demo.MastermindUI[source]¶
Rich terminal UI for the Mastermind game.
Initialize the UI.
- create_guesses_table(state)[source]¶
Create table of guesses and feedback.
- Parameters:
state (MastermindState)
- Return type:
rich.table.Table
- create_header(state)[source]¶
Create header panel with game info.
- Parameters:
state (MastermindState)
- Return type:
rich.panel.Panel
- create_layout(state, show_secret=False)[source]¶
Create complete layout for the game.
- Parameters:
state (MastermindState)
show_secret (bool)
- Return type:
rich.layout.Layout
- create_secret_panel(state, show_secret=False)[source]¶
Create panel showing the secret code (or hidden).
- Parameters:
state (MastermindState)
show_secret (bool)
- Return type:
rich.panel.Panel
- display_game_state(state, show_secret=False)[source]¶
Display the current game state.
- Parameters:
state (MastermindState)
show_secret (bool)
- show_result(state)[source]¶
Show the game result.
- Parameters:
state (MastermindState)