MajorityPlayers¶
Role: Factory that creates a paired
(MajorityPlayerA, MajorityPlayerB)sharing a singleGameLayoutinstance. Location:Q_Sea_Battle.majority_players.MajorityPlayers
Constructor¶
| Parameter | Type | Description |
|---|---|---|
| game_layout | GameLayout | None, constraints: if not None must be a valid GameLayout instance, shape: N/A |
Shared game configuration; if None, the base class creates a default GameLayout. |
Preconditions
- Not specified.
Postconditions
self.game_layoutis set (created by the base class ifgame_layout is None).
Errors
- Not specified.
Example
from Q_Sea_Battle.majority_players import MajorityPlayers
factory = MajorityPlayers()
player_a, player_b = factory.players()
Public Methods¶
players¶
Creates and returns a (player_a, player_b) pair that share this factory's GameLayout.
Signature
players(self) -> Tuple[PlayerA, PlayerB]
Parameters
- None.
Returns
Tuple[PlayerA, PlayerB], constraints: 2-tuple(player_a, player_b), shape:(2,)whereplayer_ais an instance ofMajorityPlayerA(aPlayerA) andplayer_bis an instance ofMajorityPlayerB(aPlayerB).
Preconditions
self.game_layoutexists and is aGameLayoutinstance (established by the base class constructor).
Postconditions
- Returns two newly constructed player objects.
- Both returned players reference the exact same
GameLayoutinstance (self.game_layout).
Errors
- Not specified.
Example
factory = MajorityPlayers()
player_a, player_b = factory.players()
assert player_a.game_layout is player_b.game_layout
Data & State¶
game_layout:GameLayout, constraints: notNoneafter construction, shape: N/A; provided by thePlayersbase class and shared by all created players.
Planned (design-spec)¶
- Not specified.
Deviations¶
- Not specified.
Notes for Contributors¶
- The
players()method must preserve identity sharing: both players must be constructed with the sameself.game_layoutobject (not a copy).
Related¶
Q_Sea_Battle.players_base.PlayersQ_Sea_Battle.majority_player_a.MajorityPlayerAQ_Sea_Battle.majority_player_b.MajorityPlayerBQ_Sea_Battle.game_layout.GameLayout
Changelog¶
- Not specified.