Commit 9ba10917 authored by Siddharth Aravindan's avatar Siddharth Aravindan Committed by asiddharth

Incorporated code review changes

parent 08411cb1
...@@ -313,7 +313,7 @@ void Agent::actionImpl() { ...@@ -313,7 +313,7 @@ void Agent::actionImpl() {
break; break;
case DEFEND_GOAL: case DEFEND_GOAL:
this->doDefendGoal(); this->doDefendGoal();
break; break;
case GO_TO_BALL: case GO_TO_BALL:
this->doGoToBall(); this->doGoToBall();
break; break;
...@@ -833,46 +833,7 @@ bool Agent::doMarkPlayer(int unum) { ...@@ -833,46 +833,7 @@ bool Agent::doMarkPlayer(int unum) {
return true; return true;
} }
/*!
* This Action marks the player which is "nearindex" nearest to the ball.
*/
bool Agent::doMarkPlayerNearIndex(int nearIndex) {
const WorldModel & wm = this->world();
Vector2D kicker_pos = Vector2D :: INVALIDATED;
Vector2D player_pos = Vector2D :: INVALIDATED;
const PlayerPtrCont::const_iterator o_end = wm.opponentsFromSelf().end();
int count = 0;
for ( PlayerPtrCont::const_iterator it = wm.opponentsFromSelf().begin(); it != o_end; ++it ) {
if ( (*it)->distFromBall() < 5 ) {
kicker_pos = (*it)->pos();
}
}
if (nearIndex >=0 && nearIndex <= wm.opponentsFromBall().size()) {
player_pos = wm.opponentsFromBall().at(nearIndex-1)->pos();
}
if (!player_pos.isValid()) {
//"nearIndex Player Not Found
return false;
}
if (!kicker_pos.isValid()) {
//Kicker not found
return false;
}
if (kicker_pos.equals(player_pos)) {
//nearIndex Player to be marked is kicker
return false;
}
double x = player_pos.x + (kicker_pos.x - player_pos.x)*0.1;
double y = player_pos.y + (kicker_pos.y - player_pos.y)*0.1;
Body_GoToPoint(Vector2D(x,y), 0.25, ServerParam::i().maxDashPower()).execute(this);
return true;
}
/*-------------------------------------------------------------------*/ /*-------------------------------------------------------------------*/
/*! /*!
* *
* This action cuts off the angle between the shooter and the goal the players always move to a dynamic line in between the kicker and the goal. * This action cuts off the angle between the shooter and the goal the players always move to a dynamic line in between the kicker and the goal.
...@@ -996,38 +957,6 @@ bool Agent::doGoToBall() { ...@@ -996,38 +957,6 @@ bool Agent::doGoToBall() {
/*-------------------------------------------------------------------*/ /*-------------------------------------------------------------------*/
/*!
Used for 1v1 .
High level action MOVE is taken whenever the agent does not have the ball.
Medium level action DRIBBLE_TO is taken whenever the agent has to turn by a large amount to get the correct angle to shoot at the goal.
High level action SHOOT is used to shoot it to the goal
This is an example action and is not used.
*/
bool Agent::doNewAction1() {
const WorldModel & wm = this->world();
if(! wm.self().isKickable() ) {
this->doMove();
return true;
} else {
Vector2D goal_pos( -ServerParam::i().pitchHalfLength(), 0.0 );
Vector2D self_pos = wm.self().pos();
Vector2D dir (self_pos.x - goal_pos.x, self_pos.y - goal_pos.y);
AngleDeg angle = wm.self().vel().th();
double angle_threshold = 10;
double angle_diff = (dir.th() - angle).degree();
if ( std::fabs(angle_diff) > angle_threshold && goal_pos.dist(self_pos) > 20) {
double x = self_pos.x + 0.1*(goal_pos.x - self_pos.x );
double y = self_pos.y + 0.1*(goal_pos.y - self_pos.y );
Body_Dribble(Vector2D(x,y), 1.0, ServerParam::i().maxDashPower(), 2).execute(this);
} else {
this->doSmartKick();
}
return true;
}
}
/*-------------------------------------------------------------------*/
/*! /*!
*/ */
......
...@@ -114,9 +114,9 @@ inline int NumParams(const action_t action) { ...@@ -114,9 +114,9 @@ inline int NumParams(const action_t action) {
case MARK_PLAYER: case MARK_PLAYER:
return 1; return 1;
case DEFEND_GOAL: case DEFEND_GOAL:
return 0; return 0;
case GO_TO_BALL: case GO_TO_BALL:
return 0; return 0;
} }
std::cerr << "Unrecognized Action: " << action << std::endl; std::cerr << "Unrecognized Action: " << action << std::endl;
return -1; return -1;
...@@ -162,9 +162,9 @@ inline std::string ActionToString(action_t action) { ...@@ -162,9 +162,9 @@ inline std::string ActionToString(action_t action) {
case MARK_PLAYER: case MARK_PLAYER:
return "Mark_Player"; return "Mark_Player";
case DEFEND_GOAL: case DEFEND_GOAL:
return "Defend_Goal"; return "Defend_Goal";
case GO_TO_BALL: case GO_TO_BALL:
return "Go_To_Ball"; return "Go_To_Ball";
default: default:
return "Unknown"; return "Unknown";
} }
......
...@@ -56,7 +56,11 @@ const std::vector<float>& HighLevelFeatureExtractor::ExtractFeatures( ...@@ -56,7 +56,11 @@ const std::vector<float>& HighLevelFeatureExtractor::ExtractFeatures(
Vector2D ball_pos = wm.ball().pos(); Vector2D ball_pos = wm.ball().pos();
angleDistToPoint(self_pos, ball_pos, th, r); angleDistToPoint(self_pos, ball_pos, th, r);
// Feature[3] and [4]: (x,y) postition of the ball // Feature[3] and [4]: (x,y) postition of the ball
addNormFeature(ball_pos.x, -SP.pitchHalfLength()-tolerance_x, tolerance_x); if (playingOffense) {
addNormFeature(ball_pos.x, -tolerance_x, SP.pitchHalfLength() + tolerance_x);
} else {
addNormFeature(ball_pos.x, -SP.pitchHalfLength()-tolerance_x, tolerance_x);
}
addNormFeature(ball_pos.y, -SP.pitchHalfWidth() - tolerance_y, SP.pitchHalfWidth() + tolerance_y); addNormFeature(ball_pos.y, -SP.pitchHalfWidth() - tolerance_y, SP.pitchHalfWidth() + tolerance_y);
// Feature[5]: Able to kick // Feature[5]: Able to kick
addNormFeature(self.isKickable(), false, true); addNormFeature(self.isKickable(), false, true);
...@@ -135,7 +139,11 @@ const std::vector<float>& HighLevelFeatureExtractor::ExtractFeatures( ...@@ -135,7 +139,11 @@ const std::vector<float>& HighLevelFeatureExtractor::ExtractFeatures(
for (PlayerCont::const_iterator it=teammates.begin(); it != teammates.end(); ++it) { for (PlayerCont::const_iterator it=teammates.begin(); it != teammates.end(); ++it) {
const PlayerObject& teammate = *it; const PlayerObject& teammate = *it;
if (valid(teammate) && detected_teammates < numTeammates) { if (valid(teammate) && detected_teammates < numTeammates) {
addNormFeature(teammate.pos().x, -tolerance_x - SP.pitchHalfLength(), tolerance_x ); if (playingOffense) {
addNormFeature(teammate.pos().x, -tolerance_x, SP.pitchHalfLength() + tolerance_x);
} else {
addNormFeature(teammate.pos().x, -SP.pitchHalfLength()-tolerance_x, tolerance_x);
}
addNormFeature(teammate.pos().y, -tolerance_y - SP.pitchHalfWidth(), SP.pitchHalfWidth() + tolerance_y); addNormFeature(teammate.pos().y, -tolerance_y - SP.pitchHalfWidth(), SP.pitchHalfWidth() + tolerance_y);
addFeature(teammate.unum()); addFeature(teammate.unum());
detected_teammates++; detected_teammates++;
...@@ -153,7 +161,11 @@ const std::vector<float>& HighLevelFeatureExtractor::ExtractFeatures( ...@@ -153,7 +161,11 @@ const std::vector<float>& HighLevelFeatureExtractor::ExtractFeatures(
for (PlayerCont::const_iterator it = opponents.begin(); it != opponents.end(); ++it) { for (PlayerCont::const_iterator it = opponents.begin(); it != opponents.end(); ++it) {
const PlayerObject& opponent = *it; const PlayerObject& opponent = *it;
if (valid(opponent) && detected_opponents < numOpponents) { if (valid(opponent) && detected_opponents < numOpponents) {
addNormFeature(opponent.pos().x, -tolerance_x - SP.pitchHalfLength(), tolerance_x ); if (playingOffense) {
addNormFeature(opponent.pos().x, -tolerance_x, SP.pitchHalfLength() + tolerance_x);
} else {
addNormFeature(opponent.pos().x, -SP.pitchHalfLength()-tolerance_x, tolerance_x);
}
addNormFeature(opponent.pos().y, -tolerance_y - SP.pitchHalfWidth(), SP.pitchHalfWidth() + tolerance_y); addNormFeature(opponent.pos().y, -tolerance_y - SP.pitchHalfWidth(), SP.pitchHalfWidth() + tolerance_y);
addFeature(opponent.unum()); addFeature(opponent.unum());
detected_opponents++; detected_opponents++;
......
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