📄 strategy.h
字号:
#ifndef Strategy_H
#define Strategy_H
// The following ifdef block is the standard way of creating macros which make exporting
// from a DLL simpler. All files within this DLL are compiled with the STRATEGY_EXPORTS
// symbol defined on the command line. this symbol should not be defined on any project
// that uses this DLL. This way any other project whose source files include this file see
// STRATEGY_API functions as being imported from a DLL, wheras this DLL sees symbols
// defined with this macro as being exported.
#ifdef STRATEGY_EXPORTS
#define STRATEGY_API __declspec(dllexport)
#else
#define STRATEGY_API __declspec(dllimport)
#endif
#include <string.h>
#include <stdio.h>
const long PLAYERS_PER_SIDE = 5;
static int gameStageCounter = 0;
// gameState
const long FREE_BALL = 1;
const long PLACE_KICK = 2;
const long PENALTY_KICK = 3;
const long FREE_KICK = 4;
const long GOAL_KICK = 5;
// whosBall
const long ANYONES_BALL = 0;
const long BLUE_BALL = 1;
const long YELLOW_BALL = 2;
// global variables -- Useful field positions ... maybe???
const double FTOP = 77.2392;
const double FBOT = 6.3730;
const double GTOPY = 49.6801;
const double GBOTY = 33.9320;
const double GRIGHT = 97.3632;
const double GLEFT = 2.8748;
const double FRIGHTX = 93.4259;
const double FLEFTX = 6.8118;
const double CENTERX = (FLEFTX+FRIGHTX)/2;
const double CENTERY = (FTOP+FBOT)/2;
const double OFFSETX = FRIGHTX+FLEFTX;
const double OFFSETY = FTOP+FBOT;
const double GUARD_POS_X= 32.1111;
const double PI = 3.14159265358979;
const double FIELD_WIDTH = (77.2392 - 6.3730);
const double FIELD_LENGTH = (93.4259 - 6.8118);
const double GOAL_LENGTH = (49.6801 - 33.9320);
const double GOAL_WIDTH = 15.0/1.55;
const double DIVISOR_FIELD = 3.0/1.55;
const double OUR_GOAL_POSITION_X= 7.3230;
const double OUR_GOAL_POSITION_Y= 41.6682;
const double MIDDLE_Y = 42.3333;
const double LIMIT_X_HIGH= 10.8;
const double LIMIT_X_LOW= 8.6;
const double LIMIT_Y_HIGH= 50;
const double LIMIT_Y_LOW= 31;
typedef struct
{
double Degree, Radian;
} AngleType;
typedef struct
{
double Left;
double Right;
} Velocity;
typedef struct
{
double x, y, z;
} Vector3D;
const Vector3D HOME_GOAL_CENTER_POSITION = {FLEFTX, CENTERY, 0};
//Vector3D ourGoalPosition={FLEFTX, CENTERY, 0};
typedef struct
{
long left, right, top, bottom;
} Bounds;
typedef struct
{
Vector3D pos;
double rotation;
double velocityLeft, velocityRight;
} Robot;
typedef struct
{
Vector3D pos;
double rotation;
} OpponentRobot;
typedef struct
{
Vector3D pos;
} Ball;
typedef struct entity
{
double distance;
double angle;
} INFO;
//User Structure
typedef struct
{
Vector3D Position;
Vector3D lastPosition;
Velocity MaxVelocity, CalculatedVelocity, LastVelocity;
double RobotStatus;
AngleType Angle;
BOOL BehindBall;
BOOL Possession;
bool ToOppoPathClear;
double GoForBall;
double GoalAngle;
INFO toRobot[5];
INFO toOppo[5];
INFO toBall;
INFO toGoalTop;
INFO toGoalBottom;
INFO toPenaltyPoint;
INFO toGoalCenter;
} UserRobot;
typedef struct
{
Vector3D Position;
double Velocity;
} UserBall;
typedef struct
{
UserBall CurrentBall, LastBall, PredictedBall;
} UserBallData;
typedef struct
{
//User Data
int zoneX;
int zoneY;
int homeGoal;
int oppoGoal;
int upper;
int lower;
int shootArea;
//Role
int attacker;
int support1;
int support2;
int sweeper;
int goalie;
double robotVelocity[5];
double oldX[5];
double oldY[5];
UserRobot HomeRobotData[PLAYERS_PER_SIDE];
UserRobot OpponentRobotData[PLAYERS_PER_SIDE];
UserBallData BallData;
} UserDefStruct;
//End Of User Structure
typedef struct
{
Robot home[PLAYERS_PER_SIDE];
OpponentRobot opponent[PLAYERS_PER_SIDE];
Ball currentBall, lastBall, predictedBall;
Bounds fieldBounds, goalBounds;
long gameState;
long whosBall;
// void *userData;
UserDefStruct *userData;
} Environment;
typedef void (*MyStrategyProc)(Environment*);
/* MUST BE IMPLEMENTED */
extern "C" STRATEGY_API void Create ( Environment *env ); // implement this function to allocate user data and assign to Environment->userData
extern "C" STRATEGY_API void Strategy ( Environment *env );
extern "C" STRATEGY_API void Destroy ( Environment *env ); // implement this function to free user data created in Create (Environment*)
#endif // Strategy_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -