📄 sleek.h
字号:
#ifndef Sleek_H
#define Sleek_H
#include "Dude.h"
#include "../TOOLS/Utilities.h"
#include "../TOOLS/KickSelecta.h"
class Sleek : public Dude {
public:
Sleek();
~Sleek();
virtual void NewReadyModel();
virtual void NewPlayingModel();
virtual void NewGoHomeModel();
// NOTE !!!!!!
// the first few entries in this struct should be *identical* to NormalMessage. All the extras
// should go AFTER. This is important. Don't screw it up.
struct CaptainMessage {
bool chasing; //1
double distance; // 4
signed char position[4]; // 4
short upperX[4]; // 8
short upperY[4]; // 8
short lowerX[4]; // 8
short lowerY[4]; // 8
short homeX[4]; // 8
short homeY[4]; // 8
};
struct NormalMessage {
bool chasing; //1
double distance; // 4
};
struct RobotRegion {
int upperX;
int upperY;
int lowerX;
int lowerY;
int homeX;
int homeY;
};
enum {
BL_GOALKEEPER = 0,
BL_LEFTSTRIKER = 1,
BL_RIGHTSTRIKER = 2,
BL_LEFTDEFENDER = 3,
BL_RIGHTDEFENDER = 4,
BL_CENTRESTRIKER = 5,
BL_CENTREDEFENDER = 6,
NUM_POSITIONS = 7
};
private:
// Big calculations
void CalculateHomePosition();
double CalculateBallDistance();
// semi-trivial helper methods:
bool SearchForBall() { if (strcmp(currentTrick->GetName(),"SearchForBall")==0) return true; return false; }
bool MoveToPoint() { if (strcmp(currentTrick->GetName(),"MoveToPoint")==0) return true; return false; }
bool Chase() { if (strcmp(currentTrick->GetName(),"AdvancedChaseWithKick")==0 || strcmp(currentTrick->GetName(),"ChaseWithKick")==0) return true; return false; }
bool InterruptibleChase() { if (Chase() && strcmp(currentTrick->GetErrorMsg(currentTrickResult),"INTERRUPTIBLE")==0) return true; return false; }
bool NonInterruptibleChase() { if (Chase() && strcmp(currentTrick->GetErrorMsg(currentTrickResult),"INTERRUPTIBLE")!=0) return true; return false; }
bool PostChaseSearchForBall() { if (strcmp(currentTrick->GetName(),"AdvancedChaseWithKick")==0 && strcmp(currentTrick->GetCurrentTrick()->GetName(),"PostChaseSearchForBall")==0) return true; return false; }
bool IsBallVisible(); // can WE see the ball ?
bool IsBallVisibleTeam(); // can ANYBODY see the ball ?
bool IsBallVisibleTeamNotSelf(); // can anybody except me see the ball ?
bool IsBallWithinChaseBounds();
bool IsBallWithinEnlargedChaseBounds();
bool IsSelfWithinChaseBounds();
bool AmIAllowedToChase(double);
int WhoIsClosestToBall();
double ClosestToBallNotSelf();
Trick* ConstructMoveToPointHead();
// Captain code
void MovePlayer(int currentPosition, int newPosition);
void AllocatePositions(int notThisId, int position1, int position2);
void RunCaptain();
// Wireless code
void CheckWireless();
Utilities utils;
bool inPlaying;
bool inGoHome;
bool debugOutput;
bool oneInchPunch;
int currentTrickResult;
double lastBallDistance;
double actualHomeX; // includes correction for where the ball currenty is
double actualHomeY;
int homeX; // home x determined by our captain
int homeY;
int homeRadius;
int homeErrorDistance;
int boundOffset;
long timeOfLastChase;
bool keeperRoaming;
long watchingBallCounter;
bool lastLookedLeft;
// wireless / captain variables
byte robotPosition[4]; // links botid-1 ---> positions (as in, the enum above)
bool isCaptain;
long lastSwitchTime;
signed char myPosition;
long lastReceivedTime[4];
RobotRegion robotRegions[NUM_POSITIONS];
NormalMessage othersNormal[4];
CaptainMessage othersCaptain;
int chaseUpperX;
int chaseUpperY;
int chaseLowerX;
int chaseLowerY;
// going home
double xPosition;
double yPosition;
double headingDeg;
double kickLeft;
// used for debugging only
char* previousTrick;
long previousTrickFrame;
bool nonStopSearch;
};
#endif // Sleek_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -