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
59c57e88
Commit
59c57e88
authored
Aug 11, 2017
by
drallensmith
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Try at putting action_status into state vector
parent
5df1cd17
Changes
13
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
121 additions
and
179 deletions
+121
-179
hfo/hfo.py
hfo/hfo.py
+0
-12
src/HFO.cpp
src/HFO.cpp
+0
-4
src/HFO.hpp
src/HFO.hpp
+0
-2
src/agent.cpp
src/agent.cpp
+72
-107
src/agent.h
src/agent.h
+14
-15
src/bhv_basic_move.cpp
src/bhv_basic_move.cpp
+11
-18
src/bhv_basic_move.h
src/bhv_basic_move.h
+0
-1
src/common.hpp
src/common.hpp
+0
-18
src/feature_extractor.h
src/feature_extractor.h
+2
-0
src/highlevel_feature_extractor.cpp
src/highlevel_feature_extractor.cpp
+8
-0
src/highlevel_feature_extractor.h
src/highlevel_feature_extractor.h
+2
-0
src/lowlevel_feature_extractor.cpp
src/lowlevel_feature_extractor.cpp
+10
-2
src/lowlevel_feature_extractor.h
src/lowlevel_feature_extractor.h
+2
-0
No files found.
hfo/hfo.py
View file @
59c57e88
...
...
@@ -114,8 +114,6 @@ hfo_lib.getNumTeammates.argtypes = [c_void_p]
hfo_lib
.
getNumTeammates
.
restype
=
c_int
hfo_lib
.
getNumOpponents
.
argtypes
=
[
c_void_p
]
hfo_lib
.
getNumOpponents
.
restype
=
c_int
hfo_lib
.
getLastActionStatus
.
argtypes
=
[
c_void_p
,
c_int
]
hfo_lib
.
getLastActionStatus
.
restype
=
c_int
class
HFOEnvironment
(
object
):
def
__init__
(
self
):
...
...
@@ -207,16 +205,6 @@ class HFOEnvironment(object):
""" Returns the number of opponents of the agent """
return
hfo_lib
.
getNumOpponents
(
self
.
obj
)
def
getLastActionStatus
(
self
,
last_action
):
"""
If last_action is the last action with a recorded status,
returns ACTION_STATUS_MAYBE for possible success,
ACTION_STATUS_BAD for no possibility of success,
or ACTION_STATUS_UNKNOWN if unknown. If it is not the
last action with a recorded status, returns ACTION_STATUS_UNKNOWN.
"""
return
hfo_lib
.
getLastActionStatus
(
self
.
obj
,
last_action
)
def
actionStatusToString
(
self
,
status
):
"""Returns a string representation of an action status."""
return
ACTION_STATUS_STRINGS
[
status
]
src/HFO.cpp
View file @
59c57e88
...
...
@@ -123,10 +123,6 @@ int HFOEnvironment::getNumOpponents() {
return
agent
->
getNumOpponents
();
}
action_status_t
HFOEnvironment
::
getLastActionStatus
(
action_t
last_action
)
{
return
agent
->
getLastActionStatus
(
last_action
);
}
Player
HFOEnvironment
::
playerOnBall
()
{
return
agent
->
getPlayerOnBall
();
}
...
...
src/HFO.hpp
View file @
59c57e88
...
...
@@ -55,8 +55,6 @@ class HFOEnvironment {
// Returns the number of opponents
virtual
int
getNumOpponents
();
virtual
action_status_t
getLastActionStatus
(
action_t
last_action
);
// Get the current player holding the ball
virtual
Player
playerOnBall
();
...
...
src/agent.cpp
View file @
59c57e88
This diff is collapsed.
Click to expand it.
src/agent.h
View file @
59c57e88
...
...
@@ -65,8 +65,7 @@ protected:
std
::
vector
<
float
>
params
;
// Parameters of current action
int
num_teammates
;
// Number of teammates
int
num_opponents
;
// Number of opponents
hfo
::
action_t
last_action_with_status
;
// Last action with a recorded return status
hfo
::
action_status_t
last_action_status
;
// Recorded return status of last action
bool
last_action_status
;
// Recorded return status of last action
public:
inline
const
std
::
vector
<
float
>&
getState
()
{
return
state
;
}
...
...
@@ -76,7 +75,7 @@ protected:
int
getUnum
();
// Returns the uniform number of the player
inline
int
getNumTeammates
()
{
return
num_teammates
;
}
inline
int
getNumOpponents
()
{
return
num_opponents
;
}
hfo
::
action_status_t
getLastActionStatus
(
hfo
::
action_t
last_action
);
// if last_action is correct, returns status if available
inline
bool
getLastActionStatus
()
{
return
last_action_status
;
}
inline
void
setFeatureSet
(
hfo
::
feature_set_t
fset
)
{
feature_set
=
fset
;
}
inline
std
::
vector
<
float
>*
mutable_params
()
{
return
&
params
;
}
...
...
@@ -85,23 +84,23 @@ protected:
private:
bool
doPreprocess
();
hfo
::
action_status_t
doReorient
();
hfo
::
action_status_t
doSmartKick
();
hfo
::
action_status_t
doShoot
();
bool
doReorient
();
bool
doSmartKick
();
bool
doShoot
();
bool
doPass
();
hfo
::
action_status_t
doPassTo
(
int
receiver
);
hfo
::
action_status_t
doDribble
();
hfo
::
action_status_t
doMove
();
bool
doPassTo
(
int
receiver
);
bool
doDribble
();
bool
doMove
();
bool
doForceKick
();
bool
doHeardPassReceive
();
hfo
::
action_status_t
doMarkPlayer
(
int
unum
);
bool
doMarkPlayer
(
int
unum
);
bool
doMarkPlayerNearIndex
(
int
near_index
);
hfo
::
action_status_t
doReduceAngleToGoal
();
hfo
::
action_status_t
doDefendGoal
();
hfo
::
action_status_t
doGoToBall
();
bool
doReduceAngleToGoal
();
bool
doDefendGoal
();
bool
doGoToBall
();
bool
doNewAction1
();
void
addLastActionStatus
(
hfo
::
action_t
last_action
,
hfo
::
action_status_t
action_status
);
void
addLastActionStatusCollision
(
hfo
::
action_t
last_action
,
bool
may_fix
,
bool
likely_success
);
inline
void
setLastActionStatus
(
bool
likely_success
)
{
last_action_status
=
likely_success
;
}
void
setLastActionStatusCollision
(
bool
may_fix
,
bool
likely_success
);
Communication
::
Ptr
M_communication
;
...
...
src/bhv_basic_move.cpp
View file @
59c57e88
...
...
@@ -52,32 +52,23 @@
using
namespace
rcsc
;
bool
Bhv_BasicMove
::
execute
(
PlayerAgent
*
agent
)
{
if
(
Bhv_BasicMove
::
action_execute
(
agent
)
==
hfo
::
ACTION_STATUS_MAYBE
)
{
return
true
;
}
else
{
return
false
;
}
}
/*-------------------------------------------------------------------*/
/*!
*/
hfo
::
action_status_t
bool
Bhv_BasicMove
::
action_execute
(
PlayerAgent
*
agent
)
{
dlog
.
addText
(
Logger
::
TEAM
,
__FILE__
": Bhv_BasicMove"
);
hfo
::
action_status_t
success
=
hfo
::
ACTION_STATUS_UNKNOWN
;
bool
success
=
false
;
bool
maybe_success
=
true
;
//-----------------------------------------------
// tackle
if
(
Bhv_BasicTackle
(
0.8
,
80.0
).
execute
(
agent
)
)
{
return
hfo
::
ACTION_STATUS_MAYBE
;
return
true
;
}
const
WorldModel
&
wm
=
agent
->
world
();
...
...
@@ -96,7 +87,7 @@ Bhv_BasicMove::action_execute( PlayerAgent * agent )
{
dlog
.
addText
(
Logger
::
TEAM
,
__FILE__
": intercept"
);
success
=
hfo
::
BooleanToActionStatus
(
Body_Intercept
().
execute
(
agent
)
);
success
=
Body_Intercept
().
execute
(
agent
);
agent
->
setNeckAction
(
new
Neck_OffensiveInterceptNeck
()
);
return
success
;
}
...
...
@@ -107,7 +98,7 @@ Bhv_BasicMove::action_execute( PlayerAgent * agent )
const
BallObject
&
ball
=
wm
.
ball
();
if
(
!
ball
.
rposValid
())
{
if
(
!
wm
.
self
().
collidesWithPost
())
{
success
=
hfo
::
ACTION_STATUS_BAD
;
maybe_success
=
false
;
}
}
...
...
@@ -127,10 +118,12 @@ Bhv_BasicMove::action_execute( PlayerAgent * agent )
).
execute
(
agent
)
)
{
if
(
!
Body_TurnToBall
().
execute
(
agent
))
{
success
=
hfo
::
ACTION_STATUS_BAD
;
success
=
false
;
}
else
{
success
=
maybe_success
;
}
}
else
if
(
success
!=
hfo
::
ACTION_STATUS_BAD
)
{
success
=
hfo
::
ACTION_STATUS_MAYBE
;
}
else
{
success
=
maybe_success
;
}
if
(
wm
.
existKickableOpponent
()
&&
...
...
src/bhv_basic_move.h
View file @
59c57e88
...
...
@@ -38,7 +38,6 @@ public:
{
}
bool
execute
(
rcsc
::
PlayerAgent
*
agent
);
hfo
::
action_status_t
action_execute
(
rcsc
::
PlayerAgent
*
agent
);
private:
double
getDashPower
(
const
rcsc
::
PlayerAgent
*
agent
);
...
...
src/common.hpp
View file @
59c57e88
...
...
@@ -53,24 +53,6 @@ enum status_t
SERVER_DOWN
// Server is not alive
};
// Action status
enum
action_status_t
{
ACTION_STATUS_UNKNOWN
=
-
1
,
// cannot tell or invalid action # in status request
ACTION_STATUS_BAD
=
0
,
// definitely not OK
ACTION_STATUS_MAYBE
=
1
,
// may be OK, may not
};
/**
* Translates from boolean false (bad) or true (maybe OK) to action status
*/
inline
action_status_t
BooleanToActionStatus
(
const
bool
status
)
{
if
(
status
)
{
return
ACTION_STATUS_MAYBE
;
}
else
{
return
ACTION_STATUS_BAD
;
}
}
// Configuration of the HFO domain including the team names and player
// numbers for each team. This struct is populated by ParseConfig().
struct
Config
{
...
...
src/feature_extractor.h
View file @
59c57e88
// -*-c++-*-
#ifndef FEATURE_EXTRACTOR_H
#define FEATURE_EXTRACTOR_H
...
...
src/highlevel_feature_extractor.cpp
View file @
59c57e88
...
...
@@ -4,6 +4,7 @@
#include "highlevel_feature_extractor.h"
#include <rcsc/common/server_param.h>
#include "agent.h"
using
namespace
rcsc
;
...
...
@@ -16,6 +17,7 @@ HighLevelFeatureExtractor::HighLevelFeatureExtractor(int num_teammates,
assert
(
numOpponents
>=
0
);
numFeatures
=
num_basic_features
+
features_per_teammate
*
numTeammates
+
features_per_opponent
*
numOpponents
;
numFeatures
++
;
// action status
feature_vec
.
resize
(
numFeatures
);
}
...
...
@@ -178,6 +180,12 @@ const std::vector<float>& HighLevelFeatureExtractor::ExtractFeatures(
addFeature
(
FEAT_INVALID
);
}
if
(
getLastActionStatus
())
{
addFeature
(
FEAT_MAX
);
}
else
{
addFeature
(
FEAT_MIN
);
}
assert
(
featIndx
==
numFeatures
);
// checkFeatures();
return
feature_vec
;
...
...
src/highlevel_feature_extractor.h
View file @
59c57e88
// -*-c++-*-
#ifndef HIGHLEVEL_FEATURE_EXTRACTOR_H
#define HIGHLEVEL_FEATURE_EXTRACTOR_H
...
...
src/lowlevel_feature_extractor.cpp
View file @
59c57e88
...
...
@@ -4,6 +4,7 @@
#include "lowlevel_feature_extractor.h"
#include <rcsc/common/server_param.h>
#include "agent.h"
using
namespace
rcsc
;
...
...
@@ -17,6 +18,7 @@ LowLevelFeatureExtractor::LowLevelFeatureExtractor(int num_teammates,
numFeatures
=
num_basic_features
+
features_per_player
*
(
numTeammates
+
numOpponents
);
numFeatures
+=
numTeammates
+
numOpponents
;
// Uniform numbers
numFeatures
++
;
// action state
feature_vec
.
resize
(
numFeatures
);
}
...
...
@@ -197,7 +199,7 @@ const std::vector<float>& LowLevelFeatureExtractor::ExtractFeatures(
detected_teammates
++
;
}
}
// Add -
2
features for any missing teammates
// Add -
1
features for any missing teammates
for
(
int
i
=
detected_teammates
;
i
<
numTeammates
;
++
i
)
{
addFeature
(
FEAT_MIN
);
}
...
...
@@ -212,11 +214,17 @@ const std::vector<float>& LowLevelFeatureExtractor::ExtractFeatures(
detected_opponents
++
;
}
}
// Add -
2
features for any missing opponents
// Add -
1
features for any missing opponents
for
(
int
i
=
detected_opponents
;
i
<
numOpponents
;
++
i
)
{
addFeature
(
FEAT_MIN
);
}
if
(
getLastActionStatus
())
{
addFeature
(
FEAT_MAX
);
}
else
{
addFeature
(
FEAT_MIN
);
}
assert
(
featIndx
==
numFeatures
);
checkFeatures
();
return
feature_vec
;
...
...
src/lowlevel_feature_extractor.h
View file @
59c57e88
// -*-c++-*-
#ifndef LOWLEVEL_FEATURE_EXTRACTOR_H
#define LOWLEVEL_FEATURE_EXTRACTOR_H
...
...
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