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

📄 memposition.h

📁 1999年卡耐基梅陇大学的2D仿真源代码
💻 H
📖 第 1 页 / 共 4 页
字号:
  inline AngleDeg OpponentAngleFromBody   (Unum n) { return PlayerAngleFromBody   (TheirSide,n); }  inline AngleDeg OpponentAngleFromNeck   (Unum n) { return PlayerAngleFromNeck   (TheirSide,n); }  inline Vector   OpponentAbsolutePosition(Unum n) { return PlayerAbsolutePosition(TheirSide,n); }  inline Vector   OpponentRelativeToBodyPosition(Unum n) { return PlayerRelativeToBodyPosition(TheirSide,n); }  inline Vector   OpponentRelativeToNeckPosition(Unum n) { return PlayerRelativeToNeckPosition(TheirSide,n); }  inline float    OpponentX               (Unum n) { return PlayerX               (TheirSide,n); }  inline float    OpponentY               (Unum n) { return PlayerY               (TheirSide,n); }  inline float    OpponentPositionValid   (Unum n) { return PlayerPositionValid   (TheirSide,n); }  inline float    OpponentSpeed           (Unum n) { return PlayerSpeed           (TheirSide,n); }  inline AngleDeg OpponentRelativeToBodyHeading (Unum n) { return PlayerRelativeToBodyHeading (TheirSide,n); }  inline AngleDeg OpponentRelativeToNeckHeading (Unum n) { return PlayerRelativeToNeckHeading (TheirSide,n); }  inline AngleDeg OpponentAbsoluteHeading (Unum n) { return PlayerAbsoluteHeading (TheirSide,n); }  inline Vector   OpponentAbsoluteVelocity(Unum n) { return PlayerAbsoluteVelocity(TheirSide,n); }  inline Vector   OpponentRelativeToBodyVelocity(Unum n) { return PlayerRelativeToBodyVelocity(TheirSide,n); }  inline Vector   OpponentRelativeToNeckVelocity(Unum n) { return PlayerRelativeToNeckVelocity(TheirSide,n); }  inline float    OpponentVelocityValid   (Unum n) { return PlayerVelocityValid   (TheirSide,n); }  inline AngleDeg OpponentRelativeToBodyBodyAngle(Unum n){ return PlayerRelativeToBodyBodyAngle(TheirSide,n);}  inline AngleDeg OpponentRelativeToNeckBodyAngle(Unum n){ return PlayerRelativeToNeckBodyAngle(TheirSide,n);}  inline AngleDeg OpponentRelativeToBodyNeckAngle(Unum n){ return PlayerRelativeToBodyNeckAngle(TheirSide,n);}  inline AngleDeg OpponentRelativeToNeckNeckAngle(Unum n){ return PlayerRelativeToNeckNeckAngle(TheirSide,n);}  inline AngleDeg OpponentRelativeNeckAngle    (Unum n) { return PlayerRelativeNeckAngle (TheirSide,n); }  inline AngleDeg OpponentAbsoluteBodyAngle    (Unum n) { return PlayerAbsoluteBodyAngle    (TheirSide,n); }  inline float    OpponentBodyAngleValid       (Unum n) { return PlayerBodyAngleValid       (TheirSide,n); }  inline AngleDeg OpponentAbsoluteNeckAngle    (Unum n) { return PlayerAbsoluteNeckAngle    (TheirSide,n); }  inline float    OpponentNeckAngleValid       (Unum n) { return PlayerNeckAngleValid       (TheirSide,n); }  /* more complex shortcuts */  /* kickable for other players */  Bool BallKickableForPlayer(char s, Unum n, float buffer=0);  inline Bool BallKickableForTeammate(Unum n, float buffer=0)     { return BallKickableForPlayer(MySide, n, buffer); }  inline Bool BallKickableForOpponent(Unum n, float buffer=0)     { return BallKickableForPlayer(TheirSide, n, buffer); }  inline Bool CanFaceBallWithNeck()    { return CanFaceAngleFromBodyWithNeck(BallAngleFromBody()); }  inline Bool CanFacePlayerWithNeck(char s, Unum n)    { return CanFaceAngleFromBodyWithNeck(PlayerAngleFromBody(s,n)); }  inline Bool CanFaceTeammateWithNeck(Unum n)    { return CanFaceAngleFromBodyWithNeck(TeammateAngleFromBody(n)); }  inline Bool CanFaceOpponentWithNeck(Unum n)    { return CanFaceAngleFromBodyWithNeck(OpponentAngleFromBody(n)); }  inline Bool CanSeeBallWithNeck()    { return CanSeeAngleFromBodyWithNeck(BallAngleFromBody()); }  inline Bool CanSeePlayerWithNeck(char s, Unum n)    { return CanSeeAngleFromBodyWithNeck(PlayerAngleFromBody(s,n)); }  inline Bool CanSeeTeammateWithNeck(Unum n)    { return CanSeeAngleFromBodyWithNeck(TeammateAngleFromBody(n)); }  inline Bool CanSeeOpponentWithNeck(Unum n)    { return CanSeeAngleFromBodyWithNeck(OpponentAngleFromBody(n)); }  /* is player behind us */  /* three forms for third arg:     angle: absolute angle indicating the front     Vector: position whose direction indicates the front     none: use MyAng */  /* is point behind us */  /* three forms for third arg:     angle: absolute angle indicating the front     Vector: position whose direction indicates the front     none: use MyAng */  inline Bool IsPointBehind(Vector pt, AngleDeg ang)    {      return (fabs(GetNormalizeAngleDeg(AngleToFromBody(pt) + MyBodyAng() - ang)) > CP_behind_angle)	? TRUE : FALSE;          }  inline Bool IsPointBehind(Vector pt, Vector targPos)    {      return IsPointBehind(pt, (targPos - MyPos()).dir());    }  inline Bool IsPointBehindBody(Vector pt)    {      return (fabs(AngleToFromBody(pt)) > CP_behind_angle)	? TRUE : FALSE;    }  inline Bool IsPointBehindNeck(Vector pt)    {      return (fabs(AngleToFromNeck(pt)) > CP_behind_angle)	? TRUE : FALSE;    }  inline Bool IsPlayerBehind(char s, Unum n, AngleDeg ang)    {            if (!PlayerPositionValid(s, n))	my_error("Can't tell if player is behind if I don't know where he is");      return (fabs(PlayerAngleFromBody(s, n) + MyBodyAng() - ang) > CP_behind_angle)	? TRUE : FALSE;    }  inline Bool IsPlayerBehind(char s, Unum n, Vector targPos)    {      return IsPlayerBehind(s, n, (targPos - MyPos()).dir());    }  inline Bool IsPlayerBehindFromBody(char s, Unum n)    {      if (!PlayerPositionValid(s, n))	my_error("Can't tell if player is behind if I don't know where he is");      return (fabs(PlayerAngleFromBody(s, n)) > CP_behind_angle)	? TRUE : FALSE;    }  inline Bool IsPlayerBehindFromNeck(char s, Unum n)    {      if (!PlayerPositionValid(s, n))	my_error("Can't tell if player is behind if I don't know where he is");      return (fabs(PlayerAngleFromNeck(s, n)) > CP_behind_angle)	? TRUE : FALSE;    }  inline Bool IsTeammateBehind(Unum n, AngleDeg ang)    { return IsPlayerBehind(MySide, n, ang); }  inline Bool IsTeammateBehind(Unum n, Vector targPos)    { return IsPlayerBehind(MySide, n, targPos); }  inline Bool IsTeammateBehindFromBody(Unum n)    { return IsPlayerBehindFromBody(MySide, n); }  inline Bool IsTeammateBehindFromNeck(Unum n)    { return IsPlayerBehindFromNeck(MySide, n); }    inline Bool IsOpponentBehind(Unum n, AngleDeg ang)    { return IsPlayerBehind(TheirSide, n, ang); }  inline Bool IsOpponentBehind(Unum n, Vector targPos)    { return IsPlayerBehind(TheirSide, n, targPos); }  inline Bool IsOpponentBehindFromBody(Unum n)    { return IsPlayerBehindFromBody(TheirSide, n); }  inline Bool IsOpponentBehindFromNeck(Unum n)    { return IsPlayerBehindFromNeck(TheirSide, n); }      /* Relative markers */  MarkerType RM_My_Goal;  MarkerType RM_Their_Goal;  MarkerType RM_LB_Flag;  MarkerType RM_LC_Flag;  MarkerType RM_LF_Flag;  MarkerType RM_RB_Flag;  MarkerType RM_RC_Flag;  MarkerType RM_RF_Flag;  MarkerType RM_My_PC_Flag;    /* Center of my penalty area */  MarkerType RM_Their_PC_Flag; /* Center of theirs          */  /* predicted positions */  Vector BallPredictedPosition(int steps, float kick_power, AngleDeg kick_dir);  Vector BallPredictedPositionWithQueuedActions(int steps = 1);  inline Vector BallPredictedPosition(int steps = 1)     { return GetBall()->estimate_future_pos(steps); }  inline Vector PlayerPredictedPosition(char side, Unum num, int steps = 1, Vector dash_per=Vector(0,0))    { return GetPlayer(side,num)->estimate_future_pos(steps, 0, dash_per); }  inline Vector TeammatePredictedPosition(Unum num, int steps = 1, Vector dash_per=Vector(0,0))     { return PlayerPredictedPosition(MySide,num,steps, dash_per); }  inline Vector OpponentPredictedPosition(Unum num, int steps = 1, Vector dash_per=Vector(0,0))     { return PlayerPredictedPosition(TheirSide,num,steps, dash_per); }  Bool BallWillBeKickable(int steps = 1, float dash_power = 0, float buffer = 0);  Bool WillKickBeCollision(float kick_power, AngleDeg kick_dir, float buffer = 0)     { return ((BallPredictedPosition(1, kick_power, kick_dir) - MyPredictedPosition()).mod() <= 	      SP_player_size + SP_ball_size + buffer)  ? TRUE : FALSE;  }   Bool WillDashBeCollision(float dash_power, float buffer = 0)     { return ((BallPredictedPosition() - MyPredictedPosition(1, dash_power)).mod() <=           SP_player_size + SP_ball_size + buffer) ? TRUE : FALSE;  }   /* PredictedCyclesToPoint */  /* a buffer of 0 is a bad idea! */  int PlayerPredictedCyclesToPoint(char side, Unum num, Vector pt,				   float dash_power, float buffer);  int PlayerPredictedCyclesToPoint(char side, Unum num, Vector pt, float dash_power)    { return PlayerPredictedCyclesToPoint(side, num, pt, dash_power, CP_at_point_buffer); }  int PlayerPredictedCyclesToPoint(char side, Unum num, Vector pt)    { return PlayerPredictedCyclesToPoint(side, num, pt, SP_max_power); }  int TeammatePredictedCyclesToPoint(Unum num, Vector pt, float dash_power, float buffer)    { return PlayerPredictedCyclesToPoint(MySide, num, pt, dash_power, buffer); }  int TeammatePredictedCyclesToPoint(Unum num, Vector pt, float dash_power)    { return PlayerPredictedCyclesToPoint(MySide, num, pt, dash_power); }  int TeammatePredictedCyclesToPoint(Unum num, Vector pt)    { return PlayerPredictedCyclesToPoint(MySide, num, pt); }  int OpponentPredictedCyclesToPoint(Unum num, Vector pt, float dash_power, float buffer)    { return PlayerPredictedCyclesToPoint(TheirSide, num, pt, dash_power, buffer); }  int OpponentPredictedCyclesToPoint(Unum num, Vector pt, float dash_power)    { return PlayerPredictedCyclesToPoint(TheirSide, num, pt, dash_power); }  int OpponentPredictedCyclesToPoint(Unum num, Vector pt)    { return PlayerPredictedCyclesToPoint(TheirSide, num, pt); }    Unum PlayerWithBall(float buffer=0);    /* with ball means actually kickable      */  Unum TeammateWithBall(float buffer=0);    Unum OpponentWithBall(float buffer=0);    char TeamWithBall(float buffer=0);       /* Direct access functions */  inline StationaryObject *GetMarker(MarkerType m) { return &Marker[m]; }  inline BallObject *GetBall() { return &Ball; }  inline PlayerObject **Teammates() { return MyPlayer; }  inline PlayerObject **Opponents() { return TheirPlayer; }  inline PlayerObject **TeamlessPlayers() { return TeamlessPlayer; }  inline int NumTeammates() { return num_my_players; }  inline int NumOpponents() { return num_their_players; }  inline int NumTeamlessPlayers()  { return num_teamless_players; }  inline int NumPlayers()   { return num_my_players + num_their_players + num_teamless_players; }  PlayerObject *GetTeammate(Unum num);  PlayerObject *GetOpponent(Unum num);  PlayerObject *GetPlayer(char side, Unum num);  /* Player data-structure management */  PlayerObject *GetNewPlayer(char side, Unum num);  Bool         ForgetAPlayer(char side);  void         CleanMyPlayers();  void         CleanTheirPlayers();  void         CleanTeamlessPlayers();  void         CleanAllPlayers();  Bool         ResetMyDuplicatePlayers();  Bool         ResetTheirDuplicatePlayers();  void         ClearSeenInfo();  MarkerType ClosestMarker;  MarkerType ClosestMotionMarker;  MarkerType ClosestGoal();  MarkerType ClosestFlagTo();    int SortPlayersBy(char side, char keyFunc, float keyNum, Unum* players);                                    /* side = m,t,b (both) keyFunc = d,a				       (dist/ang), keyNum = central val.				       players = array.  Return num found */  int SortPlayersByDistanceToPoint(char side, Vector point, Unum* players);  int SortPlayersByDistanceToLine(char side, Line line, Unum* players, 				  Bool TestEndPoints=FALSE, Vector ep1=0, Vector ep2=0);  int NumTeammatesWithin(float Dist, Vector of_pos);  inline int NumTeammatesWithin(float Dist)     { if (!MyConf()) my_error("nope"); return NumTeammatesWithin(Dist, MyPos()); }  int NumOpponentsWithin(float Dist, Vector of_pos);  inline int NumOpponentsWithin(float Dist)     { if (!MyConf()) my_error("nope"); return NumOpponentsWithin(Dist, MyPos()); }  inline int NumPlayersWithin(float Dist, Vector of_pos)    { return NumTeammatesWithin(Dist,of_pos) +  NumOpponentsWithin(Dist,of_pos); }  inline int NumPlayersWithin(float Dist)       { if (!MyConf()) my_error("nope"); return NumPlayersWithin(Dist,MyPos()); }  /* These are needed for the Decision Tree, Dodge player -- use dist and ang */  int NumTeammatesWithin(float Dist, AngleDeg Ang, float ofDist, AngleDeg ofAng);  inline int NumTeammatesWithin(float Dist, AngleDeg Ang) {return NumTeammatesWithin(Dist, Ang, 0, 0);}  int NumOpponentsWithin(float Dist, AngleDeg Ang, float ofDist, AngleDeg ofAng);  inline int NumOpponentsWithin(float Dist, AngleDeg Ang) {return NumOpponentsWithin(Dist, Ang, 0, 0);}  inline int NumPlayersWithin  (float Dist, AngleDeg Ang, float ofDist, AngleDeg ofAng)    { return NumTeammatesWithin(Dist,Ang,ofDist,ofAng) +  NumOpponentsWithin(Dist,Ang,ofDist,ofAng); }  inline int NumPlayersWithin(float Dist, AngleDeg Ang)   {return NumPlayersWithin(Dist, Ang, 0, 0);}  PlayerObject *GetPlayerWithin(float Dist, Vector ofPos);  PlayerObject *GetPlayerWithin(float Dist, AngleDeg Ang, float ofDist, AngleDeg ofAng);  int NumOpponentsInCone(float wid_dist_ratio, Vector end, Vector vert);

⌨️ 快捷键说明

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