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
81feb436
You need to sign in or sign up before continuing.
Commit
81feb436
authored
Oct 21, 2015
by
Matthew Hausknecht
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Experimenting with new disconnect.
parent
71946c3f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
29 deletions
+10
-29
bin/HFO
bin/HFO
+5
-8
bin/Trainer.py
bin/Trainer.py
+5
-21
No files found.
bin/HFO
View file @
81feb436
...
@@ -28,12 +28,9 @@ def launch(cmd, name = 'Unknown', necessary = True, supressOutput = True):
...
@@ -28,12 +28,9 @@ def launch(cmd, name = 'Unknown', necessary = True, supressOutput = True):
necProcesses
.
append
([
p
,
name
])
necProcesses
.
append
([
p
,
name
])
return
p
return
p
def
main
(
args
,
team1
=
'left'
,
team2
=
'right'
,
rng
=
numpy
.
random
.
RandomState
()
):
def
main
(
args
,
team1
=
'left'
,
team2
=
'right'
):
"""Sets up the teams, launches the server and monitor, starts the trainer.
"""Sets up the teams, launches the server and monitor, starts the trainer.
"""
"""
if
args
.
seed
:
print
'[start.py] Seeding RNG with seed: '
,
args
.
seed
rng
.
seed
(
args
.
seed
)
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
num_agents
=
args
.
offenseAgents
+
args
.
defenseAgents
...
@@ -51,17 +48,17 @@ def main(args, team1='left', team2='right', rng=numpy.random.RandomState()):
...
@@ -51,17 +48,17 @@ def main(args, team1='left', team2='right', rng=numpy.random.RandomState()):
'server::fullstate_l=
%
i server::fullstate_r=
%
i '
\
'server::fullstate_l=
%
i server::fullstate_r=
%
i '
\
'server::coach_w_referee=1 server::hfo_max_trial_time=
%
i '
\
'server::coach_w_referee=1 server::hfo_max_trial_time=
%
i '
\
'server::hfo_max_trials=
%
i server::hfo_max_frames=
%
i '
\
'server::hfo_max_trials=
%
i server::hfo_max_frames=
%
i '
\
'server::hfo_offense_on_ball=
%
i'
\
'server::hfo_offense_on_ball=
%
i
server::random_seed=
%
i
'
\
%
(
server_port
,
coach_port
,
olcoach_port
,
%
(
server_port
,
coach_port
,
olcoach_port
,
args
.
logging
,
args
.
logging
,
args
.
logging
,
args
.
logging
,
args
.
logging
,
args
.
logging
,
args
.
logDir
,
args
.
logDir
,
args
.
logDir
,
args
.
logDir
,
args
.
logDir
,
args
.
logDir
,
args
.
sync
,
args
.
fullstate
,
args
.
fullstate
,
args
.
sync
,
args
.
fullstate
,
args
.
fullstate
,
args
.
maxFramesPerTrial
,
args
.
numTrials
,
args
.
numFrames
,
args
.
maxFramesPerTrial
,
args
.
numTrials
,
args
.
numFrames
,
args
.
offenseOnBall
)
args
.
offenseOnBall
,
args
.
seed
)
# server::record_messages=on -- useful for debug
# server::record_messages=on -- useful for debug
try
:
try
:
# Launch the Server
# Launch the Server
server
=
launch
(
serverCommand
+
serverOptions
,
name
=
'server'
)
server
=
launch
(
serverCommand
+
serverOptions
,
name
=
'server'
,
supressOutput
=
True
)
time
.
sleep
(
0.2
)
time
.
sleep
(
0.2
)
assert
server
.
poll
()
is
None
,
\
assert
server
.
poll
()
is
None
,
\
'[start.py] Failed to launch Server with command:
\"
%
s
\"
'
\
'[start.py] Failed to launch Server with command:
\"
%
s
\"
'
\
...
@@ -128,7 +125,7 @@ def parseArgs():
...
@@ -128,7 +125,7 @@ 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.'
)
p
.
add_argument
(
'--seed'
,
dest
=
'seed'
,
type
=
int
,
p
.
add_argument
(
'--seed'
,
dest
=
'seed'
,
type
=
int
,
help
=
'Seed the
train
er
\'
s RNG. Default: time.'
)
help
=
'Seed the
serv
er
\'
s RNG. Default: time.'
)
args
=
p
.
parse_args
()
args
=
p
.
parse_args
()
if
args
.
offenseAgents
not
in
xrange
(
0
,
11
):
if
args
.
offenseAgents
not
in
xrange
(
0
,
11
):
p
.
error
(
'argument --offense-agents: invalid choice: '
\
p
.
error
(
'argument --offense-agents: invalid choice: '
\
...
...
bin/Trainer.py
View file @
81feb436
...
@@ -349,34 +349,18 @@ class Trainer(object):
...
@@ -349,34 +349,18 @@ class Trainer(object):
def
disconnectPlayer
(
self
,
player
,
player_num
,
on_offense
):
def
disconnectPlayer
(
self
,
player
,
player_num
,
on_offense
):
"""Wait on a launched player to disconnect from the server. """
"""Wait on a launched player to disconnect from the server. """
print
'Disconnect
%
s-
%
d'
%
(
self
.
_offenseTeamName
if
on_offense
# print 'Disconnect %s-%d'%(self._offenseTeamName if on_offense
else
self
.
_defenseTeamName
,
player_num
)
# else self._defenseTeamName, player_num)
player
.
terminate
()
time
.
sleep
(
0.1
)
player
.
kill
()
player
.
wait
()
self
.
send
(
'(look)'
)
partial
=
[
'ok'
,
'look'
]
self
.
_numPlayers
=
0
def
f
(
body
):
del
self
.
_connectedPlayers
[:]
for
i
in
xrange
(
4
,
len
(
body
)):
_
,
team
,
num
=
body
[
i
][
0
][:
3
]
if
(
team
,
num
)
not
in
self
.
_connectedPlayers
:
self
.
_connectedPlayers
.
append
((
team
,
num
))
self
.
registerMsgHandler
(
f
,
*
partial
,
quiet
=
True
)
team_name
=
self
.
_offenseTeamName
if
on_offense
else
self
.
_defenseTeamName
team_name
=
self
.
_offenseTeamName
if
on_offense
else
self
.
_defenseTeamName
while
(
team_name
,
str
(
player_num
))
in
self
.
_connectedPlayers
:
self
.
send
(
'(disconnect_player
%
s
%
d)'
%
(
team_name
,
player_num
))
self
.
listenAndProcess
()
player
.
kill
()
self
.
send
(
'(look)'
)
self
.
ignoreMsg
(
*
partial
,
quiet
=
True
)
def
waitOnPlayer
(
self
,
player_num
,
on_offense
):
def
waitOnPlayer
(
self
,
player_num
,
on_offense
):
"""Wait on a launched player to connect and be reported by the
"""Wait on a launched player to connect and be reported by the
server.
server.
"""
"""
time
.
sleep
(
0.1
)
#
time.sleep(0.1)
self
.
send
(
'(look)'
)
self
.
send
(
'(look)'
)
partial
=
[
'ok'
,
'look'
]
partial
=
[
'ok'
,
'look'
]
self
.
_numPlayers
=
0
self
.
_numPlayers
=
0
...
...
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