SimplePlayerA¶
Role: Deterministic Player A that encodes the first \(m\) bits of the flattened field into the communication vector.
Location: Q_Sea_Battle.simple_player_a.SimplePlayerA
Constructor¶
| Parameter | Type | Description |
|---|---|---|
| game_layout | GameLayout, constraints Not specified, shape Not applicable | Game configuration for this player. |
Preconditions
game_layoutis aGameLayoutinstance compatible withPlayerAand providescomms_size(type constraints Not specified).
Postconditions
- The instance is initialized via
PlayerA.__init__(game_layout). self.game_layoutis available (inherited; exact storage not specified in this module).
Errors
- Not specified.
Example
from Q_Sea_Battle.simple_player_a import SimplePlayerA
from Q_Sea_Battle.game_layout import GameLayout
gl = GameLayout(...) # Not specified in this module
player = SimplePlayerA(gl)
Public Methods¶
decide¶
| Parameter | Type | Description |
|---|---|---|
| field | np.ndarray, dtype convertible to int, constraints values intended {0,1}, shape (any, ...) | Field array of 0/1 values; any shape is accepted and will be flattened internally. |
| supp | Any or None, constraints Optional, shape Not applicable | Optional supporting information (unused). |
Returns
- np.ndarray, dtype int, constraints derived from
fieldafternp.asarray(..., dtype=int), shape (m,) where \(m = \text{self.game_layout.comms_size}\).
Preconditions
self.game_layout.comms_sizeexists and is an integer \(m\) with \(0 \le m\) (upper bound not specified).fieldis array-like and convertible vianp.asarray(field, dtype=int).
Postconditions
- Returns a copy of the first \(m\) elements of
np.asarray(field, dtype=int).ravel().
Errors
- May raise any exception propagated by
np.asarray(field, dtype=int)if conversion fails (exact exception types not specified). - May raise an exception if
self.game_layoutorself.game_layout.comms_sizeis missing (exact exception types not specified).
Example
import numpy as np
from Q_Sea_Battle.simple_player_a import SimplePlayerA
player = SimplePlayerA(game_layout) # game_layout must provide comms_size
field = np.array([[1, 0, 1], [0, 1, 0]])
comms = player.decide(field)
Data & State¶
- Inherits state from
PlayerA(not defined in this module). - Reads
self.game_layout.comms_sizeduringdecideto determine \(m\) (type/validation not specified here).
Planned (design-spec)¶
- Not specified.
Deviations¶
- Not specified.
Notes for Contributors¶
- Keep
decidedeterministic: it should depend only onfieldandself.game_layout.comms_size. suppis currently unused; if future behavior uses it, update the method contract accordingly.
Related¶
Q_Sea_Battle.players_base.PlayerA(base class; not included in this module text)Q_Sea_Battle.game_layout.GameLayout(configuration type; not included in this module text)
Changelog¶
- 0.1: Initial deterministic implementation encoding the first \(m\) flattened field cells into the communication vector.