Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1from banco_imobiliario.config import settings
3from .game_board import GameBoard
4from .player_cautious import PlayerCautious
5from .player_demanding import PlayerDemanding
6from .player_impulsive import PlayerImpulsive
7from .player_random import PlayerRandom
9strategies = {
10 "impulsive": PlayerImpulsive,
11 "demanding": PlayerDemanding,
12 "cautious": PlayerCautious,
13 "randomer": PlayerRandom,
14}
17def create_player(strategy: str, *args, **kwargs):
18 try:
19 return strategies[strategy](strategy=strategy, *args, **kwargs)
21 except KeyError:
22 available_strategies = ", ".join(strategies.keys())
23 raise NotImplementedError(
24 f"The player strategy '{strategy}' is not implemented."
25 f"Please use the available strategies: {available_strategies}"
26 )
29def create_board():
30 board = GameBoard()
31 players = [
32 create_player(strategy)
33 for strategy in settings.ENV_STRATEGY
34 ]
35 board.players = players
36 return board