style/#0: run black formatting.

Gaëlle Martin 2025-09-04 22:46:09 +02:00
parent 04d051ba37
commit 2a2b63de6e
2 changed files with 20 additions and 14 deletions

View File

@ -23,6 +23,7 @@ class TrapType(StrEnum):
SERPENT = "Serpent" SERPENT = "Serpent"
SPIDER = "Spider" SPIDER = "Spider"
@dataclass @dataclass
class Relic: class Relic:
"""A Relic that can be encountered during a round.""" """A Relic that can be encountered during a round."""
@ -223,24 +224,23 @@ class Round:
continue continue
# Player's decision about quitting. # 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. # Keep if the player is quitting or not.
if is_player_quitting: if is_player_quitting:
lst_i_player_quitting.append(_i_player) lst_i_player_quitting.append(_i_player)
# Check if the gems needs to be collected. # Check if the gems needs to be collected.
nb_quitting: int = len(lst_i_player_quitting) nb_quitting: int = len(lst_i_player_quitting)
if nb_quitting != 0: if nb_quitting != 0:
# Compute the gems each leaving player will have. # Compute the gems each leaving player will have.
gems_per_player: int = sum([ gems_per_player: int = sum(
_nb_gems // nb_quitting for _nb_gems in self._lst_gems_onfloor [_nb_gems // nb_quitting for _nb_gems in self._lst_gems_onfloor]
]) )
# Update the number of gems that will remain on the floor. # Update the number of gems that will remain on the floor.
self._lst_gems_onfloor = [ self._lst_gems_onfloor = [_nb_gems % nb_quitting for _nb_gems in 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. # Give the gems to the leaving players and mark them as leavers.
for _i_player in lst_i_player_quitting: for _i_player in lst_i_player_quitting:
@ -257,6 +257,7 @@ class Round:
if self._lst_player_exploring.count(True) == 0: if self._lst_player_exploring.count(True) == 0:
self._everyone_quit = True self._everyone_quit = True
class Board: class Board:
""" """
Model the whole game board. Model the whole game board.
@ -318,4 +319,4 @@ class Board:
+ ")" + ")"
) )
self.i_round += 1 self.i_round += 1

View File

@ -5,13 +5,17 @@ import math
# Project packages. # Project packages.
from board import Board from board import Board
class MetaBoard(Board):
class MetaBoard(Board):
def __init__(self) -> None: def __init__(self) -> None:
super().__init__() 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: class BasicDecision:
@ -32,7 +36,7 @@ class RandomAtanDecision(BasicDecision):
def is_quitting(self, **kwargs) -> bool: def is_quitting(self, **kwargs) -> bool:
if "i_card" not in kwargs: if "i_card" not in kwargs:
print("RandomAtanDecision needs parameter \"i_card\" for decision.") print('RandomAtanDecision needs parameter "i_card" for decision.')
return True return True
# Probability limit for the player to leave the game depending on the number of cards # Probability limit for the player to leave the game depending on the number of cards
@ -40,12 +44,13 @@ class RandomAtanDecision(BasicDecision):
threshold: float = math.atan((kwargs["i_card"] - 1) / 5) / (math.pi / 2) threshold: float = math.atan((kwargs["i_card"] - 1) / 5) / (math.pi / 2)
return random.random() < threshold return random.random() < threshold
class Quit5Decision(BasicDecision): class Quit5Decision(BasicDecision):
def is_quitting(self, **kwargs) -> bool: def is_quitting(self, **kwargs) -> bool:
if "i_card" not in kwargs: if "i_card" not in kwargs:
print("RandomAtanDecision needs parameter \"i_card\" for decision.") print('RandomAtanDecision needs parameter "i_card" for decision.')
return True return True
# Quit after five rounds. # Quit after five rounds.
return kwargs["i_card"] > 5 return kwargs["i_card"] > 5