Commit f7e9700e authored by Julian Rudolf's avatar Julian Rudolf
Browse files

dockerfile works now, only snake length issue needs to be resolved

added experiments.txt and qTables
parent dfc5b244
import sys
import random
import Game.maps as maps
import multiprocessing as mp
import pickle
sys.path.append("../Game")
sys.path.append("../Shield")
sys.path.append("../Agent")
import maps as maps
from shield import ShieldSnake, get_shield, find_node, init_shield
from graph_from_map import generate_graph
from state import calc_state_space, State
......
import sys
sys.path.append("../Game")
import random
import Game.maps as maps
import maps as maps
map = maps.map3
block_size = 30
head_e = 0
......
......@@ -55,11 +55,11 @@ RUN python3 -m pip install -r /temp/pip_req.txt
# comment out main.py:loadingscreen line 967 (generate_graph(snake_length, map, map_filename))
# docker run -it --rm -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=$DISPLAY --name snake IMAGE_NAME:TAG
# COPY . /2psnake
COPY . /2psnake
# RUN useradd -m -U -s /bin/bash pygame
# USER pygame
RUN useradd -m -U -s /bin/bash pygame
USER pygame
# WORKDIR /2psnake/Game
# ENV SHELL /bin/bash
# ENTRYPOINT ["python3", "main.py"]
\ No newline at end of file
WORKDIR /2psnake/Game
ENV SHELL /bin/bash
ENTRYPOINT ["python3", "main.py"]
\ No newline at end of file
Mean Worst-Case
-------------------------------------------
Snake Length: 10
0.11005938212000728 0.2001933720002853
0.11199878764999084 0.22716360200001873
0.12997044739000102 0.25403552699981446
0.1488221236850154 0.2853255459999673
0.1713842649550179 0.35535290200004965
0.18908970305500133 0.43465456700005234
0.25415917569498786 0.5533510560003378
0.3020209189299976 0.7737110130001383
0.385568985350003 0.995456600000125
0.5024551234550109 1.7424511599997459
0.6443020495050223 2.5931802049999533
0.8723925955150026 3.2465751210002054
1.194396347245047 5.294773026999792
1.7095835727249777 6.500898020999557
2.285291928565025 9.15538882600049
3.3799647720200574 15.571367145000295
4.1185061999099934 18.55722617399988
7.622854843179994 27.553530447999947
10.699965626380044 37.03164676399865
13.388397301335008 54.4620576870002
19.850223488294898 107.10121896000055
Snake Length: 15
0.10313165453493639 0.200112103997526
0.1152424167701065 0.20068860399987898
0.13260335349985325 0.2538558150008612
0.15119998709003993 0.3244189219985856
0.16982659919491197 0.3604728709979099
0.19919665256005828 0.48978475100011565
0.2675545788501222 0.7184256390028168
0.3080347252449428 0.7399667360004969
0.3875711088949538 1.2503016579976247
0.4991048643499562 1.599513304001448
0.6437847887148382 2.1503673899969726
0.792232145469934 2.5975114479988406
1.174807025980099 6.6338512809998065
1.726518008199946 7.440847489000589
2.5746387787999447 12.685257902001467
3.6330542681951012 21.218907209000463
5.7254192267948385 18.232909262998874
7.0080649674249615 28.092808004999824
10.417540839444774 65.05461321500115
16.299266593935027 80.9978720930012
20.895262981064807 133.7510083039997
Snake Length: 20
0.10391265763002594 0.18787874799818383
0.11843566682493474 0.24249298099675798
0.13529489298498448 0.2569774049989064
0.1535116418400321 0.2863680359987484
0.17592913148017034 0.40381152000190923
0.20990230321489434 0.41338331399674644
0.2702451271500286 0.6097982120008965
0.3158955036200314 0.7326872940029716
0.40219500370512834 1.164302647997829
0.4449071868601095 1.2980287589998625
0.63174285331992 2.187705186999665
0.7773735708801723 2.3311894129983557
1.1148831520101885 4.901464181999472
1.6311476322850649 7.193275439996796
2.0339306631802536 8.547816584003158
3.4669421428803253 15.082328233002045
5.065392146144841 19.69493949000025
7.259508114044838 25.750400124998123
9.39959108044477 33.00506514200242
13.7521619228501 49.72189590999915
20.66706598636032 86.76819785599946
......@@ -7,10 +7,11 @@ import pickle
sys.path.append("../Shield")
sys.path.append("../Agent")
sys.path.append("../State")
from shield import ShieldSnake, get_shield, find_node, init_shield
from graph_from_map import generate_graph
from Agent.state import calc_state_space, State
from Agent.agent import load_qtable
from state import calc_state_space, State
from agent import load_qtable
# -------------------------------------------------------------------
......@@ -1197,10 +1198,7 @@ def game_loop():
if img == purple_apple:
agent_apples.append((int(apple.pos[0] / block_size), int(apple.pos[1] / block_size)))
state = calc_state_space(snake2, snake1, agent_apples)
#print("l: ", state.df_l, " r: ", state.df_r, " u: ", state.df_u, " d: ", state.df_d)
#print("l: ", state.kill_l, " r: ", state.kill_r, " u: ", state.kill_u, " d: ", state.kill_d)
action = snake2.choose_best_action(qtable, state)
#print(action)
snake2.key_event(action)
action_taken = True
......
File added
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment