add missing file
This commit is contained in:
parent
1484d0d90f
commit
beecacb897
1 changed files with 19 additions and 0 deletions
19
bots.py
Normal file
19
bots.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
import subprocess
|
||||
|
||||
from games import get_game_json, GAMES_PATH
|
||||
|
||||
|
||||
def run_strategy(game_id: int, strategy: str):
|
||||
if strategy not in ['cheat', 'info', 'random']:
|
||||
print('Strategy has to be one of cheat, info or random')
|
||||
return
|
||||
get_game_json(game_id)
|
||||
result = subprocess.run(['./rust_hanabi', '--file', str((GAMES_PATH / str(game_id))), '--json-output', '%-' + strategy, '--strategy', strategy])
|
||||
if result.returncode != 0:
|
||||
print('Failed to run game {} with cheating stratgey'.format(game_id))
|
||||
|
||||
|
||||
def ensure_bot_game_exists(game_id: int, strategy: str):
|
||||
filename = GAMES_PATH / '{}-{}'.format(game_id, strategy)
|
||||
if not filename.exists():
|
||||
run_strategy(game_id, strategy)
|
Loading…
Reference in a new issue