-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
54 lines (43 loc) · 1.59 KB
/
main.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
49
50
51
52
53
54
# Free for personal or classroom use; see 'LICENSE.md' for details.
# https://github.com/squillero/computational-intelligence
import logging
import argparse
import random
import quarto
import ga_agent
from trained_rl import *
from opponent_agents import DumbAgent
class RandomPlayer(quarto.Player):
"""Random player"""
def __init__(self, quarto: quarto.Quarto) -> None:
super().__init__(quarto)
def choose_piece(self) -> int:
test = random.randint(0, 15)
#logging.debug(f"Selected piece random player: {test}")
return test
def place_piece(self) -> tuple[int, int]:
return random.randint(0, 3), random.randint(0, 3)
def main():
game = quarto.Quarto()
rl_agent = TrainedRL(game)
random_agent = RandomPlayer(game)
game.set_players((random_agent, rl_agent))
winner = game.run()
logging.warning(f"main: Winner: player {winner}")
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('-v', '--verbose', action='count', default=1, help='increase log verbosity')
parser.add_argument('-d',
'--debug',
action='store_const',
dest='verbose',
const=2,
help='log debug messages (same as -vv)')
args = parser.parse_args()
if args.verbose == 0:
logging.getLogger().setLevel(level=logging.WARNING)
elif args.verbose == 1:
logging.getLogger().setLevel(level=logging.INFO)
elif args.verbose == 2:
logging.getLogger().setLevel(level=logging.DEBUG)
main()