Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

# Representations/RoboCup/GameRules.cpp

Go to the documentation of this file.

    00001 #include "GameRules.h"
    00002
    00003 #include "Tools/FieldDimensions.h"
    00004
    00005 THROW_IN_POINTS getPoint(GameRules::THROWINPOINT p,Player::teamColor c)
    00006 {
    00007   switch (c)
    00008   {
    00009     case Player::red:
    00010       switch (p)
    00011       {
    00012         case GameRules::leftRed:
    00013           return throwInPointNumberBackLeft;
    00014         case GameRules::rightRed:
    00015           return throwInPointNumberBackRight;
    00016         case GameRules::leftmiddle:
    00017           return throwInPointNumberMiddleLeft;
    00018         case GameRules::rightmiddle:
    00019           return throwInPointNumberMiddleRight;
    00020         case GameRules::leftBlue:
    00021           return throwInPointNumberFrontLeft;
    00022         case GameRules::rightBlue:
    00023           return throwInPointNumberFrontRight;
    00024       }
    00025     case Player::blue:
    00026       switch (p)
    00027       {
    00028         case GameRules::leftRed:
    00029           return throwInPointNumberFrontLeft;
    00030         case GameRules::rightRed:
    00031           return throwInPointNumberFrontRight;
    00032         case GameRules::leftmiddle:
    00033           return throwInPointNumberMiddleLeft;
    00034         case GameRules::rightmiddle:
    00035           return throwInPointNumberMiddleRight;
    00036         case GameRules::leftBlue:
    00037           return throwInPointNumberBackLeft;
    00038         case GameRules::rightBlue:
    00039           return throwInPointNumberBackRight;
    00040       }
    00041   }
    00042   return throwInPointNumber;
    00043 }
    00044
    00045 int GameRules::getThrowInPointFieldNumber(THROWINPOINT pointNr, Player::teamColor team)
    00046 {
    00047   return getPoint(pointNr, team);
    00048 }
    00049
    00050 GameRules::THROWINPOINT GameRules::getThrowInPointNumber(GameRules::ROLLOUTBORDER border, Player::teamColor team)
    00051 {
    00052   switch (team)
    00053   {
    00054 //    case Player::red:
    00055     case Player::blue:
    00056       switch (border)
    00057       {
    00058         case leftRedGoal:
    00059         case leftRedSite:
    00060           return leftRed;
    00061         case rightRedGoal:
    00062         case rightRedSite:
    00063           return rightRed;
    00064         case leftBlueSite:
    00065         case leftBlueGoal:
    00066           return leftmiddle;
    00067         case rightBlueSite:
    00068         case rightBlueGoal:
    00069           return rightmiddle;
    00070       }
    00071       break;
    00072 //    case Player::blue:
    00073     case Player::red:
    00074       switch (border)
    00075       {
    00076         case leftRedGoal:
    00077         case leftRedSite:
    00078           return leftmiddle;
    00079         case rightRedGoal:
    00080         case rightRedSite:
    00081           return rightmiddle;
    00082         case leftBlueSite:
    00083         case leftBlueGoal:
    00084           return leftBlue;
    00085         case rightBlueSite:
    00086         case rightBlueGoal:
    00087           return rightBlue;
    00088       }
    00089       break;
    00090   }
    00091   return numOfThrowIn;
    00092 }
    00093
    00094 int GameRules::getThrowInPointNumber(Vector2<double> ball, Player player, RoboCupGameControlData gamedata)
    00095 {
    00096   GameRules::ROLLOUTBORDER border;
    00097   switch ( player.getTeamColor() )
    00098   {
    00099     case Player::red:
    00100       if (ball.x > 0)
    00101       {
    00102         if (ball.y > 0)
    00103         {
    00104           border = leftBlueGoal;
    00105         }else{
    00106           border = rightBlueGoal;
    00107         }
    00108       }else{
    00109         if (ball.y > 0)
    00110         {
    00111           border = leftRedGoal;
    00112         }else{
    00113           border = rightRedGoal;
    00114         }
    00115       }
    00116     break;
    00117     case Player::blue:
    00118       if (ball.x > 0)
    00119       {
    00120         if (ball.y > 0)
    00121         {
    00122           border = leftRedGoal;
    00123         }else{
    00124           border = rightRedGoal;
    00125         }
    00126       }else{
    00127         if (ball.y > 0)
    00128         {
    00129           border = leftBlueGoal;
    00130         }else{
    00131           border = rightBlueGoal;
    00132         }
    00133       }
    00134     break;
    00135     default:
    00136       return throwInPointNumber;
    00137   }
    00138
    00139   THROWINPOINT tip= getThrowInPointNumber(border,
    00140     GameManagerTool::getTeamColorFormGameManager(gamedata.teams[gamedata.dropInTeam].teamColour));
    00141
    00142   return tip;
    00143 }
    00144 Vector3<double> GameRules::getThrowInPoint(Vector2<double> ball, Player player, RoboCupGameControlData gamedata)
    00145 {
    00146   int tip = getThrowInPointNumber(ball,player,gamedata);
    00147   if (tip >=throwInPointNumber)
    00148     Vector3<double>(0,0,0);
    00149
    00150   int tmpi =getPoint((GameRules::THROWINPOINT)tip,player.getTeamColor());
    00151   Vector3<double> tmpv(throwInPoint[tmpi][0],throwInPoint[tmpi][1],0);
    00152   return tmpv;
    00153 }
    00154
    00155
    00156 Player::teamColor GameManagerTool::getTeamColorFormGameManager(uint32 teamColour)
    00157 {
    00158   switch (teamColour)
    00159   {
    00160     case (TEAM_BLUE):
    00161       return Player::blue;
    00162     case (TEAM_RED):
    00163       return Player::red;
    00164   }
    00165   return Player::undefinedTeamColor;
    00166 }
    00167