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
7d9f7e09
Commit
7d9f7e09
authored
Aug 12, 2017
by
drallensmith
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Last_action_status as a boolean state variable
parent
59c57e88
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
31 additions
and
45 deletions
+31
-45
doc/manual.pdf
doc/manual.pdf
+0
-0
doc/manual.tex
doc/manual.tex
+8
-0
hfo/hfo.py
hfo/hfo.py
+0
-11
hfo/hfo_c_wrapper.h
hfo/hfo_c_wrapper.h
+0
-3
src/agent.cpp
src/agent.cpp
+3
-2
src/bhv_basic_move.cpp
src/bhv_basic_move.cpp
+1
-1
src/common.hpp
src/common.hpp
+0
-16
src/feature_extractor.h
src/feature_extractor.h
+4
-1
src/highlevel_feature_extractor.cpp
src/highlevel_feature_extractor.cpp
+6
-5
src/highlevel_feature_extractor.h
src/highlevel_feature_extractor.h
+2
-1
src/lowlevel_feature_extractor.cpp
src/lowlevel_feature_extractor.cpp
+4
-3
src/lowlevel_feature_extractor.h
src/lowlevel_feature_extractor.h
+2
-1
src/sample_player.cpp
src/sample_player.cpp
+1
-1
No files found.
doc/manual.pdf
View file @
7d9f7e09
No preview for this file type
doc/manual.tex
View file @
7d9f7e09
...
...
@@ -324,6 +324,10 @@ features.
\item
[
$
3
O
$
]
{
\textbf
{
X, Y, and Uniform Number of
Opponents
}
- For each opponent: the x-position, y-position and
uniform number of that opponent.
}
\item
{
\textbf
{
Last
\_
Action
\_
Success
\_
Possible
}
- Whether there is any chance
the last action taken was successful, either in accomplishing the
usual intent of the action or in some other way such as getting out of
a goal-collision state. 1 for yes, -1 for no.
}
\end{enumerate}
\begin{figure}
[htp]
...
...
@@ -518,6 +522,10 @@ low-level features:
sorted by proximity to the agent.
}
\item
[
$
O
$
]
{
\textbf
{
Opponent Uniform Nums
}
[Unum] One uniform number for each opponent active in HFO,
sorted by proximity to the player.
}
\item
{
\textbf
{
Last
\_
Action
\_
Success
\_
Possible
}
[Boolean] Whether there is any chance
the last action taken was successful, either in accomplishing the
usual intent of the action or in some other way such as getting out of
a goal-collision state.
}
\end{enumerate}
\section
{
Action Space
}
...
...
hfo/hfo.py
View file @
7d9f7e09
...
...
@@ -69,13 +69,6 @@ STATUS_STRINGS = {IN_GAME: "InGame",
OUT_OF_TIME
:
"OutOfTime"
,
SERVER_DOWN
:
"ServerDown"
}
"""Possible action result statuses."""
ACTION_STATUS_UNKNOWN
,
ACTION_STATUS_BAD
,
ACTION_STATUS_MAYBE
=
list
(
range
(
-
1
,
2
))
ACTION_STATUS_MAYBE_OK
=
ACTION_STATUS_MAYBE
# typos
ACTION_STATUS_STRINGS
=
{
ACTION_STATUS_UNKNOWN
:
"Unknown"
,
ACTION_STATUS_BAD
:
"Bad"
,
ACTION_STATUS_MAYBE
:
"MaybeOK"
}
"""Possible sides."""
RIGHT
,
NEUTRAL
,
LEFT
=
list
(
range
(
-
1
,
2
))
...
...
@@ -204,7 +197,3 @@ class HFOEnvironment(object):
def
getNumOpponents
(
self
):
""" Returns the number of opponents of the agent """
return
hfo_lib
.
getNumOpponents
(
self
.
obj
)
def
actionStatusToString
(
self
,
status
):
"""Returns a string representation of an action status."""
return
ACTION_STATUS_STRINGS
[
status
]
hfo/hfo_c_wrapper.h
View file @
7d9f7e09
...
...
@@ -43,9 +43,6 @@ extern "C" {
int
getUnum
(
hfo
::
HFOEnvironment
*
hfo
)
{
return
hfo
->
getUnum
();}
int
getNumTeammates
(
hfo
::
HFOEnvironment
*
hfo
)
{
return
hfo
->
getNumTeammates
();}
int
getNumOpponents
(
hfo
::
HFOEnvironment
*
hfo
)
{
return
hfo
->
getNumOpponents
();}
int
getLastActionStatus
(
hfo
::
HFOEnvironment
*
hfo
,
hfo
::
action_t
last_action
)
{
return
hfo
->
getLastActionStatus
(
last_action
);
}
}
#endif
src/agent.cpp
View file @
7d9f7e09
...
...
@@ -398,7 +398,8 @@ void
Agent
::
UpdateFeatures
()
{
if
(
feature_extractor
!=
NULL
)
{
state
=
feature_extractor
->
ExtractFeatures
(
this
->
world
());
state
=
feature_extractor
->
ExtractFeatures
(
this
->
world
(),
getLastActionStatus
());
}
}
...
...
@@ -1093,7 +1094,7 @@ bool Agent::doDefendGoal() {
Vector2D
goal_pos2
(
-
ServerParam
::
i
().
pitchHalfLength
()
+
ServerParam
::
i
().
goalAreaLength
(),
-
ServerParam
::
i
().
goalHalfWidth
()
);
const
BallObject
&
ball
=
wm
.
ball
();
if
(
!
ball
.
rposValid
())
{
return
ACTION_STATUS_BAD
;
return
false
;
}
Vector2D
ball_pos
=
ball
.
pos
();
...
...
src/bhv_basic_move.cpp
View file @
7d9f7e09
...
...
@@ -57,7 +57,7 @@ using namespace rcsc;
*/
bool
Bhv_BasicMove
::
action_
execute
(
PlayerAgent
*
agent
)
Bhv_BasicMove
::
execute
(
PlayerAgent
*
agent
)
{
dlog
.
addText
(
Logger
::
TEAM
,
__FILE__
": Bhv_BasicMove"
);
...
...
src/common.hpp
View file @
7d9f7e09
...
...
@@ -198,22 +198,6 @@ inline std::string StatusToString(status_t status) {
}
};
/**
* Returns a string representation of an action status.
*/
inline
std
::
string
ActionStatusToString
(
action_status_t
status
)
{
switch
(
status
)
{
case
ACTION_STATUS_BAD
:
return
"Bad"
;
case
ACTION_STATUS_MAYBE
:
return
"MaybeOK"
;
case
ACTION_STATUS_UNKNOWN
:
return
"Unknown"
;
default:
return
"Invalid"
;
}
}
/**
* Parse a Trainer message to populate config. Returns a bool
* indicating if the struct was correctly parsed.
...
...
src/feature_extractor.h
View file @
7d9f7e09
...
...
@@ -6,6 +6,8 @@
#include <rcsc/player/player_agent.h>
#include <vector>
class
Agent
;
typedef
std
::
pair
<
float
,
float
>
OpenAngle
;
class
FeatureExtractor
{
...
...
@@ -14,7 +16,8 @@ public:
virtual
~
FeatureExtractor
();
// Updated the state features stored in feature_vec
virtual
const
std
::
vector
<
float
>&
ExtractFeatures
(
const
rcsc
::
WorldModel
&
wm
)
=
0
;
virtual
const
std
::
vector
<
float
>&
ExtractFeatures
(
const
rcsc
::
WorldModel
&
wm
,
bool
last_action_status
)
=
0
;
// Record the current state
void
LogFeatures
();
...
...
src/highlevel_feature_extractor.cpp
View file @
7d9f7e09
...
...
@@ -11,7 +11,7 @@ using namespace rcsc;
HighLevelFeatureExtractor
::
HighLevelFeatureExtractor
(
int
num_teammates
,
int
num_opponents
,
bool
playing_offense
)
:
FeatureExtractor
(
num_teammates
,
num_opponents
,
playing_offense
)
FeatureExtractor
(
num_teammates
,
num_opponents
,
playing_offense
)
{
assert
(
numTeammates
>=
0
);
assert
(
numOpponents
>=
0
);
...
...
@@ -23,8 +23,9 @@ HighLevelFeatureExtractor::HighLevelFeatureExtractor(int num_teammates,
HighLevelFeatureExtractor
::~
HighLevelFeatureExtractor
()
{}
const
std
::
vector
<
float
>&
HighLevelFeatureExtractor
::
ExtractFeatures
(
const
WorldModel
&
wm
)
{
const
std
::
vector
<
float
>&
HighLevelFeatureExtractor
::
ExtractFeatures
(
const
rcsc
::
WorldModel
&
wm
,
bool
last_action_status
)
{
featIndx
=
0
;
const
ServerParam
&
SP
=
ServerParam
::
i
();
const
SelfObject
&
self
=
wm
.
self
();
...
...
@@ -37,7 +38,7 @@ const std::vector<float>& HighLevelFeatureExtractor::ExtractFeatures(
// features about self pos
// Allow the agent to go 10% over the playfield in any direction
float
tolerance_x
=
.1
*
SP
.
pitchHalfLength
();
float
tolerance_y
=
.1
*
SP
.
pitchHalfWidth
();
float
tolerance_y
=
.1
*
SP
.
pitchHalfWidth
();
// should this be SP.pitchWidth()?
// Feature[0]: X-postion
if
(
playingOffense
)
{
addNormFeature
(
self_pos
.
x
,
-
tolerance_x
,
SP
.
pitchHalfLength
()
+
tolerance_x
);
...
...
@@ -180,7 +181,7 @@ const std::vector<float>& HighLevelFeatureExtractor::ExtractFeatures(
addFeature
(
FEAT_INVALID
);
}
if
(
getLastActionStatus
()
)
{
if
(
last_action_status
)
{
addFeature
(
FEAT_MAX
);
}
else
{
addFeature
(
FEAT_MIN
);
...
...
src/highlevel_feature_extractor.h
View file @
7d9f7e09
...
...
@@ -20,7 +20,8 @@ public:
virtual
~
HighLevelFeatureExtractor
();
// Updated the state features stored in feature_vec
virtual
const
std
::
vector
<
float
>&
ExtractFeatures
(
const
rcsc
::
WorldModel
&
wm
);
virtual
const
std
::
vector
<
float
>&
ExtractFeatures
(
const
rcsc
::
WorldModel
&
wm
,
bool
last_action_status
);
protected:
// Number of features for non-player objects.
...
...
src/lowlevel_feature_extractor.cpp
View file @
7d9f7e09
...
...
@@ -24,8 +24,9 @@ LowLevelFeatureExtractor::LowLevelFeatureExtractor(int num_teammates,
LowLevelFeatureExtractor
::~
LowLevelFeatureExtractor
()
{}
const
std
::
vector
<
float
>&
LowLevelFeatureExtractor
::
ExtractFeatures
(
const
WorldModel
&
wm
)
{
const
std
::
vector
<
float
>&
LowLevelFeatureExtractor
::
ExtractFeatures
(
const
rcsc
::
WorldModel
&
wm
,
bool
last_action_status
)
{
featIndx
=
0
;
const
ServerParam
&
SP
=
ServerParam
::
i
();
// ======================== SELF FEATURES ======================== //
...
...
@@ -219,7 +220,7 @@ const std::vector<float>& LowLevelFeatureExtractor::ExtractFeatures(
addFeature
(
FEAT_MIN
);
}
if
(
getLastActionStatus
()
)
{
if
(
last_action_status
)
{
addFeature
(
FEAT_MAX
);
}
else
{
addFeature
(
FEAT_MIN
);
...
...
src/lowlevel_feature_extractor.h
View file @
7d9f7e09
...
...
@@ -14,7 +14,8 @@ public:
virtual
~
LowLevelFeatureExtractor
();
// Updated the state features stored in feature_vec
virtual
const
std
::
vector
<
float
>&
ExtractFeatures
(
const
rcsc
::
WorldModel
&
wm
);
virtual
const
std
::
vector
<
float
>&
ExtractFeatures
(
const
rcsc
::
WorldModel
&
wm
,
bool
last_action_status
);
protected:
// Number of features for non-player objects.
...
...
src/sample_player.cpp
View file @
7d9f7e09
...
...
@@ -257,7 +257,7 @@ SamplePlayer::actionImpl()
lastTrainerMessageTime
=
audioSensor
().
trainerMessageTime
().
cycle
();
}
if
(
feature_extractor
!=
NULL
)
{
feature_extractor
->
ExtractFeatures
(
this
->
world
());
feature_extractor
->
ExtractFeatures
(
this
->
world
()
,
true
);
feature_extractor
->
LogFeatures
();
}
}
...
...
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