Commit 1b71c1e8 authored by Matthew Hausknecht's avatar Matthew Hausknecht

Added flag to toggle if defense agent plays goalie or defender.

parent 963eef65
......@@ -123,6 +123,8 @@ def parseArgs():
help='Number of offensive uncontrolled players. Default: 0.')
p.add_argument('--defense-npcs', dest='defenseNPCs', type=int, default=0,
help='Number of defensive uncontrolled players. Default: 0.')
p.add_argument('--agent-play-goalie', dest='agentPlayGoalie', action='store_true',
default=False, help='Defense-agent plays goalie, rather than defender.')
p.add_argument('--offense-team', dest='offenseTeam', type=str, default='base',
help='Offense team binary. Options: '+str(installed_teams)+'. Default: base.')
p.add_argument('--defense-team', dest='defenseTeam', type=str, default='base',
......@@ -182,6 +184,8 @@ def parseArgs():
p.error('Unrecognized offense team: ' + str(args.offenseTeam))
if args.defenseTeam not in installed_teams:
p.error('Unrecognized defense team: ' + str(args.defenseTeam))
if args.agentPlayGoalie and args.defenseAgents <= 0:
p.error('You must add a --defense-agent before it can play goalie.')
return args
if __name__ == '__main__':
......
......@@ -36,6 +36,7 @@ class Trainer(object):
self._numAgents = args.offenseAgents + args.defenseAgents
self._offenseAgents = args.offenseAgents
self._defenseAgents = args.defenseAgents
self._agentPlayGoalie = args.agentPlayGoalie
self._agentReady = set([]) # Unums of ready agents
self._agentTeams = [] # Names of the teams the agents are playing for
self._agentNumInt = [] # List of agents internal team numbers
......@@ -383,8 +384,10 @@ class Trainer(object):
(offenseTeam, defenseTeam) = self.getTeams(offense_team_name, defense_team_name)
offense_unums = self._offenseOrder[1: self._numOffense + 1]
sorted_offense_agent_unums = sorted(self._offenseOrder[1:self._offenseAgents+1])
defense_unums = self._defenseOrder[: self._numDefense]
sorted_defense_agent_unums = sorted(self._defenseOrder[:self._defenseAgents])
defense_unums = sorted(self._defenseOrder[: self._numDefense])
sorted_defense_agent_unums = \
defense_unums[:self._defenseAgents] if self._agentPlayGoalie \
else defense_unums[-self._defenseAgents:]
# Launch offense
agent_num = 0
......
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