📄 interceptcalculate.h
字号:
/* * Copyright 2002-2005, Mersad Team, Allameh Helli High School (NODET). * * This program is free software, you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * This file is created by: Ahmad Boorghany * * Released on Monday 1 August 2005, 10 Mordad 1384 by Mersad RoboCup Team. * For more information please read README file.*/#ifndef __INTERCEPT_CALCULATE_H#define __INTERCEPT_CALCULATE_H#include <Ball.h>#include <Types.h>#include <Player.h>#define INCA_OUT_DIST 2#define INCA_MIN_DELTA_ANGLE 5#define INCA_MAX_INTERCEPT_TIME 100#define INCA_MAX_PLAYERS 65#define MAX_CHECK_PLAYERS 3#define DEFAULT_SHARE_CYCLES 2class WorldModel;class InterceptPlayer{protected: bool loggingFlag; // Static variables bool kickingFlag; bool blockedFlag; float slowAccel; float fastAccel; float directAccel; float kickableRadius; float posDevDashDist; unsigned seeBallDelay; Player simPlayer; const Player *player; float withTurnVelArchive[INCA_MAX_INTERCEPT_TIME]; float withoutTurnVelArchive[INCA_MAX_INTERCEPT_TIME]; float withTurnDashDistArchive[INCA_MAX_INTERCEPT_TIME]; float withoutTurnDashDistArchive[INCA_MAX_INTERCEPT_TIME]; // Dynamic variables bool catchBallFlag; float *withTurnVel; float *withoutTurnVel; float *withTurnDashDist; float *withoutTurnDashDist; // Result variables bool extraCatchedFlag; unsigned interceptTime; Point interceptPoint;public: InterceptPlayer(); void simulate(); void getReadyToRun(); void checkForExtraCatch(const Ball &ball); void init(const Player &playerArg, const Ball &ball, bool kickingFlagArg, unsigned kickCycles, unsigned seeBallDelayArg, float slowDashPower, float fastDashPower, float directDashPower, float posDevDashDist, bool blockedPlayer = false, bool checkForPenaltyBox = true); void finalizeIntercept(const Ball &ball, unsigned interceptTimeArg); bool isBallKickable(const Ball &ball); bool checkCatchBall(const Ball &ball); // Getting functions bool isLogging() const; bool isKicking() const; bool isBlocked() const; bool isCatchBall() const; bool isExtraCatched() const; float getDashDist() const; float getKickableRadius() const; unsigned getInterTime() const; Point getInterPoint() const; const Player& getPlayer() const; // Setting functions void setLogging(bool loggingFlagArg); void setKicking(bool kickingFlagArg); void setCatchBall(bool catchBallFlagArg); void setExtraCatched(bool extraCatchedFlagArg); void setKickableRadius(float kickableRadiusArg);};class InterceptCalculate{protected: // Starting session variables bool loggingFlag; unsigned kickCycles; unsigned playersNum; unsigned shareCycles; Vector blockedBallVel; InterceptPlayer interceptPlayers[INCA_MAX_PLAYERS]; const Player *kickPlayer; const Player *blockedPlayer; // Two teams properties unsigned kickerSeeBallDelay; float tmmPosDevRate; float tmmSlowDashPower; float tmmFastDashPower; float tmmDirectDashPower; float tmmGoalieDirectDashPower; unsigned tmmSeeBallDelay; unsigned tmmGoalieSeeBallDelay; float oppPosDevRate; float oppSlowDashPower; float oppFastDashPower; float oppDirectDashPower; float oppGoalieDirectDashPower; unsigned oppSeeBallDelay; unsigned oppGoalieSeeBallDelay; // Before running intercepts variables Ball virtualBall; // After running intercepts variables PlayMode playMode; unsigned fastestPlayerNum; unsigned fastestTmmPlayerNum; unsigned fastestOppPlayerNum; unsigned checkedPlayersNum; unsigned fastestCheckedPlayerNum; unsigned fastestTmmCheckedPlayerNum; unsigned fastestOppCheckedPlayerNum; unsigned checkedPlayers[MAX_CHECK_PLAYERS]; void getReadyToRun(); void setBlockedBall(); void simulateVirtualBall(); void finalizeIntercepts(); void prepareSum(); void initTeamsProps();public: void run(); void startSession(unsigned kickCyclesArg = 0, const Player *kickPlayerArg = NULL, const Player *blockedPlayerArg = NULL); void addPlayer(const Player &player, bool kickingBallFlag = false, bool blockedPlayerFlag = false, bool checkForPenaltyBox = true); void updateByWorldModel(const WorldModel *worldModel, bool removeBody = false, bool removeTmm = false, bool removeOpp = false); void logCheckedPlayers() const; void getNearestOppDistDirToFastest(float &dist, float &dir); bool existFastestPlayer() const; bool existFastestTmmPlayer() const; bool existFastestOppPlayer() const; bool isFastestPlayer(const Player &player) const; unsigned getTmmCheckedPlayersNum() const; unsigned getOppCheckedPlayersNum() const; unsigned getCheckedListNum(const Player &Player) const; unsigned getOppPlayersBeforeLine(float x) const; unsigned getOppPlayersBetweenLines(float x1, float x2) const; const Player &getFastestPlayer() const; const Player &getFastestTmmPlayer() const; const Player &getFastestOppPlayer() const; const InterceptPlayer &getFastestInterPlayer() const; const InterceptPlayer &getFastestTmmInterPlayer() const; const InterceptPlayer &getFastestOppInterPlayer() const; const InterceptPlayer &getCheckedInterPlayer(unsigned CheckedNum) const; // Getting functions unsigned getPlayersNum() const; unsigned getFastestPlayerNum() const; unsigned getFastestTmmPlayerNum() const; unsigned getFastestOppPlayerNum() const; unsigned getCheckedPlayersNum() const; unsigned getFastestCheckedPlayerNum() const; unsigned getFastestTmmCheckedPlayerNum() const; unsigned getFastestOppCheckedPlayerNum() const; bool isLogging() const; PlayMode getPlayMode() const; const Ball &getVirtualBall() const; const Player *getKickPlayer() const; // Setting functions void setLogging(bool loggingFlagArg); void setKickCycles(unsigned kickCyclesArg); void setShareCycles(unsigned shareCyclesArg); void setBlockedBallVel(const Vector &blockedBallVelArg); void setKickerSeeBallDelay(unsigned kickerSeeBallDelayArg); void setTmmPosDevRate(float tmmPosDevRateArg); void setTmmSlowDashPower(float tmmSlowDashPowerArg); void setTmmFastDashPower(float tmmFastDashPowerArg); void setTmmDirectDashPower(float tmmDirectDashPowerArg); void setTmmGoalieDirectDashPower(float tmmGoalieDirectDashPowerArg); void setTmmSeeBallDelay(unsigned tmmSeeBallDelayArg); void setTmmGoalieSeeBallDelay(unsigned tmmGoalieSeeBallDelayArg); void setOppPosDevRate(float oppPosDevRateArg); void setOppSlowDashPower(float oppSlowDashPowerArg); void setOppFastDashPower(float oppFastDashPowerArg); void setOppDirectDashPower(float oppDirectDashPowerArg); void setOppGoalieDirectDashPower(float oppGoalieDirectDashPowerArg); void setOppSeeBallDelay(unsigned oppSeeBallDelayArg); void setOppGoalieSeeBallDelay(unsigned oppGoalieSeeBallDelayArg); void setVirtualBall(const Ball &virtualBallArg); InterceptPlayer &setLastInterPlayer();};#endif // __INTERCEPT_CALCULATE_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -