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
b9f7aa36
Commit
b9f7aa36
authored
Jul 28, 2017
by
drallensmith
Browse files
Options
Browse Files
Download
Plain Diff
Bringing in from upstream/master
parents
d21d0b1e
c54d2350
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
34 additions
and
27 deletions
+34
-27
.travis.yml
.travis.yml
+3
-0
example/high_level_random_agent.py
example/high_level_random_agent.py
+9
-3
example/python_agents_3v3.sh
example/python_agents_3v3.sh
+3
-2
example/python_agents_eps_3v3.sh
example/python_agents_eps_3v3.sh
+5
-3
example/random_python_2v1.sh
example/random_python_2v1.sh
+6
-2
hfo/hfo.py
hfo/hfo.py
+8
-10
hfo/hfo_c_wrapper.h
hfo/hfo_c_wrapper.h
+0
-7
No files found.
.travis.yml
View file @
b9f7aa36
sudo
:
required
sudo
:
required
language
:
cpp
language
:
cpp
dist
:
trusty
dist
:
trusty
branches
:
except
:
-
action_chart
addons
:
addons
:
apt
:
apt
:
sources
:
sources
:
...
...
example/high_level_random_agent.py
View file @
b9f7aa36
...
@@ -5,6 +5,8 @@ from __future__ import print_function
...
@@ -5,6 +5,8 @@ from __future__ import print_function
# Before running this program, first Start HFO server:
# Before running this program, first Start HFO server:
# $> ./bin/HFO --offense-agents 1
# $> ./bin/HFO --offense-agents 1
from
__future__
import
print_function
import
argparse
import
argparse
import
itertools
import
itertools
import
random
import
random
...
@@ -41,8 +43,10 @@ def main():
...
@@ -41,8 +43,10 @@ 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
)
if
args
.
seed
:
if
args
.
seed
:
print
(
"Python randomization seed: {0:d}"
.
format
(
args
.
seed
))
print
(
"Python randomization seed: {0:d}"
.
format
(
args
.
seed
))
for
episode
in
itertools
.
count
():
for
episode
in
itertools
.
count
():
status
=
hfo
.
IN_GAME
status
=
hfo
.
IN_GAME
while
status
==
hfo
.
IN_GAME
:
while
status
==
hfo
.
IN_GAME
:
...
@@ -60,8 +64,10 @@ def main():
...
@@ -60,8 +64,10 @@ def main():
status
=
hfo_env
.
step
()
status
=
hfo_env
.
step
()
# Check the outcome of the episode
# Check the outcome of the episode
print
(
"Episode {0:d} ended with {1:s}"
.
format
(
episode
,
hfo_env
.
statusToString
(
status
)))
end_status
=
hfo_env
.
statusToString
(
status
)
print
(
"Episode {0:n} ended with {1:s}"
.
format
(
episode
,
end_status
))
# Quit if the server goes down
# Quit if the server goes down
if
status
==
hfo
.
SERVER_DOWN
:
if
status
==
hfo
.
SERVER_DOWN
:
hfo_env
.
act
(
hfo
.
QUIT
)
hfo_env
.
act
(
hfo
.
QUIT
)
...
...
example/python_agents_3v3.sh
View file @
b9f7aa36
...
@@ -2,10 +2,11 @@
...
@@ -2,10 +2,11 @@
./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
python
2.7
-x
./example/high_level_custom_agent.py
--port
6000 &> agent1.txt &
python ./example/high_level_custom_agent.py
--port
6000 &> agent1.txt &
sleep
5
sleep
5
python
3
-x
./example/high_level_custom_agent.py
--port
6000 &> agent2.txt &
python ./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
...
...
example/python_agents_eps_3v3.sh
View file @
b9f7aa36
...
@@ -2,10 +2,12 @@
...
@@ -2,10 +2,12 @@
./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
python2.7
-x
./example/high_level_custom_agent.py
--eps
0.2
--numTeammates
=
2
--numOpponents
=
3
--port
6000 &> agent1.txt &
# If wanting to test below with different python versions, add -x to avoid
# the #!/usr/bin/env python initial line.
python ./example/high_level_custom_agent.py
--eps
0.2
--port
6000 &> agent1.txt &
sleep
5
sleep
5
python
3
-x
./example/high_level_custom_agent.py
--eps
0.2
--numTeammates
=
2
--numOpponents
=
3
--port
6000 &> agent2.txt &
python
./example/high_level_custom_agent.py
--eps
0.2
--port
6000 &> agent2.txt &
# The magic line
# The magic line
# $$ holds the PID for this script
# $$ holds the PID for this script
...
...
example/random_python_2v1.sh
View file @
b9f7aa36
...
@@ -2,9 +2,13 @@
...
@@ -2,9 +2,13 @@
./bin/HFO
--offense-agents
=
2
--defense-npcs
=
1
--trials
20
--headless
&
./bin/HFO
--offense-agents
=
2
--defense-npcs
=
1
--trials
20
--headless
&
sleep
5
sleep
5
python2.7
-x
example/high_level_random_agent.py
--port
6000 &> agent1.txt &
# If wanting to test below with different python versions, add -x to avoid
# the #!/usr/bin/env python initial line.
python example/high_level_random_agent.py
--port
6000 &> agent1.txt &
sleep
5
sleep
5
python
3
-x
example/high_level_random_agent.py
--port
6000 &> agent2.txt &
python example/high_level_random_agent.py
--port
6000 &> agent2.txt &
# The magic line
# The magic line
# $$ holds the PID for this script
# $$ holds the PID for this script
...
...
hfo/hfo.py
View file @
b9f7aa36
...
@@ -28,7 +28,8 @@ LOW_LEVEL_FEATURE_SET, HIGH_LEVEL_FEATURE_SET = list(range(NUM_FEATURE_SETS))
...
@@ -28,7 +28,8 @@ LOW_LEVEL_FEATURE_SET, HIGH_LEVEL_FEATURE_SET = list(range(NUM_FEATURE_SETS))
QUIT(): Quit the game '''
QUIT(): Quit the game '''
NUM_HFO_ACTIONS
=
20
NUM_HFO_ACTIONS
=
20
DASH
,
TURN
,
TACKLE
,
KICK
,
KICK_TO
,
MOVE_TO
,
DRIBBLE_TO
,
INTERCEPT
,
\
DASH
,
TURN
,
TACKLE
,
KICK
,
KICK_TO
,
MOVE_TO
,
DRIBBLE_TO
,
INTERCEPT
,
\
MOVE
,
SHOOT
,
PASS
,
DRIBBLE
,
CATCH
,
NOOP
,
QUIT
,
REDUCE_ANGLE_TO_GOAL
,
MARK_PLAYER
,
DEFEND_GOAL
,
GO_TO_BALL
,
REORIENT
=
list
(
range
(
NUM_HFO_ACTIONS
))
MOVE
,
SHOOT
,
PASS
,
DRIBBLE
,
CATCH
,
NOOP
,
QUIT
,
REDUCE_ANGLE_TO_GOAL
,
MARK_PLAYER
,
DEFEND_GOAL
,
GO_TO_BALL
=
list
(
range
(
NUM_HFO_ACTIONS
))
ACTION_STRINGS
=
[
"Dash"
,
"Turn"
,
"Tackle"
,
"Kick"
,
"KickTo"
,
"MoveTo"
,
"DribbleTo"
,
"Intercept"
,
"Move"
,
"Shoot"
,
"Pass"
,
"Dribble"
,
"Catch"
,
"No-op"
,
"Quit"
,
"Reduce_Angle_To_Goal"
,
"Mark_Player"
,
"Defend_Goal"
,
"Go_To_Ball"
,
"Reorient"
]
''' Possible game status
''' Possible game status
[IN_GAME] Game is currently active
[IN_GAME] Game is currently active
...
@@ -40,6 +41,7 @@ DASH, TURN, TACKLE, KICK, KICK_TO, MOVE_TO, DRIBBLE_TO, INTERCEPT, \
...
@@ -40,6 +41,7 @@ DASH, TURN, TACKLE, KICK, KICK_TO, MOVE_TO, DRIBBLE_TO, INTERCEPT, \
'''
'''
NUM_GAME_STATUS_STATES
=
6
NUM_GAME_STATUS_STATES
=
6
IN_GAME
,
GOAL
,
CAPTURED_BY_DEFENSE
,
OUT_OF_BOUNDS
,
OUT_OF_TIME
,
SERVER_DOWN
=
list
(
range
(
NUM_GAME_STATUS_STATES
))
IN_GAME
,
GOAL
,
CAPTURED_BY_DEFENSE
,
OUT_OF_BOUNDS
,
OUT_OF_TIME
,
SERVER_DOWN
=
list
(
range
(
NUM_GAME_STATUS_STATES
))
STATUS_STRINGS
=
[
"InGame"
,
"Goal"
,
"CapturedByDefense"
,
"OutOfBounds"
,
"OutOfTime"
,
"ServerDown"
]
''' Possible sides '''
''' Possible sides '''
RIGHT
,
NEUTRAL
,
LEFT
=
list
(
range
(
-
1
,
2
))
RIGHT
,
NEUTRAL
,
LEFT
=
list
(
range
(
-
1
,
2
))
...
@@ -73,10 +75,6 @@ hfo_lib.step.argtypes = [c_void_p]
...
@@ -73,10 +75,6 @@ hfo_lib.step.argtypes = [c_void_p]
hfo_lib
.
step
.
restype
=
c_int
hfo_lib
.
step
.
restype
=
c_int
hfo_lib
.
numParams
.
argtypes
=
[
c_int
]
hfo_lib
.
numParams
.
argtypes
=
[
c_int
]
hfo_lib
.
numParams
.
restype
=
c_int
hfo_lib
.
numParams
.
restype
=
c_int
hfo_lib
.
actionToString
.
argtypes
=
[
c_int
]
hfo_lib
.
actionToString
.
restype
=
c_char_p
hfo_lib
.
statusToString
.
argtypes
=
[
c_int
]
hfo_lib
.
statusToString
.
restype
=
c_char_p
hfo_lib
.
getUnum
.
argtypes
=
[
c_void_p
]
hfo_lib
.
getUnum
.
argtypes
=
[
c_void_p
]
hfo_lib
.
getUnum
.
restype
=
c_int
hfo_lib
.
getUnum
.
restype
=
c_int
hfo_lib
.
getNumTeammates
.
argtypes
=
[
c_void_p
]
hfo_lib
.
getNumTeammates
.
argtypes
=
[
c_void_p
]
...
@@ -100,7 +98,7 @@ class HFOEnvironment(object):
...
@@ -100,7 +98,7 @@ class HFOEnvironment(object):
play_goalie
=
False
,
play_goalie
=
False
,
record_dir
=
''
):
record_dir
=
''
):
"""
"""
Connect to the server on the specified port. The
Connect
s
to the server on the specified port. The
following information is provided by the ./bin/HFO
following information is provided by the ./bin/HFO
feature_set: High or low level state features
feature_set: High or low level state features
...
@@ -132,7 +130,7 @@ class HFOEnvironment(object):
...
@@ -132,7 +130,7 @@ class HFOEnvironment(object):
hfo_lib
.
act
(
self
.
obj
,
action_type
,
params
.
ctypes
.
data_as
(
POINTER
(
c_float
)))
hfo_lib
.
act
(
self
.
obj
,
action_type
,
params
.
ctypes
.
data_as
(
POINTER
(
c_float
)))
def
say
(
self
,
message
):
def
say
(
self
,
message
):
""" Transmit a message """
""" Transmit
s
a message """
hfo_lib
.
say
(
self
.
obj
,
message
.
encode
(
'utf-8'
))
hfo_lib
.
say
(
self
.
obj
,
message
.
encode
(
'utf-8'
))
def
hear
(
self
):
def
hear
(
self
):
...
@@ -149,14 +147,14 @@ class HFOEnvironment(object):
...
@@ -149,14 +147,14 @@ class HFOEnvironment(object):
def
actionToString
(
self
,
action
):
def
actionToString
(
self
,
action
):
""" Returns a string representation of an action """
""" Returns a string representation of an action """
return
hfo_lib
.
actionToString
(
action
)
.
decode
(
'utf-8'
)
return
ACTION_STRINGS
[
action
]
def
statusToString
(
self
,
status
):
def
statusToString
(
self
,
status
):
""" Returns a string representation of a game status """
""" Returns a string representation of a game status """
return
hfo_lib
.
statusToString
(
status
)
.
decode
(
'utf-8'
)
return
STATUS_STRINGS
[
status
]
def
getUnum
(
self
):
def
getUnum
(
self
):
""" Return the uniform number of the agent """
""" Return
s
the uniform number of the agent """
return
hfo_lib
.
getUnum
(
self
.
obj
)
return
hfo_lib
.
getUnum
(
self
.
obj
)
def
getNumTeammates
(
self
):
def
getNumTeammates
(
self
):
...
...
hfo/hfo_c_wrapper.h
View file @
b9f7aa36
...
@@ -40,13 +40,6 @@ extern "C" {
...
@@ -40,13 +40,6 @@ extern "C" {
hfo
::
status_t
step
(
hfo
::
HFOEnvironment
*
hfo
)
{
return
hfo
->
step
();
}
hfo
::
status_t
step
(
hfo
::
HFOEnvironment
*
hfo
)
{
return
hfo
->
step
();
}
int
numParams
(
const
hfo
::
action_t
action
)
{
return
NumParams
(
action
);
}
int
numParams
(
const
hfo
::
action_t
action
)
{
return
NumParams
(
action
);
}
const
char
*
actionToString
(
const
hfo
::
action_t
action
)
{
return
ActionToString
(
action
).
c_str
();
}
const
char
*
statusToString
(
const
hfo
::
status_t
status
)
{
StatusToString
(
status
);
// TODO: OSX requires two calls...?!
return
StatusToString
(
status
).
c_str
();
}
int
getUnum
(
hfo
::
HFOEnvironment
*
hfo
)
{
return
hfo
->
getUnum
();}
int
getUnum
(
hfo
::
HFOEnvironment
*
hfo
)
{
return
hfo
->
getUnum
();}
int
getNumTeammates
(
hfo
::
HFOEnvironment
*
hfo
)
{
return
hfo
->
getNumTeammates
();}
int
getNumTeammates
(
hfo
::
HFOEnvironment
*
hfo
)
{
return
hfo
->
getNumTeammates
();}
int
getNumOpponents
(
hfo
::
HFOEnvironment
*
hfo
)
{
return
hfo
->
getNumOpponents
();}
int
getNumOpponents
(
hfo
::
HFOEnvironment
*
hfo
)
{
return
hfo
->
getNumOpponents
();}
...
...
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