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

📄 brucelee.h

📁 该文件是包含了机器人足球比赛中的整个系统的代码
💻 H
字号:
#ifndef BruceLee_H
#define BruceLee_H

#include "Dude.h"
#include "../TOOLS/Utilities.h"
#include "../TOOLS/KickSelecta.h"


class BruceLee : public Dude {
public:
	BruceLee();
  ~BruceLee();

	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:
  void RunCaptain();
  void MovePlayer(int currentPosition, int newPosition);
  bool isTeamOnOffense;
  byte robotPosition[4]; // links botid-1 ---> positions (as in, the enum above)
  bool isCaptain;

  double lastBallDistance;

  bool IsBallVisible();
  bool IsBallWithinChaseBounds();
  bool IsBallWithinNonEnlargedChaseBounds();
  bool IsSelfWithinChaseBounds();
  bool IsAnybodyChasing();
  bool IsChasePaused();
  bool AmIAllowedToChase(double);
  int WhoIsChasing();
  int WhoIsClosestToBall();
  int WhoIsClosestToBallIncludingMe();
  double ClosestToBall();
  void AllocatePositions(int notThisId, int position1, int position2);
  void OneInchPunch();
  void CheckWireless();
  
  bool inPlaying;
  bool inGoHome;
  Utilities utils;
  KickSelecta ks;

  bool debugOutput;
  bool oneInchPunch;

  int chaseUpperX;
  int chaseUpperY;
  int chaseLowerX;
  int chaseLowerY;

  int boundOffset;

  double actualHomeX;
  double actualHomeY;
  int homeX;
  int homeY;
  int homeRadius;
  int homeErrorDistance;

  bool chasePaused;
  long pauseChaseUntil;

  int offensiveSwitchY;
  int defensiveSwitchY;

  long lastSwitchTime;
  
  long timeOfLastChase;
  bool keeperRoaming;

  long watchingBallCounter;
  bool lastLookedLeft;

  signed char myPosition;
  long lastReceivedTime[4];
  RobotRegion robotRegions[NUM_POSITIONS];
  NormalMessage othersNormal[4];
  CaptainMessage othersCaptain;

  char* previousTrick;
  long previousTrickFrame;
};

#endif // BruceLee_H

⌨️ 快捷键说明

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