⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 memposition.c

📁 RoboCup 2D 仿真组冠军源代码之1998年冠军队——CMUnited98源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
    RM_Their_PC_Flag = Flag_PRC; /* Center of theirs          */  }  else{ /* MySide == 'r' */    RM_My_Goal = Goal_R;    RM_Their_Goal = Goal_L;    RM_LB_Flag = Flag_RB;    RM_LC_Flag = Flag_CB;    RM_LF_Flag = Flag_LB;    RM_RB_Flag = Flag_RT;    RM_RC_Flag = Flag_CT;    RM_RF_Flag = Flag_LT;    RM_My_PC_Flag = Flag_PRC;    /* Center of my penalty area */    RM_Their_PC_Flag = Flag_PLC; /* Center of theirs          */  }      i=0;  Fieldline = new StationaryObject[SP_num_lines];  Fieldline[i].Initialize((SideLine) i, Vector( -SP_pitch_length/2.0, 0.0 ), 			 CP_max_conf, CP_min_valid_conf, rotate); i++; /* SL_Left */  Fieldline[i].Initialize((SideLine) i, Vector( SP_pitch_length/2.0, 0.0 ), 			 CP_max_conf, CP_min_valid_conf, rotate); i++; /* SL_Right */  Fieldline[i].Initialize((SideLine) i, Vector( 0.0, -SP_pitch_width/2.0 ), 			 CP_max_conf, CP_min_valid_conf, rotate); i++; /* SL_Top */  Fieldline[i].Initialize((SideLine) i, Vector( 0.0, SP_pitch_width/2.0 ), 			 CP_max_conf, CP_min_valid_conf, rotate); /* SL_Bottom */    Ball.Initialize(CP_max_conf, CP_min_valid_conf, CP_ball_conf_decay, SP_ball_decay, SP_ball_speed_max);  num_players          = SP_team_size*2-1;  Player = new PlayerObject[num_players];     /* allow for all players but me          */  for (i=0; i<num_players; i++)    Player[i].Initialize(CP_max_conf, CP_min_valid_conf, CP_player_conf_decay, 			 SP_player_decay, SP_player_speed_max );  for (i=0; i<num_players; i++)    FreePlayer[i] = &(Player[(num_players-1) - i]);   /* Player array backwards: take from end */  UnknownPlayer = new TempPlayerObject[num_players];  num_seen_markers     = 0;  num_my_players       = 0;  num_their_players    = 0;  num_teamless_players = 0;  num_free_players     = num_players;  num_unknown_players  = 0;  ClosestMarker = ClosestMotionMarker = No_Marker;  SeenLine = SL_No_Line;  for (i=1; i<=SP_team_size; i++)    TiredTimes[i] = -CP_say_tired_interval;  OwnPenaltyArea = Rectangle(-SP_pitch_length/2,                          //left			     -SP_pitch_length/2 + SP_penalty_area_length, //right			     -SP_penalty_area_width/2,                    //top			     SP_penalty_area_width/2);                    //bottom  OwnGoalieArea = Rectangle(-SP_pitch_length/2,                       //left			    -SP_pitch_length/2 + SP_goal_area_length, //right			    -SP_goal_area_width/2,                    //top				    SP_goal_area_width/2);                    //bottom  TheirPenaltyArea = Rectangle(SP_pitch_length/2 - SP_penalty_area_length,//left			      SP_pitch_length/2,                          //right			     -SP_penalty_area_width/2,                    //top			     SP_penalty_area_width/2);                    //bottom  TheirGoalieArea = Rectangle(SP_pitch_length/2 - SP_goal_area_length,//left			      SP_pitch_length/2,                          //right			    -SP_goal_area_width/2,                    //top				    SP_goal_area_width/2);                    //bottom  FieldRectangle = Rectangle(-SP_pitch_length/2,			      SP_pitch_length/2,			     -SP_pitch_width/2,			      SP_pitch_width);}PositionInfo::~PositionInfo(){  delete Fieldline;  delete Marker;  delete Player;  delete UnknownPlayer;}/********************************************************************************//********************************************************************************//********************************************************************************/void PositionInfo::SeeLine(SideLine l, float dist, float ang, Time tm){  Fieldline[l].set_polar(dist,ang,tm);  SeenLine = l;}/********************************************************************************/void PositionInfo::SeeLine(SideLine l, float ang, Time tm){  Fieldline[l].set_angle(ang,tm);  SeenLine = l;}/********************************************************************************//********************************************************************************//********************************************************************************/void PositionInfo::SeeMarker(MarkerType marker, float dist, float ang, Time tm){  Marker[marker].set_polar(dist,ang,tm);  SeenMarker[num_seen_markers++] = marker;}/********************************************************************************/void PositionInfo::SeeMarker(MarkerType marker, float ang, Time tm){  Marker[marker].set_angle(ang,tm);  SeenMarker[num_seen_markers++] = marker;  my_error("Shouldn't process markers when using low quality -- no info");}/********************************************************************************/void PositionInfo::SeeMarker(MarkerType marker, float dist, float ang, 			     float distChng, float dirChng, Time tm){  Marker[marker].set_chinfo(distChng, dirChng, tm);  Marker[marker].set_polar(dist,ang,tm);  SeenMarker[num_seen_markers++] = marker;}/*********************************************************************************//*********************************************************************************//*********************************************************************************/void PositionInfo::SeeBall(float ang, Time tm){  Ball.set_angle(ang,tm);}/*********************************************************************************/void PositionInfo::SeeBall(float dist, float ang, Time tm){  Ball.set_polar(dist,ang,tm);}/*********************************************************************************/void PositionInfo::SeeBall(float dist, float ang, float distChng, float dirChng, Time tm){  Ball.set_chinfo(distChng, dirChng, tm);  SeeBall(dist,ang,tm);}/*********************************************************************************//********************************************************************************//*********************************************************************************/void PositionInfo::SeePlayer(char side, Unum num, float ang, Time time){  PlayerObject *player;  if ( (player = GetPlayer(side, num)) == NULL )    player = GetNewPlayer(side, num);  if ( player != NULL )     player->set_angle(ang,time);  else     my_error("Can't get a player to see (1)");}/********************************************************************************/void PositionInfo::SeePlayer(char side, Unum num, float dist, float ang, Time time){  PlayerObject *player;  if ( (player = GetPlayer(side, num)) == NULL )    player = GetNewPlayer(side, num);  if ( player != NULL )     player->set_polar(dist,ang,time);  else     my_error("Can't get a player to see (2)");}/********************************************************************************/void PositionInfo::SeePlayer(char side, Unum num, 			     float dist, float ang, float distChng, float dirChng, float facedir, Time time){  PlayerObject *player;  if ( (player = GetPlayer(side, num)) == NULL )    player = GetNewPlayer(side, num);  if ( player != NULL ){    player->set_chinfo(distChng,dirChng,time);    player->set_face(facedir,time);    player->set_polar(dist,ang,time);  }  else     my_error("Can't get a player to see (3)");}/********************************************************************************/void PositionInfo::SeePlayer(char side, float dist, float ang, Time time){  UnknownPlayer[num_unknown_players].set(side,dist,ang,time);  num_unknown_players++;}/********************************************************************************/void PositionInfo::SeePlayer(char side, float ang, Time time){  my_error("What can I do that's useful with just the player angle?");  return;  UnknownPlayer[num_unknown_players].set(side,0,ang,time);  num_unknown_players++;}/********************************************************************************/void PositionInfo::SeePlayer(float dist, float ang, Time time){  UnknownPlayer[num_unknown_players].set('?',dist,ang,time);  num_unknown_players++;}/********************************************************************************/void PositionInfo::SeePlayer(float ang, Time time){  my_error("What can I do that's useful with just the player angle?");  return;  UnknownPlayer[num_unknown_players].set('?',0,ang,time);    num_unknown_players++;}/********************************************************************************/void PositionInfo::HearBall(float x, float y, float conf, float dist, Time time){  Ball.set_heard_info(x,y,conf,dist,time);}/********************************************************************************/void PositionInfo::HearBall(float x, float y, float pconf, float dx, float dy, float vconf, 			    float dist, Time time){  Ball.set_heard_info(x,y,pconf,dx,dy,vconf,dist,time);}/********************************************************************************/void PositionInfo::HearPlayer(char side, Unum num, float x, float y, float conf, float dist, Time time){  /* When hearing a player location, remember not to call just getplayer, but also     closestPlayerto(side,vector) -- might be one of the unknowns      can just update the side---update_players takes care of the rest */  PlayerObject *player;  if ( (player = GetPlayer(side, num)) == NULL ){    Vector pos = Vector(x,y);    if ( (player = ClosestPlayerObjectTo(side, pos)) != NULL ){      if ( player->side == '?' )	player->side = side;       player->unum = num;    }    else       player = GetNewPlayer(side, num);  }  if ( player != NULL )     player->set_heard_info(x,y,conf,dist,time);  else     my_error("Can't get a player to hear");}/********************************************************************************/void PositionInfo::HearPlayer(char side, Unum num, float x, float y, float pconf, 			      float dx, float dy, float vconf, float dist, Time time){  /* When hearing a player location, remember not to call just getplayer, but also     closestPlayerto(side,vector) -- might be one of the unknowns      can just update the side---update_players takes care of the rest */  PlayerObject *player;  if ( (player = GetPlayer(side, num)) == NULL ){    Vector pos = Vector(x,y);    if ( (player = ClosestPlayerObjectTo(side, pos)) != NULL ){      if ( player->side == '?' )	player->side = side;       player->unum  = num;    }    else       player = GetNewPlayer(side, num);  }  if ( player != NULL )     player->set_heard_info(x,y,pconf,dx,dy,vconf,dist,time);}/********************************************************************************/void PositionInfo::HearPlayer(char side, Unum num, float x, float y, float pconf, float dx, float dy, 			      float vconf, AngleDeg face, float fconf, float dist, Time time){  /* When hearing a player location, remember not to call just getplayer, but also     closestPlayerto(side,vector) -- might be one of the unknowns      can just update the side---update_players takes care of the rest */  PlayerObject *player;  if ( (player = GetPlayer(side, num)) == NULL ){    Vector pos = Vector(x,y);    if ( (player = ClosestPlayerObjectTo(side, pos)) != NULL ){      if ( player->side == '?' )	player->side = side;       player->unum  = num;    }    else       player = GetNewPlayer(side, num);  }  if ( player != NULL )     player->set_heard_info_w_face(x,y,pconf,dx,dy,vconf,face,fconf,dist,time);}/********************************************************************************//*********************************************************************************//********************************************************************************/float PositionInfo::PlayerPositionValid(char side, Unum n){   if ( side == MySide && n==MyNumber )     return MyConf();  PlayerObject *player = GetPlayer(side,n);  if ( player == NULL )     return 0;  else     return player->pos_valid();}/********************************************************************************/float PositionInfo::PlayerVelocityValid(char side, Unum n){   if ( side == MySide && n==MyNumber )     return MyVelConf();  PlayerObject *player = GetPlayer(side,n);  if ( player == NULL )     return 0;  else     return player->vel_valid();}  /********************************************************************************/float PositionInfo::PlayerFaceValid(char side, Unum n){   if ( side == MySide && n==MyNumber )     return MyConf();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -