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

fixed an issue with inital state after reset

parent ba1f6a9d
......@@ -90,7 +90,6 @@ class QLearning:
print(dirs)
# returns all possible actions
# TODO: maby possible != not kill
def possible_directions(self):
poss_actions = []
# if not state.kill_l:
......@@ -140,6 +139,7 @@ def learning(al, ga, ep, games):
print("Starting learning process!")
for i in range(max_games):
playerwin = play_game_learning(qagent, q_0, poss_dirs_0)
q_0, poss_dirs_0 = reset()
print("Game ", i+1, "/", max_games, " finished!")
if playerwin == 1:
score[0] += 1
......
......@@ -523,7 +523,6 @@ def step(action):
reward = 0
print("Apples eaten: ", snake1.getscore())
reset()
agent_apples = []
for a, id in apples:
for apple in a:
......@@ -577,8 +576,8 @@ def step(action):
playerwin = 2
if check_if_crossing(snake1.pos[0] / block_size, snake1.pos[1] / block_size):
# print("Action needed!")
reward -= 1
if not init:
reward -= 1
agent_apples = []
for a, id in apples:
for apple in a:
......@@ -662,6 +661,8 @@ def reset():
snake2.set_enemy_norm_snake(snake1)
gameExit = False
playerwin = 0
state, _, _, poss_dirs = step("init")
return state, poss_dirs
# exit game
......
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