Commit d56ba025 authored by Matthew Hausknecht's avatar Matthew Hausknecht

Added defense agent example.

parent 09fe6e7e
#!/bin/bash
./bin/HFO --offense-npcs=1 --defense-agents=1 --trials 20 --agent-play-goalie --headless &
sleep 5
./example/example_defense_agent.py &> agent1.txt &
sleep 5
# The magic line
# $$ holds the PID for this script
# Negation means kill by process group id instead of PID
trap "kill -TERM -$$" SIGINT
wait
\ No newline at end of file
#!/usr/bin/env python
# encoding: utf-8
# Before running this program, first Start HFO server:
# $> ./bin/HFO --offense-agents 1
import itertools
from hfo import *
def main():
# Create the HFO Environment
hfo = HFOEnvironment()
# Connect to the server with the specified
# feature set. See feature sets in hfo.py/hfo.hpp.
hfo.connectToServer(LOW_LEVEL_FEATURE_SET,
'bin/teams/base/config/formations-dt', 6000,
'localhost', 'base_right', True)
for episode in itertools.count():
status = IN_GAME
while status == IN_GAME:
# Grab the state features from the environment
features = hfo.getState()
# Take an action and get the current game status
hfo.act(DASH, 20.0, 0.)
# Advance the environment and get the game status
status = hfo.step()
# Check the outcome of the episode
print(('Episode %d ended with %s'%(episode, hfo.statusToString(status))))
# Quit if the server goes down
if status == SERVER_DOWN:
hfo.act(QUIT)
break
if __name__ == '__main__':
main()
\ No newline at end of file
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