Commit f54c759c authored by drallensmith's avatar drallensmith

First try at adding PreprocessAsAction

parent e1410fc5
......@@ -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
......
......@@ -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;
}
/*-------------------------------------------------------------------*/
/*!
......
......@@ -76,6 +76,7 @@ protected:
private:
bool doPreprocess();
bool doPreprocessAsAction();
bool doSmartKick();
bool doShoot();
bool doPass();
......
......@@ -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";
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment