-
Notifications
You must be signed in to change notification settings - Fork 9
/
main.py
executable file
·57 lines (49 loc) · 1.88 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
55
56
57
#!/usr/bin/python3
import argparse
import team_config
from lib.debug.debug import log
parser = argparse.ArgumentParser(description='Run a player or a coach')
parser.add_argument('--player', action='store_true', help='Run a player', default=True)
parser.add_argument('--coach', action='store_true', help='Run a coach')
parser.add_argument('--goalie', action='store_true', help='Run a goalie')
parser.add_argument('-t', '--team-name', help='Team name to display')
parser.add_argument('-H', '--host', help='Server IP address')
parser.add_argument('-p', '--player-port', help='Server Player port')
parser.add_argument('-P', '--coach-port', help='Server Coach port')
parser.add_argument('--trainer-port', help='Server Trainer port')
parser.add_argument('--log-path', help='Path to store logs')
parser.add_argument('--file-log-level', help='Log level for file')
parser.add_argument('--console-log-level', help='Log level for console')
parser.add_argument('--disable-file-log', action='store_true', help='Disable file logging')
args = parser.parse_args()
team_config.update_team_config(args)
from base.sample_coach import SampleCoach
from base.sample_player import SamplePlayer
import sys
def main():
if args.player:
agent = SamplePlayer()
elif args.coach:
agent = SampleCoach()
elif args.goalie:
agent = SamplePlayer(True)
else:
print("Please specify --player or --coach")
return
if not agent.handle_start():
agent.handle_exit()
return
try:
agent.run()
except KeyboardInterrupt:
print("\nApplication interrupted. Exiting...")
agent.handle_exit()
sys.exit(0)
if __name__ == "__main__":
try:
main()
except Exception as e:
import traceback
traceback.print_exc()
log.os_log().error(f"Error: {e}")
log.os_log().error(traceback.format_exc())