Skip to content

Instantly share code, notes, and snippets.

@joooyzee
Created July 26, 2021 05:44
Show Gist options
  • Save joooyzee/b053ab09eb908996633c269c6492cffd to your computer and use it in GitHub Desktop.
Save joooyzee/b053ab09eb908996633c269c6492cffd to your computer and use it in GitHub Desktop.
from .helpers import *
class Agent:
def __init__(self):
'''
Place any initialization code for your agent here (if any)
'''
self.pending_actions = []
def next_move(self, game_state, player_state):
'''
This method is called each time your Agent is required to choose an action
'''
print(f"tick: {game_state.tick_number}")
# ammo spawns randomly
ammo = get_ammo(game_state)
treasure = get_treasure(game_state)
if len(self.pending_actions) > 0:
action = self.pending_actions.pop()
print(f"moving: {action}")
elif ammo:
path = astar(game_state, player_state.location, ammo)
if path:
actions = get_path_actions(path)
print(f"--ACTIONS: {actions}")
for action in actions:
self.pending_actions.append(action)
action = self.pending_actions.pop()
else:
action = ''
else:
action = ''
return action
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment