Commit 94beac7f authored by Matthew Hausknecht's avatar Matthew Hausknecht

Merge pull request #7 from UNiQ10/exp

Fixed cleanup in high level random agent
parents 38b50145 bc7a979a
...@@ -12,20 +12,27 @@ except: ...@@ -12,20 +12,27 @@ except:
def get_random_action(): def get_random_action():
""" Returns a random high-level action """ """ Returns a random high-level action """
high_lv_actions = [HFO_Actions.MOVE, HFO_Actions.SHOOT, high_lv_actions = [HFO_Actions.SHOOT, HFO_Actions.PASS, HFO_Actions.DRIBBLE]
HFO_Actions.PASS, HFO_Actions.DRIBBLE]
return (random.choice(high_lv_actions), 0, 0) return (random.choice(high_lv_actions), 0, 0)
def play_hfo(num): def play_hfo(num):
""" Method called by a thread to play 5 games of HFO """ """ Method called by a thread to play 5 games of HFO """
hfo_env = hfo.HFOEnvironment() hfo_env = hfo.HFOEnvironment()
hfo_env.connectToAgentServer(6000 + num, HFO_Features.HIGH_LEVEL_FEATURE_SET) hfo_env.connectToAgentServer(6000 + num, HFO_Features.HIGH_LEVEL_FEATURE_SET)
for episode in xrange(5): try:
status = HFO_Status.IN_GAME for episode in xrange(5):
while status == HFO_Status.IN_GAME: status = HFO_Status.IN_GAME
state = hfo_env.getState() while status == HFO_Status.IN_GAME:
status = hfo_env.act(get_random_action()) state = hfo_env.getState()
hfo_env.cleanup() if state[5] == 1: #state[5] is 1 when player has the ball
status = hfo_env.act(get_random_action())
else:
status = hfo_env.act((HFO_Actions.MOVE, 0, 0))
except:
pass
finally:
print "Agent " + str(num) + " exiting."
hfo_env.cleanup()
def main(): def main():
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
......
Markdown is supported
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