-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplay_human.py
54 lines (41 loc) · 1.09 KB
/
play_human.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
from logic.gameinfo import GameInfo
from logic.gameboard import GameBoard
from gui.guiinfo import GUIInfo
from gui.guimanager import GUIManager
from constants import *
# Environment Settings
rows = 11
cols = 15
gameInfo = GameInfo(rows = rows,
cols = cols,
startPos = (rows//2, cols//4),
startDir = RIGHT)
guiInfo = GUIInfo(rows = rows,
cols = cols,
side = 35,
space = 3,
offset = (3, 3),
name = ':: Manga Snake ::')
# - - - - -
guiManager = GUIManager(guiInfo)
gameBoard = GameBoard(gameInfo)
# Main Loop
done = False
while (not done):
curr = gameBoard.update()
state = gameBoard.getState()
if curr.hitWall or curr.hitSelf:
gameBoard.reset()
guiManager.update(state)
guiManager.show()
key = guiManager.waitKey(100)
if key == K_ESC:
done = True
elif key == K_A:
gameBoard.goLeft()
elif key == K_D:
gameBoard.goRight()
# - - - - -
guiManager.finish()
# Q-learning | SARS | Off-policy | Q-value
# SARSA | SARSA | On-policy | Q-value