Commit b06bf087 authored by drallensmith's avatar drallensmith

Added function to high_level_custom_agent.py re teammates

parent 357fe5ce
...@@ -68,8 +68,6 @@ def main(): ...@@ -68,8 +68,6 @@ def main():
help="If doing HFO --record") help="If doing HFO --record")
parser.add_argument('--rdir', type=str, default='log/', parser.add_argument('--rdir', type=str, default='log/',
help="Set directory to use if doing --record") help="Set directory to use if doing --record")
parser.add_argument('--numTeammates', type=int, default=0)
parser.add_argument('--numOpponents', type=int, default=1)
args=parser.parse_args() args=parser.parse_args()
if args.seed: if args.seed:
random.seed(args.seed) random.seed(args.seed)
...@@ -83,12 +81,14 @@ def main(): ...@@ -83,12 +81,14 @@ def main():
hfo_env.connectToServer(hfo.HIGH_LEVEL_FEATURE_SET, hfo_env.connectToServer(hfo.HIGH_LEVEL_FEATURE_SET,
'bin/teams/base/config/formations-dt', args.port, 'bin/teams/base/config/formations-dt', args.port,
'localhost', 'base_left', False) 'localhost', 'base_left', False)
num_teammates = hfo_env.getNumTeammates()
#num_opponents = hfo_env.getNumOpponents()
if args.seed: if args.seed:
if (args.rand_pass and (args.numTeammates > 1)) or (args.epsilon > 0): if (args.rand_pass and (num_teammates > 1)) or (args.epsilon > 0):
print("Python randomization seed: {0:d}".format(args.seed)) print("Python randomization seed: {0:d}".format(args.seed))
else: else:
print("Python randomization seed useless without --rand-pass w/teammates or --epsilon >0") print("Python randomization seed useless without --rand-pass w/2+ teammates or --epsilon >0")
if args.rand_pass and (args.numTeammates > 1): if args.rand_pass and (num_teammates > 1):
print("Randomizing order of checking for a pass") print("Randomizing order of checking for a pass")
if args.epsilon > 0: if args.epsilon > 0:
print("Using epsilon {0:n}".format(args.epsilon)) print("Using epsilon {0:n}".format(args.epsilon))
...@@ -108,7 +108,7 @@ def main(): ...@@ -108,7 +108,7 @@ def main():
hfo_env.act(hfo.DRIBBLE) hfo_env.act(hfo.DRIBBLE)
num_eps += 1 num_eps += 1
else: else:
get_action(state,hfo_env,args.numTeammates,args.rand_pass) get_action(state,hfo_env,num_teammates,args.rand_pass)
num_had_ball += 1 num_had_ball += 1
else: else:
hfo_env.act(hfo.MOVE) hfo_env.act(hfo.MOVE)
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
./bin/HFO --offense-agents=2 --defense-npcs=3 --offense-npcs=1 --trials 20 --headless & ./bin/HFO --offense-agents=2 --defense-npcs=3 --offense-npcs=1 --trials 20 --headless &
sleep 5 sleep 5
# -x is needed to skip first line - otherwise whatever default python version is will run # -x is needed to skip first line - otherwise whatever default python version is will run
python2.7 -x ./example/high_level_custom_agent.py --numTeammates=2 --numOpponents=3 --port 6000 &> agent1.txt & python2.7 -x ./example/high_level_custom_agent.py --port 6000 &> agent1.txt &
sleep 5 sleep 5
python3 -x ./example/high_level_custom_agent.py --numTeammates=2 --numOpponents=3 --port 6000 &> agent2.txt & python3 -x ./example/high_level_custom_agent.py --port 6000 &> agent2.txt &
# The magic line # The magic line
# $$ holds the PID for this script # $$ holds the PID for this script
......
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