minor improvements

This commit is contained in:
Adrian Gunnar Lauterer 2024-04-07 00:34:08 +02:00
parent 1f11ca9009
commit 0f8b6ec693
Signed by: adriangl
GPG Key ID: D33368A59745C2F0
2 changed files with 15 additions and 3 deletions

4
.gitignore vendored
View File

@ -1,3 +1,7 @@
#keep my sepcial bot secret
ml.py
# ---> Python # ---> Python
# Byte-compiled / optimized / DLL files # Byte-compiled / optimized / DLL files
__pycache__/ __pycache__/

14
main.py Normal file → Executable file
View File

@ -1,3 +1,5 @@
#!/usr/bin/env python3
from time import sleep from time import sleep
import requests import requests
import numpy as np import numpy as np
@ -272,8 +274,12 @@ def play_game(gameid, players, strategy):
for player in players: for player in players:
mov = do_move(gameid, player, filter_strategy=strategy) mov = do_move(gameid, player, filter_strategy=strategy)
if game_over(game_id): if game_over(game_id):
print(f"Game Over {player} won") #get the score of the players
break score = []
for player in players:
score.append(get_score(gameid, player))
print(f"Game Over, scores: {score}")
return score
if __name__ == "__main__": if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Play a game with specified strategies.') parser = argparse.ArgumentParser(description='Play a game with specified strategies.')
@ -281,8 +287,10 @@ if __name__ == "__main__":
parser.add_argument('--players', nargs='+', default=["a", "b"], help='The names of the players.') parser.add_argument('--players', nargs='+', default=["a", "b"], help='The names of the players.')
parser.add_argument('--strategy', type=str, default="", help='The strategy to use. Can be "1", "2", or "" for random.') parser.add_argument('--strategy', type=str, default="", help='The strategy to use. Can be "1", "2", or "" for random.')
parser.add_argument('--ozai_url', type=str, default='http://localhost:8000/api/', help='The url to the ozai server.') parser.add_argument('--ozai_url', type=str, default='http://localhost:8000/api/', help='The url to the ozai server.')
args = parser.parse_args() args = parser.parse_args()
game_id = args.game_id game_id = args.game_id
players = args.players players = args.players
strategy = args.strategy strategy = args.strategy