style/#0: run black formatting.
parent
65021caedb
commit
803937ed3e
17
src/board.py
17
src/board.py
|
|
@ -23,6 +23,7 @@ class TrapType(StrEnum):
|
|||
SERPENT = "Serpent"
|
||||
SPIDER = "Spider"
|
||||
|
||||
|
||||
@dataclass
|
||||
class Relic:
|
||||
"""A Relic that can be encountered during a round."""
|
||||
|
|
@ -223,24 +224,23 @@ class Round:
|
|||
continue
|
||||
|
||||
# Player's decision about quitting.
|
||||
is_player_quitting: bool = self._lst_player_decision[_i_player](i_card=self._deck.nb_cards_drawn)
|
||||
is_player_quitting: bool = self._lst_player_decision[_i_player](
|
||||
i_card=self._deck.nb_cards_drawn
|
||||
)
|
||||
|
||||
# Keep if the player is quitting or not.
|
||||
if is_player_quitting:
|
||||
lst_i_player_quitting.append(_i_player)
|
||||
|
||||
|
||||
# Check if the gems needs to be collected.
|
||||
nb_quitting: int = len(lst_i_player_quitting)
|
||||
if nb_quitting != 0:
|
||||
# Compute the gems each leaving player will have.
|
||||
gems_per_player: int = sum([
|
||||
_nb_gems // nb_quitting for _nb_gems in self._lst_gems_onfloor
|
||||
])
|
||||
gems_per_player: int = sum(
|
||||
[_nb_gems // nb_quitting for _nb_gems in self._lst_gems_onfloor]
|
||||
)
|
||||
# Update the number of gems that will remain on the floor.
|
||||
self._lst_gems_onfloor = [
|
||||
_nb_gems % nb_quitting for _nb_gems in self._lst_gems_onfloor
|
||||
]
|
||||
self._lst_gems_onfloor = [_nb_gems % nb_quitting for _nb_gems in self._lst_gems_onfloor]
|
||||
|
||||
# Give the gems to the leaving players and mark them as leavers.
|
||||
for _i_player in lst_i_player_quitting:
|
||||
|
|
@ -257,6 +257,7 @@ class Round:
|
|||
if self._lst_player_exploring.count(True) == 0:
|
||||
self._everyone_quit = True
|
||||
|
||||
|
||||
class Board:
|
||||
"""
|
||||
Model the whole game board.
|
||||
|
|
|
|||
|
|
@ -5,13 +5,17 @@ import math
|
|||
# Project packages.
|
||||
from board import Board
|
||||
|
||||
class MetaBoard(Board):
|
||||
|
||||
class MetaBoard(Board):
|
||||
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
|
||||
self._lst_player_decision = [Quit5Decision().is_quitting, RandomHalfDecision().is_quitting, RandomAtanDecision().is_quitting]
|
||||
self._lst_player_decision = [
|
||||
Quit5Decision().is_quitting,
|
||||
RandomHalfDecision().is_quitting,
|
||||
RandomAtanDecision().is_quitting,
|
||||
]
|
||||
|
||||
|
||||
class BasicDecision:
|
||||
|
|
@ -32,7 +36,7 @@ class RandomAtanDecision(BasicDecision):
|
|||
def is_quitting(self, **kwargs) -> bool:
|
||||
|
||||
if "i_card" not in kwargs:
|
||||
print("RandomAtanDecision needs parameter \"i_card\" for decision.")
|
||||
print('RandomAtanDecision needs parameter "i_card" for decision.')
|
||||
return True
|
||||
|
||||
# Probability limit for the player to leave the game depending on the number of cards
|
||||
|
|
@ -40,11 +44,12 @@ class RandomAtanDecision(BasicDecision):
|
|||
threshold: float = math.atan((kwargs["i_card"] - 1) / 5) / (math.pi / 2)
|
||||
return random.random() < threshold
|
||||
|
||||
|
||||
class Quit5Decision(BasicDecision):
|
||||
|
||||
def is_quitting(self, **kwargs) -> bool:
|
||||
if "i_card" not in kwargs:
|
||||
print("RandomAtanDecision needs parameter \"i_card\" for decision.")
|
||||
print('RandomAtanDecision needs parameter "i_card" for decision.')
|
||||
return True
|
||||
|
||||
# Quit after five rounds.
|
||||
|
|
|
|||
Loading…
Reference in New Issue