Game¶
Role: Orchestrates a single QSeaBattle game between two players by coordinating a
GameEnvand aPlayersfactory.
Location: Q_Sea_Battle.game.Game
Constructor¶
| Parameter | Type | Description |
|---|---|---|
game_env |
GameEnv, not specified, shape N/A |
Game environment instance. |
players |
Players, not specified, shape N/A |
Players factory providing Player A and B. |
Preconditions
game_envis notNone.playersis notNone.game_envprovides methods:reset(),provide(),apply_channel_noise(comm),evaluate(shoot).playersprovides methods:reset(),players()returning two player objects with methoddecide(...).
Postconditions
self.game_envreferences the providedgame_env.self.playersreferences the providedplayers.
Errors
- Not specified (constructor contains no explicit validation or exception handling).
Example
from Q_Sea_Battle.game import Game
from Q_Sea_Battle.game_env import GameEnv
from Q_Sea_Battle.players_base import Players
game_env = GameEnv(...) # Not specified
players = Players(...) # Not specified
game = Game(game_env=game_env, players=players)
Public Methods¶
play() -> Tuple[float, np.ndarray, np.ndarray, np.ndarray, int]¶
Play a single game round by resetting environment and players, obtaining player instances, providing (field, gun) from the environment, having Player A produce a communication, applying channel noise, having Player B decide whether to shoot, and evaluating the reward.
Returns
reward:float, not specified, shape N/A.field:np.ndarray, not specified, shape not specified (documented as flattened in docstring).gun:np.ndarray, not specified, shape not specified (documented as flattened in docstring).comm:np.ndarray, not specified, shape not specified (returned value is the noisy communication; documented as flattened in docstring).shoot:int, constraints not specified, shape N/A (constructed asint(shoot)from Player B decision).
Errors
- Not specified (method contains no explicit exception handling; may propagate exceptions raised by
GameEnv,Players, or player instances).
Example
reward, field, gun, comm, shoot = game.play()
Data & State¶
game_env:GameEnv, not specified, shape N/A; stored reference to the environment used forreset(),provide(),apply_channel_noise(...), andevaluate(...).players:Players, not specified, shape N/A; stored reference to the players factory used forreset()andplayers().
Planned (design-spec)¶
- Not specified.
Deviations¶
- The
play()docstring states it returns(reward, field, gun, comm, shoot), wherecommrefers to the communication; the implementation returnscomm_noisy(noisy communication) in thecommposition.
Notes for Contributors¶
play()assumesGameEnv.provide()returns(field, gun)in a format compatible withplayer_a.decide(field, supp=None)andplayer_b.decide(gun, comm_noisy, supp=None); the precise dtypes/shapes are not enforced in code.shootis cast tointon return; ifplayer_b.decide(...)returns a non-scalar or non-castable object,int(shoot)will raise.
Related¶
Q_Sea_Battle.game_env.GameEnvQ_Sea_Battle.players_base.Players
Changelog¶
- 0.1: Initial implementation of single-game orchestration via
Game.play().