-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow specifying number of games via arg
Leverage click (already a dependency) to accept a command line argument for specifying the number of games to play.
- Loading branch information
1 parent
5f9617f
commit 6bb0e96
Showing
2 changed files
with
21 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,24 @@ | ||
import click | ||
from rps.player import BotPlayer | ||
from rps.play import human_readable | ||
from rps.strategy import RandomPlayStrategy | ||
from rps.game import play_games | ||
|
||
|
||
player1 = BotPlayer(RandomPlayStrategy()) | ||
player2 = BotPlayer(RandomPlayStrategy()) | ||
results = play_games(player1, player2, 3) | ||
|
||
# Hard-coded, simple demonstration of a play-through | ||
for result in results: | ||
print("Result: Player 1...", human_readable(result)) | ||
@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()) | ||
results = play_games(player1, player2, games) | ||
|
||
for result in results: | ||
# Simple message with results | ||
print("Result: Player 1", human_readable(result)) | ||
|
||
print("Simulation finished.") | ||
print("Simulation finished.") | ||
|
||
|
||
if __name__ == '__main__': | ||
simple_sim() |