📄 formation.h
字号:
inline void SetOnlyActiveIfClosest(int x) { only_active_if_closest = x; } inline float GetMaxActiveDistance() { return MaxActiveDistance; } inline float GetMinInactiveDistance() { return MinInactiveDistance; } inline int OnlyActiveIfClosest() { return only_active_if_closest; } inline int GetType() { return type; } inline int GetSide() { return side; }private: float HomeX; float HomeY; float HomeBuffer; Rectangle *HomeRange; Rectangle *MaxRange; float MinInactiveDistance; /* Stay active if the ball is closer */ float MaxActiveDistance; /* Never active if ball is farther */ int only_active_if_closest; /* If false, always go active if ball is closer than MaxActiveDistance */ int type; int side; };/*************************** UNIT CLASS DEFINITION ************************/#define DEFENSIVE_UNIT 0#define MIDFIELD_UNIT (DEFENSIVE_UNIT+1)#define FORWARD_UNIT (MIDFIELD_UNIT +1)#define LEFT_UNIT (FORWARD_UNIT +1)#define CENTER_UNIT (LEFT_UNIT +1)#define RIGHT_UNIT (CENTER_UNIT +1)class Unit {public: Unit(); ~Unit(); InitializeUnit(int tp, int sz, int *mems, int capt); inline int GetType() { return type; } inline int GetSize() { return size; } inline int GetCaptain() { return captain; } inline int *GetMembers() { return members; } int IsMember(int position); int IsCaptain(int position); int ImportantPosition(int p1, int p2);private: int type; /* defensive, mid, left, center, etc. */ int size; /* number of members */ int *members; /* The POSITIONS in the unit */ int captain; /* The Captain has special privileges */};/************************ FORMATION CLASS DEFINITION **********************/class Formation {public: Formation(int type); ~Formation(); AllocateUnits(int num); inline int GetType() { return type; } void SetPosition(int num, float x, float y, float buffer, float home_width, float home_height, float max_width, float max_height, float max_act_dist, float min_inact_dist, int act_if_closest); TeamPosition *GetPosition(int num); void SetCandidateReceivers(int position, int num, int *PrefList); int *GetCandidateReceivers(int position); Unit *GetUnit(int unit); inline int GetNumUnits() {return NumUnits;} int IsUnitMember(int unit, int position); int IsUnitCaptain(int unit, int position); int IsMoreImportantPosition(int pos1, int pos2);private: int type; TeamPosition PositionList[TEAM_SIZE]; /* A static list of positions: */ /* Shouldn't change once defined */ int ReceiverList[TEAM_SIZE][TEAM_SIZE];/* map position to candidate */ /* receiver positions */ int TempReceiverList[TEAM_SIZE]; /* Used to pass back possible receivers */ int NumUnits; Unit *FormationUnits;};/******************** TEAMPOSITIONINFO CLASS DEFINITION ******************/#define UNKNOWN_POSITION -1#define UNKNOWN_PLAYER -1#define UNKNOWN_FORMATION NULL#define UNKNOWN_FORMATION_TYPE -1#define MARK_OBEY 0#define MARK_CLOSEST (MARK_OBEY+1 )#define MARK_OPEN (MARK_CLOSEST+1)#define HOME_OBEY 0#define HOME_SHIFT (HOME_OBEY+1 )#define HOME_MARK (HOME_SHIFT+1 )#define HOME_MARK_ELSE_SHIFT (HOME_MARK +1 ) /* If I don't have a mark, shift */ class TeamPositionInfo {public: TeamPositionInfo(); ~TeamPositionInfo(); void Reset(); void SetPlayerPosition(int player, int position); void ClearPlayerPosition(int player); void ClearPositionPlayer(int position); void SetMyPosition (int position); void ClearMyPosition(); int PositionOccupied (int position); int LocationToPosition(float x, float y); float DistanceToPositionHome(int position, float x, float y); float PositionHomeX (int position); float PositionHomeY (int position); float PositionHomeBuffer (int position); int PositionType (int position); int PositionSide (int position); Rectangle *PositionHomeRange (int position); Rectangle *PositionMaxRange (int position); float PositionHomeRangeWidth (int position); float PositionHomeRangeHeight(int position); float PositionMaxRangeWidth (int position); float PositionMaxRangeHeight(int position); float PlayerHomeX (int player ); float PlayerHomeY (int player ); float PlayerHomeBuffer (int player ); int PlayerType (int player ); int PlayerSide (int player ); int GetPlayerPosition(int player); int GetPositionPlayer(int position); int GetMyPosition(); float GetMyPositionX(); float GetMyPositionY(); inline void GetMyPositionXY(float *x, float *y) { *x = GetMyPositionX(); *y = GetMyPositionY(); } int GetMyPositionType(); int GetMyPositionSide(); float GetMyPositionBuffer(); Rectangle *GetMyHomeRange(); Rectangle *GetMyMaxRange(); float GetMyHomeRangeWidth(); float GetMyHomeRangeHeight(); float GetMyMaxRangeWidth(); float GetMyMaxRangeHeight(); void PrintMyHomeRange(); void PrintMyMaxRange(); int IsWithinMyHomeRange(float x, float y); int IsWithinMyMaxRange (float x, float y); void ResetCurrentHome(); void SetFormation (int formation_number, int time); inline Formation *GetCurrentFormation() { return CurrentFormation; } inline int GetCurrentFormationType() { return CurrentFormation->GetType(); } inline float GetCurrentHomeX() { return CurrentHomeX; } inline float GetCurrentHomeY() { return CurrentHomeY; } inline int GetMark() { return Mark; } inline float GetMarkBuffer() { return MarkBuffer; } int SetCurrentHome (float x, float y); int SetCurrentHomeX(float x ); int SetCurrentHomeY(float y ); int SetMark (int mark); inline void SetMarkBuffer(float buffer) { MarkBuffer = buffer; } void HearTeammateFormationPosition(int player, int form, int formtime, int pos); int GetUnitSize(int unit); int *GetUnitMembers(int unit); int IsUnitMember(int unit, int player); int IsUnitCaptain(int unit, int player); int IsMyUnit(int unit); int AmUnitCaptain(int unit); int IsMyUnitCaptain(int player); int AmCandidateReceiverOfPlayer(int player); int IsMoreImportantPosition(int pos1, int pos2); /**** Public Variables ***********************************************/ int MarkChangeMethod; /* There might be different ways of */ int PositionChangeMethod; /* deciding who to mark, when to change */ int HomeChangeMethod; /* positions, and where to make home */ int MarkPursuitRange; /* range, max_range, everywhere, etc. */ int PositionStrategy; /* evade, mark, hold home, etc. */ int FormationTime; /* Time the current formation was set */private: float CurrentHomeX; /* These could be different from HomeX and HomeY */ float CurrentHomeY; /* In my position */ int Mark; /* The number of the opponent whom I'm marking */ float MarkBuffer; /* The distance at which I should mark */ int PositionPlayers[TEAM_SIZE+1]; /* Maps positions to their players */ int PlayerPositions[TEAM_SIZE+1]; /* Maps players to their positions */ Formation *CurrentFormation; Formation *f433_Formation; Formation *f442_Formation; Formation *f352_Formation; Formation *f72_Formation; Formation *f334_Formation; Formation *f244_Formation; Formation *f432_Formation; Formation *fRT_Formation; Formation *fLT_Formation;};#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -