hfo_example_agent.py 843 Bytes
Newer Older
1 2 3
#!/usr/bin/env python
# encoding: utf-8

4 5 6 7
# Before running this program, first Start HFO server:
# $> ./bin/HFO --offense-agents 1

from hfo import *
sanmit's avatar
sanmit committed
8

9 10
if __name__ == '__main__':
  # Create the HFO Environment
11 12
  hfo = HFOEnvironment()
  # Connect to the server with the specified
13
  # feature set. See feature sets in hfo.py/hfo.hpp.
14
  hfo.connectToServer(LOW_LEVEL_FEATURE_SET,
15
                      'bin/teams/base/config/formations-dt', 6000,
16 17 18 19
                      'localhost', 'base_left', False)
  for episode in xrange(10):
    status = IN_GAME
    while status == IN_GAME:
20 21
      # Grab the state features from the environment
      features = hfo.getState()
22
      # Take an action and get the current game status
23
      hfo.act(DASH, 20.0, 0)
24
      status = hfo.step()
25
    print 'Episode', episode, 'ended with', hfo.statusToString(status)