diff --git a/rps-sim.py b/rps-sim.py index 016d55f..5faebdc 100644 --- a/rps-sim.py +++ b/rps-sim.py @@ -8,14 +8,16 @@ @click.command @click.option("--games", default=3, type=click.IntRange(min=1, max=1000), help="Number of games to play") -def simple_sim(games: int) -> None: - player1 = BotPlayer(RandomPlayStrategy()) - player2 = BotPlayer(RandomPlayStrategy()) +@click.option("--p1-name", default="Player 1", help="Name of first player") +@click.option("--p2-name", default="Player 2", help="Name of second player") +def simple_sim(games: int, p1_name: str, p2_name: str) -> None: + player1 = BotPlayer(RandomPlayStrategy(), p1_name) + player2 = BotPlayer(RandomPlayStrategy(), p2_name) results = play_games(player1, player2, games) for result in results: # Simple message with results - print("Result: Player 1", human_readable(result)) + print("Result:", player1.name, human_readable(result)) print("Simulation finished.") diff --git a/rps/player.py b/rps/player.py index 990517a..f20ed59 100644 --- a/rps/player.py +++ b/rps/player.py @@ -5,14 +5,17 @@ class Player(object): + name: str + @abc.abstractmethod def play(self) -> Play: """Required method""" class BotPlayer(Player): - def __init__(self, play_strategy: PlaySelectionStrategy): + def __init__(self, play_strategy: PlaySelectionStrategy, name: str = "Bot Player"): self.__strategy = play_strategy + self.name = name def play(self) -> Play: return self.__strategy.play()