Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
Seminar-HFO
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shashank Suhas
Seminar-HFO
Commits
86cf7950
Commit
86cf7950
authored
Jun 12, 2015
by
Matthew Hausknecht
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored arguments and support for multiple agents.
parent
70a2b0ed
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
113 additions
and
103 deletions
+113
-103
bin/Trainer.py
bin/Trainer.py
+92
-79
bin/start.py
bin/start.py
+21
-24
No files found.
bin/Trainer.py
View file @
86cf7950
This diff is collapsed.
Click to expand it.
bin/start.py
View file @
86cf7950
...
@@ -45,10 +45,11 @@ def main(args, team1='left', team2='right', rng=numpy.random.RandomState()):
...
@@ -45,10 +45,11 @@ def main(args, team1='left', team2='right', rng=numpy.random.RandomState()):
"""
"""
if
not
os
.
path
.
exists
(
args
.
logDir
):
if
not
os
.
path
.
exists
(
args
.
logDir
):
os
.
makedirs
(
args
.
logDir
)
os
.
makedirs
(
args
.
logDir
)
num_agents
=
args
.
offenseAgents
+
args
.
defenseAgents
binary_dir
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
binary_dir
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
server_port
=
args
.
port
+
1
server_port
=
args
.
port
+
num_agents
coach_port
=
args
.
port
+
2
coach_port
=
args
.
port
+
num_agents
+
1
olcoach_port
=
args
.
port
+
3
olcoach_port
=
args
.
port
+
num_agents
+
2
serverOptions
=
' server::port=
%
i server::coach_port=
%
i '
\
serverOptions
=
' server::port=
%
i server::coach_port=
%
i '
\
'server::olcoach_port=
%
i server::coach=1 '
\
'server::olcoach_port=
%
i server::coach=1 '
\
'server::game_logging=
%
i server::text_logging=
%
i '
\
'server::game_logging=
%
i server::text_logging=
%
i '
\
...
@@ -76,7 +77,8 @@ def main(args, team1='left', team2='right', rng=numpy.random.RandomState()):
...
@@ -76,7 +77,8 @@ def main(args, team1='left', team2='right', rng=numpy.random.RandomState()):
launch
(
MONITOR_CMD
+
monitorOptions
,
name
=
'monitor'
)
launch
(
MONITOR_CMD
+
monitorOptions
,
name
=
'monitor'
)
# Launch the Trainer
# Launch the Trainer
from
Trainer
import
Trainer
from
Trainer
import
Trainer
trainer
=
Trainer
(
args
=
args
,
rng
=
rng
)
trainer
=
Trainer
(
args
=
args
,
rng
=
rng
,
server_port
=
server_port
,
coach_port
=
coach_port
)
trainer
.
initComm
()
trainer
.
initComm
()
# Start Team1
# Start Team1
launch
(
team1Cmd
,
False
)
launch
(
team1Cmd
,
False
)
...
@@ -109,15 +111,17 @@ def parseArgs():
...
@@ -109,15 +111,17 @@ def parseArgs():
help
=
'Number of trials to run'
)
help
=
'Number of trials to run'
)
p
.
add_argument
(
'--frames'
,
dest
=
'numFrames'
,
type
=
int
,
default
=-
1
,
p
.
add_argument
(
'--frames'
,
dest
=
'numFrames'
,
type
=
int
,
default
=-
1
,
help
=
'Number of frames to run for'
)
help
=
'Number of frames to run for'
)
p
.
add_argument
(
'--offense'
,
dest
=
'numOffense'
,
type
=
int
,
default
=
4
,
p
.
add_argument
(
'--frames-per-trial'
,
dest
=
'maxFramesPerTrial'
,
type
=
int
,
help
=
'Number of offensive players'
)
default
=
1000
,
help
=
'Max number of frames per trial. '
\
p
.
add_argument
(
'--defense'
,
dest
=
'numDefense'
,
type
=
int
,
default
=
4
,
'Negative values mean unlimited.'
)
help
=
'Number of defensive players'
)
p
.
add_argument
(
'--offense-agents'
,
dest
=
'offenseAgents'
,
type
=
int
,
default
=
1
,
p
.
add_argument
(
'--play-defense'
,
dest
=
'play_offense'
,
help
=
'Number of offensive agents'
)
action
=
'store_false'
,
default
=
True
,
p
.
add_argument
(
'--defense-agents'
,
dest
=
'defenseAgents'
,
type
=
int
,
default
=
0
,
help
=
'Put the learning agent on defensive team'
)
help
=
'Number of defensive agents'
)
p
.
add_argument
(
'--no-agent'
,
dest
=
'no_agent'
,
action
=
'store_true'
,
p
.
add_argument
(
'--offense-npcs'
,
dest
=
'offenseNPCs'
,
type
=
int
,
default
=
0
,
help
=
'Don
\'
t use a learning agent.'
)
help
=
'Number of offensive uncontrolled players'
)
p
.
add_argument
(
'--defense-npcs'
,
dest
=
'defenseNPCs'
,
type
=
int
,
default
=
0
,
help
=
'Number of defensive uncontrolled players'
)
p
.
add_argument
(
'--no-sync'
,
dest
=
'sync'
,
action
=
'store_false'
,
default
=
True
,
p
.
add_argument
(
'--no-sync'
,
dest
=
'sync'
,
action
=
'store_false'
,
default
=
True
,
help
=
'Run server in non-sync mode'
)
help
=
'Run server in non-sync mode'
)
p
.
add_argument
(
'--port'
,
dest
=
'port'
,
type
=
int
,
default
=
6000
,
p
.
add_argument
(
'--port'
,
dest
=
'port'
,
type
=
int
,
default
=
6000
,
...
@@ -134,17 +138,10 @@ def parseArgs():
...
@@ -134,17 +138,10 @@ def parseArgs():
p
.
add_argument
(
'--fullstate'
,
dest
=
'fullstate'
,
action
=
'store_true'
,
p
.
add_argument
(
'--fullstate'
,
dest
=
'fullstate'
,
action
=
'store_true'
,
help
=
'Server provides full-state information to agents.'
)
help
=
'Server provides full-state information to agents.'
)
args
=
p
.
parse_args
()
args
=
p
.
parse_args
()
if
args
.
numOffense
not
in
xrange
(
1
,
11
):
assert
args
.
offenseAgents
+
args
.
offenseNPCs
in
xrange
(
0
,
11
),
\
p
.
error
(
'argument --offense: invalid choice: '
+
str
(
args
.
numOffense
)
+
'Invalid number of offensive players: (choose from [0,10])'
' (choose from [1-10])'
)
assert
args
.
defenseAgents
+
args
.
defenseNPCs
in
xrange
(
0
,
12
),
\
if
args
.
play_offense
:
'Invalid number of defensive players: (choose from [0,11])'
if
args
.
numDefense
not
in
xrange
(
0
,
12
):
p
.
error
(
'argument --defense: invalid choice: '
+
str
(
args
.
numDefense
)
+
' (choose from [0-11])'
)
else
:
if
args
.
numDefense
not
in
xrange
(
1
,
12
):
p
.
error
(
'argument --defense: invalid choice: '
+
str
(
args
.
numDefense
)
+
' (choose from [1-11])'
)
return
args
return
args
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment