Commit aaf8751c authored by Matthew Hausknecht's avatar Matthew Hausknecht

Switched back to normalized features.

parent dda0c9d0
......@@ -41,12 +41,21 @@ const std::vector<float>& HighLevelFeatureExtractor::ExtractFeatures(
// Allow the agent to go 10% over the playfield in any direction
float tolerance_x = .1 * SP.pitchHalfLength();
float tolerance_y = .1 * SP.pitchHalfWidth();
// Feature[0]: Xpostion
addFeature(self_pos.x);
// Feature[1]: YPosition
addFeature(self_pos.y);
// Feature[0]: X-postion
if (playingOffense) {
addNormFeature(self_pos.x, -tolerance_x, SP.pitchHalfLength() + tolerance_x);
} else {
addNormFeature(self_pos.x, -SP.pitchHalfLength()-tolerance_x, tolerance_x);
}
// addFeature(self_pos.x);
// Feature[1]: Y-Position
addNormFeature(self_pos.y, -SP.pitchHalfWidth() - tolerance_y,
SP.pitchHalfWidth() + tolerance_y);
// addFeature(self_pos.y);
// Feature[2]: Self Angle
addFeature(self_ang);
addNormFeature(self_ang, -2*M_PI, 2*M_PI); // addFeature(self_ang);
float r;
float th;
......@@ -54,11 +63,11 @@ const std::vector<float>& HighLevelFeatureExtractor::ExtractFeatures(
Vector2D ball_pos = wm.ball().pos();
angleDistToPoint(self_pos, ball_pos, th, r);
// Feature[3]: Dist to ball
addFeature(r);
addNormFeature(r, 0, maxR); // addFeature(r);
// Feature[4]: Ang to ball
addFeature(th);
addNormFeature(th, -2*M_PI, 2*M_PI); // addFeature(th);
// Feature[5]: Able to kick
addFeature(self.isKickable());
addNormFeature(self.isKickable(), false, true); // addFeature(self.isKickable());
// features about distance to goal center
Vector2D goalCenter(SP.pitchHalfLength(), 0);
......@@ -67,18 +76,20 @@ const std::vector<float>& HighLevelFeatureExtractor::ExtractFeatures(
}
angleDistToPoint(self_pos, goalCenter, th, r);
// Feature[6]: Goal Center Distance
addFeature(r);
addNormFeature(r, 0, maxR); // addFeature(r);
// Feature[7]: Angle to goal center
addFeature(th);
addNormFeature(th, -2*M_PI, 2*M_PI); // addFeature(th);
// Feature[8]: largest open goal angle
addFeature(calcLargestGoalAngle(wm, self_pos));
addNormFeature(calcLargestGoalAngle(wm, self_pos), 0, M_PI);
// addFeature(calcLargestGoalAngle(wm, self_pos));
// Feature [9+T]: teammate's open angle to goal
// Features [9+T - 9 + 2T]: teammate's open angle to goal
int detected_teammates = 0;
for (PlayerCont::const_iterator it=teammates.begin(); it != teammates.end(); ++it) {
const PlayerObject& teammate = *it;
if (valid(teammate) && detected_teammates < numTeammates) {
addFeature(calcLargestGoalAngle(wm, teammate.pos()));
addNormFeature(calcLargestGoalAngle(wm, teammate.pos()), 0, M_PI);
// addFeature(calcLargestGoalAngle(wm, teammate.pos()));
detected_teammates++;
}
}
......@@ -90,17 +101,15 @@ const std::vector<float>& HighLevelFeatureExtractor::ExtractFeatures(
// dist to our closest opp
if (numOpponents > 0) {
calcClosestOpp(wm, self_pos, th, r);
addFeature(r);
addNormFeature(r, 0, maxR); // addFeature(r);
// teammates dists to closest opps
detected_teammates = 0;
for (PlayerCont::const_iterator it=teammates.begin(); it != teammates.end(); ++it) {
const PlayerObject& teammate = *it;
if (valid(teammate) && detected_teammates < numTeammates) {
//addNormFeature(calcClosestOpp(wm,teammate.pos),0,maxR);
calcClosestOpp(wm, teammate.pos(), th, r);
addFeature(r);
//addNormFeature(th,-M_PI,M_PI);
addNormFeature(r, 0, maxR); // addFeature(r);
detected_teammates++;
}
}
......@@ -110,12 +119,13 @@ const std::vector<float>& HighLevelFeatureExtractor::ExtractFeatures(
}
}
// open angle to teammates
// Features [9+2T - 9+3T]: open angle to teammates
detected_teammates = 0;
for (PlayerCont::const_iterator it=teammates.begin(); it != teammates.end(); ++it) {
const PlayerObject& teammate = *it;
if (valid(teammate) && detected_teammates < numTeammates) {
addFeature(calcLargestTeammateAngle(wm, self_pos, teammate.pos()));
addNormFeature(calcLargestTeammateAngle(wm, self_pos, teammate.pos()),0,M_PI);
// addFeature(calcLargestTeammateAngle(wm, self_pos, teammate.pos()));
detected_teammates++;
}
}
......@@ -124,14 +134,14 @@ const std::vector<float>& HighLevelFeatureExtractor::ExtractFeatures(
addFeature(FEAT_INVALID);
}
// dist and angle to teammates
// Features [9+3T - end]: dist, angle, unum of teammates
detected_teammates = 0;
for (PlayerCont::const_iterator it=teammates.begin(); it != teammates.end(); ++it) {
const PlayerObject& teammate = *it;
if (valid(teammate) && detected_teammates < numTeammates) {
angleDistToPoint(self_pos, teammate.pos(), th, r);
addFeature(r);
addFeature(th);
addNormFeature(r,0,maxR); // addFeature(r);
addNormFeature(th,-M_PI,M_PI); // addFeature(th);
addFeature(teammate.unum());
detected_teammates++;
}
......
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