<commit_before>#!/usr/bin/env python
# encoding: utf-8

# First Start the server: $> bin/start.py
import random, threading, argparse
try:
  from hfo import *
except:
  print 'Failed to import hfo. To install hfo, in the HFO directory'\
    ' run: \"pip install .\"'
  exit()

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]
  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)
  for episode in xrange(5):
    status = HFO_Status.IN_GAME
    while status == HFO_Status.IN_GAME:
      state = hfo_env.getState()
      status = hfo_env.act(get_random_action())
  hfo_env.cleanup()

def main():
  parser = argparse.ArgumentParser()
  parser.add_argument('num_agents', type=int, help='Number of agents to start. '\<commit_msg>Fixed cleanup in high level random agent<commit_after>#!/usr/bin/env python
# encoding: utf-8

# First Start the server: $> bin/start.py
import random, threading, argparse
try:
  from hfo import *
except:
  print 'Failed to import hfo. To install hfo, in the HFO directory'\
    ' run: \"pip install .\"'
  exit()

def get_random_action():
  """ Returns a random high-level action """
  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():
  parser = argparse.ArgumentParser()
  parser.add_argument('num_agents', type=int, help='Number of agents to start. '\
{'fraction_non_alphanumeric': 0.11906816220880069, 'fraction_numerical': 0.010353753235547885, 'mean_word_length': 3.610337972166998, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2355221', 'n_tokens_mistral': 828, 'n_tokens_neox': 809, 'n_words': 215}