MajorityPlayers¶
Role: Factory that produces a
(MajorityPlayerA, MajorityPlayerB)pair sharing a commonGameLayout. Location:Q_Sea_Battle.majority_players.MajorityPlayers
Constructor¶
| Parameter | Type | Description |
|---|---|---|
| game_layout | GameLayout | None, optional | Shared configuration for both players; if None, a default GameLayout is created by the base class. |
Preconditions
- Not specified.
Postconditions
self.game_layoutis available for subsequentplayers()calls (exact initialization behavior is delegated toPlayers.__init__).
Errors
- Not specified.
Example
from Q_Sea_Battle.majority_players import MajorityPlayers
factory = MajorityPlayers()
player_a, player_b = factory.players()
Public Methods¶
players¶
Create a (MajorityPlayerA, MajorityPlayerB) pair that shares the factory's GameLayout.
Signature: players(self) -> Tuple[PlayerA, PlayerB]
Returns
- Tuple[PlayerA, PlayerB], length 2, shape (2,):
(player_a, player_b)whereplayer_ais aMajorityPlayerAandplayer_bis aMajorityPlayerB; both are constructed with the sameself.game_layout.
Preconditions
self.game_layoutis set (provided by thePlayersbase class).
Postconditions
- Two new player instances are created and returned.
Errors
- Not specified.
Example
from Q_Sea_Battle.majority_players import MajorityPlayers
from Q_Sea_Battle.game_layout import GameLayout
layout = GameLayout()
factory = MajorityPlayers(game_layout=layout)
a, b = factory.players()
Data & State¶
game_layout: GameLayout, constraints unknown, shape N/A; stored on the instance viaPlayers.__init__and passed into constructed players inplayers().
Planned (design-spec)¶
- None specified.
Deviations¶
- None identified.
Notes for Contributors¶
MajorityPlayersdelegatesgame_layoutinitialization toPlayers.__init__; update this documentation if base-class behavior changes (e.g., if defaults or validation are added there).players()currently always constructsMajorityPlayerAandMajorityPlayerBwithself.game_layout; any future support for alternative player types should be reflected here.
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¶
- 0.1: Initial version (module docstring).