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
756b60e5
Commit
756b60e5
authored
Jul 16, 2017
by
drallensmith
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'randomization' into add_preprocess_action - bring in fixes, avoid rebase
parents
34a71542
bdf38152
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
4 deletions
+49
-4
bin/HFO
bin/HFO
+26
-3
example/defense_python_2v3.sh
example/defense_python_2v3.sh
+12
-0
example/hand_coded_defense_agent.py
example/hand_coded_defense_agent.py
+11
-1
No files found.
bin/HFO
View file @
756b60e5
...
...
@@ -2,7 +2,13 @@
# encoding: utf-8
from
__future__
import
print_function
import
subprocess
,
os
,
time
,
numpy
,
sys
import
atexit
import
numpy
import
os
import
time
import
signal
import
subprocess
import
sys
# Global list of all/essential running processes
processes
,
necProcesses
=
[],
[]
...
...
@@ -12,6 +18,16 @@ SERVER_BIN = 'rcssserver'
# Command to run the monitor. Edit as needed; ditto to the above re directories.
MONITOR_BIN
=
'soccerwindow2'
def
cleanup
():
"""Cleanup even if doing SystemExit, as with term."""
for
p
in
reversed
(
processes
):
p
.
terminate
()
time
.
sleep
(
0.1
)
p
.
kill
()
def
term
(
received_signal
,
ignored_stack
):
sys
.
exit
(
"Signal {0!r} received; exiting"
.
format
(
received_signal
))
def
launch
(
cmd
,
name
=
'Unknown'
,
necessary
=
True
,
suppressOutput
=
True
):
"""Launch a process.
...
...
@@ -22,8 +38,8 @@ def launch(cmd, name = 'Unknown', necessary = True, suppressOutput = True):
"""
kwargs
=
{}
if
suppressOutput
:
kwargs
=
{
'stdout'
:
open
(
'/dev/null'
,
'w'
),
'stderr'
:
open
(
'/dev/null'
,
'w'
)}
kwargs
=
{
'stdout'
:
open
(
os
.
devnull
,
'w'
),
'stderr'
:
open
(
os
.
devnull
,
'w'
)}
try
:
p
=
subprocess
.
Popen
(
cmd
.
split
(
' '
),
shell
=
False
,
**
kwargs
)
except
(
IOError
,
OSError
):
...
...
@@ -69,6 +85,13 @@ def main(args):
args
.
min_ball_x
,
args
.
max_ball_x
,
args
.
messageSize
,
args
.
verbose
)
try
:
signal
.
signal
(
signal
.
SIGTERM
,
term
)
except
(
ValueError
,
AttributeError
):
print
(
"Not able to catch sigterm"
)
atexit
.
register
(
cleanup
)
try
:
# Launch the Server
server
=
launch
(
serverCommand
+
serverOptions
,
name
=
'server'
,
...
...
example/defense_python_2v3.sh
0 → 100755
View file @
756b60e5
#!/bin/bash
./bin/HFO
--offense-npcs
=
2
--defense-agents
=
1
--defense-npcs
=
2
--trials
20
--headless
&
sleep
5
./example/hand_coded_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
example/hand_coded_defense_agent.py
View file @
756b60e5
...
...
@@ -221,12 +221,22 @@ def main():
print
(
"Python randomization seed useless without --epsilon >0"
)
if
args
.
epsilon
>
0
:
print
(
"Using epsilon {0:n}"
.
format
(
args
.
epsilon
))
my_unum
=
hfo_env
.
getUnum
()
assert
((
my_unum
>
1
)
and
(
my_unum
<=
11
)),
"Bad unum {!r}"
.
format
(
my_unum
)
print
(
"My unum is {0:d}"
.
format
(
my_unum
))
for
episode
in
itertools
.
count
():
old_ball_pos_x
=
0
old_ball_pos_x
=
-
1
old_ball_pos_y
=
0
episode_start
=
True
status
=
hfo
.
IN_GAME
while
status
==
hfo
.
IN_GAME
:
state
=
hfo_env
.
getState
()
if
episode_start
:
if
(
state
[
3
]
>=
-
1
)
and
(
state
[
3
]
<=
1
):
old_ball_pos_x
=
state
[
3
]
if
(
state
[
4
]
>=
-
1
)
and
(
state
[
4
]
<=
1
):
old_ball_pos_y
=
state
[
4
]
episode_start
=
False
if
(
args
.
epsilon
>
0
)
and
(
random
.
random
()
<
args
.
epsilon
):
do_random_defense_action
(
state
,
hfo_env
)
else
:
...
...
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