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
170bd346
Commit
170bd346
authored
Jul 28, 2017
by
Allen W. Smith, Ph.D
Committed by
GitHub
Jul 28, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1 from LARG/master
Pull from LARG/HFO master - function changes, some cleanup
parents
c966e912
965aea3f
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
17 additions
and
23 deletions
+17
-23
example/high_level_random_agent.py
example/high_level_random_agent.py
+7
-4
example/python_agents_3v3.sh
example/python_agents_3v3.sh
+2
-2
example/python_agents_eps_3v3.sh
example/python_agents_eps_3v3.sh
+2
-2
example/random_python_2v1.sh
example/random_python_2v1.sh
+2
-2
hfo/hfo.py
hfo/hfo.py
+4
-6
hfo/hfo_c_wrapper.h
hfo/hfo_c_wrapper.h
+0
-7
No files found.
example/high_level_random_agent.py
View file @
170bd346
...
@@ -4,6 +4,8 @@
...
@@ -4,6 +4,8 @@
# 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
...
@@ -39,7 +41,7 @@ def main():
...
@@ -39,7 +41,7 @@ def main():
else
:
else
:
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
)
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
:
...
@@ -55,10 +57,11 @@ def main():
...
@@ -55,10 +57,11 @@ def main():
hfo_env
.
act
(
hfo
.
MOVE
)
hfo_env
.
act
(
hfo
.
MOVE
)
# Advance the environment and get the game status
# Advance the environment and get the game status
status
=
hfo_env
.
step
()
status
=
hfo_env
.
step
()
# Check the outcome of the episode
# Check the outcome of the episode
print
((
'Episode
%
d ended with
%
s'
%
(
episode
,
end_status
=
hfo_env
.
statusToString
(
status
)
hfo_env
.
statusToString
(
status
))))
print
(
"Episode {} ended with {}"
.
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 @
170bd346
...
@@ -3,9 +3,9 @@
...
@@ -3,9 +3,9 @@
./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
-x
./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
-x
./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 @
170bd346
...
@@ -3,9 +3,9 @@
...
@@ -3,9 +3,9 @@
./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
--eps
0.2
--numTeammates
=
2
--numOpponents
=
3
--port
6000 &> agent1.txt &
python
-x
./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
-x
./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 @
170bd346
...
@@ -2,9 +2,9 @@
...
@@ -2,9 +2,9 @@
./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
python
2.7
-x
example/high_level_random_agent.py
--port
6000 &> agent1.txt &
python
-x
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
-x
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 @
170bd346
...
@@ -29,6 +29,7 @@ LOW_LEVEL_FEATURE_SET, HIGH_LEVEL_FEATURE_SET = list(range(NUM_FEATURE_SETS))
...
@@ -29,6 +29,7 @@ LOW_LEVEL_FEATURE_SET, HIGH_LEVEL_FEATURE_SET = list(range(NUM_FEATURE_SETS))
NUM_HFO_ACTIONS
=
19
NUM_HFO_ACTIONS
=
19
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
=
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"
]
''' 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
]
...
@@ -149,11 +147,11 @@ class HFOEnvironment(object):
...
@@ -149,11 +147,11 @@ 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 the uniform number of the agent """
...
...
hfo/hfo_c_wrapper.h
View file @
170bd346
...
@@ -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