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
f54c759c
Commit
f54c759c
authored
Jul 06, 2017
by
drallensmith
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
First try at adding PreprocessAsAction
parent
e1410fc5
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
126 additions
and
2 deletions
+126
-2
hfo/hfo.py
hfo/hfo.py
+1
-1
src/agent.cpp
src/agent.cpp
+118
-0
src/agent.h
src/agent.h
+1
-0
src/common.hpp
src/common.hpp
+6
-1
No files found.
hfo/hfo.py
View file @
f54c759c
...
...
@@ -26,7 +26,7 @@ LOW_LEVEL_FEATURE_SET, HIGH_LEVEL_FEATURE_SET = list(range(2))
NOOP(): Do Nothing
QUIT(): Quit the game '''
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
(
19
))
MOVE
,
SHOOT
,
PASS
,
DRIBBLE
,
CATCH
,
NOOP
,
QUIT
,
REDUCE_ANGLE_TO_GOAL
,
MARK_PLAYER
,
DEFEND_GOAL
,
GO_TO_BALL
,
PREPROCESS
=
list
(
range
(
20
))
''' Possible game status
[IN_GAME] Game is currently active
...
...
src/agent.cpp
View file @
f54c759c
...
...
@@ -317,6 +317,9 @@ void Agent::actionImpl() {
case
GO_TO_BALL
:
this
->
doGoToBall
();
break
;
case
PREPROCESS
:
this
->
doPreprocessAsAction
();
break
;
default:
std
::
cerr
<<
"ERROR: Unsupported Action: "
<<
requested_action
<<
std
::
endl
;
...
...
@@ -698,6 +701,121 @@ Agent::doPreprocess()
return
false
;
}
/*-------------------------------------------------------------------*/
/*!
Alternative high-level action to always doing "Move"; usable by either side, although
probably more useful for offense.
*/
bool
Agent
::
doPreprocessAsAction
()
{
// check tackle expires
// check self position accuracy
// ball search
// check queued intention
const
WorldModel
&
wm
=
this
->
world
();
dlog
.
addText
(
Logger
::
TEAM
,
__FILE__
": (doPreProcessAsAction)"
);
//
// frozen by tackle effect
//
if
(
wm
.
self
().
isFrozen
()
)
{
dlog
.
addText
(
Logger
::
TEAM
,
__FILE__
": tackle wait. expires= %d"
,
wm
.
self
().
tackleExpires
()
);
// face neck to ball
this
->
setViewAction
(
new
View_Tactical
()
);
this
->
setNeckAction
(
new
Neck_TurnToBallOrScan
()
);
return
true
;
}
//
// BeforeKickOff or AfterGoal. jump to the initial position
//
if
(
wm
.
gameMode
().
type
()
==
GameMode
::
BeforeKickOff
||
wm
.
gameMode
().
type
()
==
GameMode
::
AfterGoal_
)
{
dlog
.
addText
(
Logger
::
TEAM
,
__FILE__
": before_kick_off"
);
Vector2D
move_point
=
Strategy
::
i
().
getPosition
(
wm
.
self
().
unum
()
);
Bhv_CustomBeforeKickOff
(
move_point
).
execute
(
this
);
this
->
setViewAction
(
new
View_Tactical
()
);
return
true
;
}
//
// self localization error
//
if
(
!
(
wm
.
self
().
posValid
()
&&
wm
.
self
().
velValid
()
)
)
{
if
(
!
wm
.
self
().
posValid
()
)
{
dlog
.
addText
(
Logger
::
TEAM
,
__FILE__
": invalid my pos"
);
}
else
{
dlog
.
addText
(
Logger
::
TEAM
,
__FILE__
": invalid my vel"
);
}
Bhv_Emergency
().
execute
(
this
);
// includes change view
return
true
;
}
//
// ball localization error
//
const
int
count_thr
=
(
wm
.
self
().
goalie
()
?
10
:
5
);
if
(
wm
.
ball
().
posCount
()
>
count_thr
||
(
wm
.
gameMode
().
type
()
!=
GameMode
::
PlayOn
&&
wm
.
ball
().
seenPosCount
()
>
count_thr
+
10
)
)
{
dlog
.
addText
(
Logger
::
TEAM
,
__FILE__
": search ball"
);
this
->
setViewAction
(
new
View_Tactical
()
);
Bhv_NeckBodyToBall
().
execute
(
this
);
return
true
;
}
//
// set default change view
//
this
->
setViewAction
(
new
View_Tactical
()
);
//
// check queued action
//
if
(
this
->
doIntention
()
)
{
dlog
.
addText
(
Logger
::
TEAM
,
__FILE__
": do queued intention"
);
return
true
;
}
//
// check pass message
//
if
(
doHeardPassReceive
()
)
{
return
true
;
}
const
BallObject
&
ball
=
wm
.
ball
();
if
(
!
(
ball
.
rposValid
()
&&
ball
.
rvelValid
()
))
{
dlog
.
addText
(
Logger
::
TEAM
,
__FILE__
": search ball"
);
Bhv_NeckBodyToBall
().
execute
(
this
);
return
true
;
}
return
false
;
}
/*-------------------------------------------------------------------*/
/*!
...
...
src/agent.h
View file @
f54c759c
...
...
@@ -76,6 +76,7 @@ protected:
private:
bool
doPreprocess
();
bool
doPreprocessAsAction
();
bool
doSmartKick
();
bool
doShoot
();
bool
doPass
();
...
...
src/common.hpp
View file @
f54c759c
...
...
@@ -37,7 +37,8 @@ enum action_t
REDUCE_ANGLE_TO_GOAL
,
// [High-Level] Reduce_Angle_To_Goal : Reduces the shooting angle
MARK_PLAYER
,
// [High-Level] Mark_Player(opponent_unum [0,11]) : Moves to the position in between the kicker and a given player
DEFEND_GOAL
,
GO_TO_BALL
GO_TO_BALL
,
PREPROCESS
// [High-Level] Handle lost position of self/ball; variant called in DRIBBLE
};
// Status of a HFO game
...
...
@@ -117,6 +118,8 @@ inline int NumParams(const action_t action) {
return
0
;
case
GO_TO_BALL
:
return
0
;
case
PREPROCESS
:
return
0
;
}
std
::
cerr
<<
"Unrecognized Action: "
<<
action
<<
std
::
endl
;
return
-
1
;
...
...
@@ -165,6 +168,8 @@ inline std::string ActionToString(action_t action) {
return
"Defend_Goal"
;
case
GO_TO_BALL
:
return
"Go_To_Ball"
;
case
PREPROCESS
:
return
"PreProcessAsAction"
;
default:
return
"Unknown"
;
}
...
...
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