-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathZGameHumanPlay.py
More file actions
37 lines (33 loc) · 1.11 KB
/
ZGameHumanPlay.py
File metadata and controls
37 lines (33 loc) · 1.11 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
import json
import uuid
import gym
import gym_zgame
from gym_zgame.envs.enums.PLAY_TYPE import PLAY_TYPE
from gym_zgame.envs.enums.PLAYER_ACTIONS import LOCATIONS, DEPLOYMENTS
from GUI import *
class ZGame:
def __init__(self, data_log_file='data_log.json', developer_mode = False):
self.ENV_NAME = 'ZGame-v0'
self.DATA_LOG_FILE_NAME = data_log_file
self.DEVELOPER_MODE = developer_mode
self.GAME_ID = uuid.uuid4()
self.env = None
self.turn = 0
self.max_turns = 14
# Always do these actions upon start
self._setup()
def _setup(self):
# Game parameters
self.env = gym.make(self.ENV_NAME)
self.env.developer_mode = self.DEVELOPER_MODE
self.env.play_type = PLAY_TYPE.HUMAN
self.env.render_mode = 'human'
self.env.MAX_TURNS = 14
self.env.reset()
# Report success
print('Created new environment {0} with GameID: {1}'.format(self.ENV_NAME, self.GAME_ID))
def run(self):
#Instantiating GUI
root = Tk()
user_interface = GUI(root,self)
root.mainloop()