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
07286e31
Commit
07286e31
authored
Jul 27, 2017
by
Matthew Hausknecht
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated python statusToString and actionToString as well as random_2v1.
parent
b5249d39
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
15 deletions
+13
-15
example/high_level_random_agent.py
example/high_level_random_agent.py
+7
-4
example/random_python_2v1.sh
example/random_python_2v1.sh
+2
-2
hfo/hfo.py
hfo/hfo.py
+4
-2
hfo/hfo_c_wrapper.h
hfo/hfo_c_wrapper.h
+0
-7
No files found.
example/high_level_random_agent.py
View file @
07286e31
...
...
@@ -4,6 +4,8 @@
# Before running this program, first Start HFO server:
# $> ./bin/HFO --offense-agents 1
from
__future__
import
print_function
import
argparse
import
itertools
import
random
...
...
@@ -57,8 +59,9 @@ def main():
status
=
hfo_env
.
step
()
# Check the outcome of the episode
print
((
'Episode
%
d ended with
%
s'
%
(
episode
,
hfo_env
.
statusToString
(
status
))))
end_status
=
hfo_env
.
statusToString
(
status
)
print
(
"Episode {} ended with {}"
.
format
(
episode
,
end_status
))
# Quit if the server goes down
if
status
==
hfo
.
SERVER_DOWN
:
hfo_env
.
act
(
hfo
.
QUIT
)
...
...
example/random_python_2v1.sh
View file @
07286e31
...
...
@@ -2,9 +2,9 @@
./bin/HFO
--offense-agents
=
2
--defense-npcs
=
1
--trials
20
--headless
&
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
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
# $$ holds the PID for this script
...
...
hfo/hfo.py
View file @
07286e31
...
...
@@ -29,6 +29,7 @@ LOW_LEVEL_FEATURE_SET, HIGH_LEVEL_FEATURE_SET = list(range(NUM_FEATURE_SETS))
NUM_HFO_ACTIONS
=
19
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
))
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
[IN_GAME] Game is currently active
...
...
@@ -40,6 +41,7 @@ DASH, TURN, TACKLE, KICK, KICK_TO, MOVE_TO, DRIBBLE_TO, INTERCEPT, \
'''
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
))
STATUS_STRINGS
=
[
"InGame"
,
"Goal"
,
"CapturedByDefense"
,
"OutOfBounds"
,
"OutOfTime"
,
"ServerDown"
]
''' Possible sides '''
RIGHT
,
NEUTRAL
,
LEFT
=
list
(
range
(
-
1
,
2
))
...
...
@@ -149,11 +151,11 @@ class HFOEnvironment(object):
def
actionToString
(
self
,
action
):
""" Returns a string representation of an action """
return
hfo_lib
.
actionToString
(
action
)
.
decode
(
'utf-8'
)
return
ACTION_STRINGS
(
action
)
def
statusToString
(
self
,
status
):
""" Returns a string representation of a game status """
return
hfo_lib
.
statusToString
(
status
)
.
decode
(
'utf-8'
)
return
STATUS_STRINGS
[
status
]
def
getUnum
(
self
):
""" Return the uniform number of the agent """
...
...
hfo/hfo_c_wrapper.h
View file @
07286e31
...
...
@@ -40,13 +40,6 @@ extern "C" {
hfo
::
status_t
step
(
hfo
::
HFOEnvironment
*
hfo
)
{
return
hfo
->
step
();
}
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
getNumTeammates
(
hfo
::
HFOEnvironment
*
hfo
)
{
return
hfo
->
getNumTeammates
();}
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