This repository was archived by the owner on Jul 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
48 lines (40 loc) · 1.87 KB
/
main.py
File metadata and controls
48 lines (40 loc) · 1.87 KB
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
import os
import logging
import argparse
from chillow.service import ai
from chillow.controller import OnlineController, OfflineController, AIEvaluationController
from chillow.service.data_loader import JSONDataLoader
from chillow.service.data_writer import JSONDataWriter
if __name__ == "__main__":
logging.basicConfig(format='%(asctime)s - %(levelname)s - %(message)s', level=logging.WARNING)
parser = argparse.ArgumentParser()
parser.add_argument('-o', '--play-online', type=bool, default=False)
parser.add_argument('-d', '--deactivate-pygame', type=bool, default=False)
parser.add_argument('-r', '--ai-eval-runs', type=int, default=0)
parser.add_argument('-p', '--ai-eval-db-path', type=str, default="evaluation.db")
parser.add_argument('-t', '--ai-eval-type', type=int, default=1)
args = parser.parse_args()
if args.deactivate_pygame:
from chillow.view.console_view import ConsoleView
monitoring = ConsoleView()
else:
import pygame
from chillow.view.graphical_view import GraphicalView
monitoring = GraphicalView(pygame)
if not args.play_online:
if args.ai_eval_runs > 0:
con = AIEvaluationController(args.ai_eval_runs, args.ai_eval_db_path, args.ai_eval_type)
else:
con = OfflineController(monitoring)
else:
url = os.getenv("URL")
key = os.getenv("KEY")
assert url is not None, "URL is not set as environment variable"
assert key is not None, "KEY is not set as environment variable"
server_time_url = os.getenv("TIME_URL")
data_loader = JSONDataLoader()
data_writer = JSONDataWriter()
ai_class = ai.PathfindingSearchTreeAI.__name__
ai_params = (1, 50, 3, 0.75, 10)
con = OnlineController(monitoring, url, key, server_time_url, data_loader, data_writer, ai_class, ai_params)
con.play()