Commit 73e1fd10 authored by Julian Rudolf's avatar Julian Rudolf
Browse files

agent now on all maps

parent 14eafdee
......@@ -176,9 +176,11 @@ def search(dir, head, apples, steps, max_steps=50, kill=0, crossing=False):
# calculates nearest apple from all directions
# determines if enemy snake travels towards agent snake on neighboring edges
# returns a Feature object
def calc_state_space(snake_agent, snake_enemy, apples):
def calc_state_space(snake_agent, snake_enemy, apples, map_):
global map
global head_e
global dir_e
map = map_
head = snake_agent.pos[1] / block_size, snake_agent.pos[0] / block_size
dir = snake_agent.direction
head_e = snake_enemy.pos[1] / block_size, snake_enemy.pos[0] / block_size
......@@ -1198,7 +1198,7 @@ def game_loop():
for apple in a:
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)
state = calc_state_space(snake2, snake1, agent_apples, map)
action = snake2.choose_best_action(qtable, state)
action_taken = True
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