-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
48 lines (40 loc) · 1.74 KB
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# coding=utf-8
import click
import time
from yaml import dump
from client import CommsClient
from poker_rounds.betting_player import AIBettingPlayer
from poker_rounds.human_betting_player import HumanBettingPlayer
from poker_rounds.poker_sequencer import PokerGameSequencer
"""This is the main runnable code, send the argument --help:
Usage: run.py [OPTIONS]
Options:
--log-level INTEGER Log level for the client, lower is more logs
--player TEXT Player, (c)omputer or (h)uman
--host TEXT Hostname of the redis message broker
--num-players INTEGER The number of players to wait for in the game
--help Show this message and exit.
"""
@click.command()
@click.option('--log-level', default=100, help='Log level for the client, lower is more logs')
@click.option('--player', default='c', help='Player, (c)omputer or (h)uman')
@click.option('--host', default='localhost', help='Hostname of the redis message broker')
@click.option('--num-players', default=3, help='The number of players to wait for in the game')
def run(log_level, player, host, num_players):
print(player, num_players)
if player == 'c':
betting_player = AIBettingPlayer()
elif player == 'h':
betting_player = HumanBettingPlayer()
else:
print("Invalid arguments, please specify a player")
return
rounds = PokerGameSequencer()
cli = CommsClient(rounds, {'betting_player': betting_player, 'log_level': log_level,
'host': host, 'num_players': num_players}).begin()
print("- [Game Over, {}]".format(time.time()))
print("~~~~~~~ Game State Log ~~~~~~~~~~")
print(dump(cli['game'].state_log))
print("My Ident: %s" % cli['ident'])
if __name__ == '__main__':
run()