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,19 +12,26 @@ except:
def get_random_action():
""" Returns a random high-level action """
high_lv_actions = [HFO_Actions.MOVE, HFO_Actions.SHOOT,
HFO_Actions.PASS, HFO_Actions.DRIBBLE]
high_lv_actions = [HFO_Actions.SHOOT, HFO_Actions.PASS, HFO_Actions.DRIBBLE]
return (random.choice(high_lv_actions), 0, 0)
def play_hfo(num):
""" Method called by a thread to play 5 games of HFO """
hfo_env = hfo.HFOEnvironment()
hfo_env.connectToAgentServer(6000 + num, HFO_Features.HIGH_LEVEL_FEATURE_SET)
try:
for episode in xrange(5):
status = HFO_Status.IN_GAME
while status == HFO_Status.IN_GAME:
state = hfo_env.getState()
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():
......
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