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

📄 strategy.h

📁 FIRA机器人足球比赛5V5仿真组的一般的防守策略
💻 H
字号:
#ifndef Strategy_H
#define Strategy_H
// 下面的ifdef程序块是一种标准的方法生成用于接口的宏指令
// 通过一个简单的dll.所有的文件将在这个dll里面被编译与STRATEGY_EXPORTS
// 符号被定以在命令行。这个符号不能被定以在任何工程里面
// STRATEGY_API函数将从从一个dll输入,这个dll在任何地方都将能用这些符号
// 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



//宏定义是动态连接库
#define STRATEGY_API __declspec(dllexport)

#include <string.h>
#include <stdio.h>
#include <math.h>
#include <windows.h>



const long PLAYERS_PER_SIDE = 5;

//数据的精确度只有	0.1
// 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 FRIGHT = 93.4259;
const double FLEFT = 6.8118;
const double FRIGHTX = 93.4259;
const double FLEFTX = 6.8118;
const double CORRECTX = 0;//-2.942073;			//修正  坐标转换时的  偏差
const double CORRECTY = 0;//-6.283795;

//const double GTOP = 51.148312;
const double GTOP = 49.6801;				
const double GBOT = 33.9320;				
const double GTOPY = 49.6801;				
const double GBOTY = 33.9320;				
const double GRIGHT = 85.3632;
const double GLEFT = 15.8748;

const double GBRIGHT = 97.3632;			//右边球网
const double GBLEFT = 2.8748;
const double GBTOP = 49.652424;
const double GBBOT = 33.517822;
const double RIGHTG = 79.339401;				//禁区
const double LEFTG = 21.299461;
const double BOTG = 25.875967;
const double TOPG = 57.212448;

const double FREELEFT = 29.262907;			//自由球
const double FREERIGHT = 71.798508;
const double FREETOP = 64.454193;
const double FREEBOT = 18.184305;

const double PENALTYRIGHT = 78.329132;		//点球
const double PENALTYLEFT = 22.216028;

const long CAR = 3;							//小车边长 2.95

///角落为 边长 为5 的等腰三角形

//球能到达的边长范围
//黄队测试

const double RLEFT	=	8.44	;
const double RRIGHT	=	91.78	;
const double RTOP	=	75.59	;
const double RBOT	=	8.04	;

const double RRIGHTGRIT	=	95.75	;
const double RRIGHTGLFT	=	85.88	;
const double RLEFTGLFT	=	4.52	;
const double RLEFTGRIT	=	15.27	;

const double RGTOP	=	53.05	;
const double RGBOT	=	30.44	;

const double RJINQUTOP	=	58.67	;
const double RLEFTJINQURIT	=	22.89	;
const double RRIGHTJINQULFT	=	77.92	;
const double RJINQUBOT	=	24.33	;

const double CORNERLEFT	=	13.13	;
const double CORNERRIT	=	87.76	;
const double CORNERTOP	=	71.24	;
const double CORNERBOT	=	12.85	;

const double ROBOTWITH	=	3.14	;
const double BALLWITH	=	1.5	;
//球能到大的范围
const double BLEFT	=	7.77	;
const double BRIGHT	=	92.46	;
const double BTOP	=	76.29	;
const double BBOT	=	7.35	;
//

//////////////////////MANY CONST NUMBERS
const double SPEED_TANGENT = 0.81;
const double SPEED_NORMAL = 0.27;

const double SPEED_A=0.060;
const double SPEED_B=0.015222305;


const double ANGLE_A=0.273575;
const double ANGLE_B=0.534262;
const double ANGLE_K=0.000294678;




////////////////////////MANY CONST NUMBERS

///以下参数 用在分区上 

const double X1= 7;		
const double X2= 21;
const double X3= 51.0;
const double X4= 80.0;
const double X5= 97.0;
const double X6= 0.0;

const double Y1= 6;
const double Y2= 25.0;
const double Y3= 40.0;
const double Y4= 55.0;
const double Y5= 77.0;
const double Y6= 0.0;
///分区参数


typedef struct
{
	double x, y, z;
} Vector3D;

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
{
	Robot home[PLAYERS_PER_SIDE];
	OpponentRobot opponent[PLAYERS_PER_SIDE];
	Ball currentBall, lastBall, predictedBall;
	Bounds fieldBounds, goalBounds;
	long gameState;	//0,1,2,3,4,5
	long whoseBall; //0,1,2
	void *userData;
} Environment;

typedef struct
{
	Vector3D myoldpos[PLAYERS_PER_SIDE];	//记录 我方 队员的旧坐标,方向
	Vector3D myspeed[PLAYERS_PER_SIDE];		//纪录 我方 队员的速度,跑位的方向
	Vector3D myoldvelocity[PLAYERS_PER_SIDE];		//纪录 我方 队员上次驱动力

	Vector3D opoldpos[PLAYERS_PER_SIDE];	//记录 对方 队员的旧坐标,方向
	Vector3D opspeed[PLAYERS_PER_SIDE];		//纪录 对方 队员的速度,跑位的方向

	Robot robot[PLAYERS_PER_SIDE];			// 我方 球员
	OpponentRobot opp[PLAYERS_PER_SIDE];			// 对方 球员

	Vector3D oldball;							//纪录球 过去 的坐标
	Vector3D curball;							//纪录球 现在 的坐标
	Vector3D preball;							//纪录球 预测 的坐标
	Vector3D ballspeed;							//纪录球 速度 的坐标


    long time[2];							// time[1]取样周期 & time[0]取样次数
	bool mygrand;							//是 黄队  ??
	bool locked;							//判断了 场地	
	int ballArea;							//分区 专用函数int checkball();
	int bgoalball;							//球门球

	int nfreeball;							//自由球

	int nplaceball;

	int npenaltyball;						//点对方
	int chooserobot;		//还没有选择了点球队员吗??	
	int mainrobot;	//主发						//发对方点球时的几个队员
	int cutrobot;	//包抄
	int slowrobot;	//轻踢
	int defentrobot;
	int oppmainrobot;	//对方主发						
	int oppcutrobot;	//对方包抄
	int oppslowrobot;	//对方轻踢
	int oppdefentrobot; //对方防守
	

	int goalie;


	long gameState;	//0,1,2,3,4,5
	long whoseBall; //0,1,2


	long n;
	bool B_N;				//these two veriaty is for the test funtion!
	//	Bounds field, goal;

	bool debug;								//是 调试 吗??
	FILE * debugfile; 

}Mydata;


extern "C" STRATEGY_API void Create ( Environment *env ); 
extern "C" STRATEGY_API void Strategy ( Environment *env );
extern "C" STRATEGY_API void Destroy ( Environment *env ); 


//以下
const	double InlitializeMyPosition_X[5]={
		10.6663,
		19.9199,
		19.7433,
		39.4618,
		39.8876
	};
const	double InlitializeMyPosition_Y[5]={
		42.3077,
		60.3647,
		22.9943,
		60.3031,
		23.1065
	};
const	double InlitializeMyPosition_Z[5]={
		90,
		0,
		0,
		0,
		0
	};
const	double InlitializeOppPosition_X[5]={
		90.4616,
		82.0921,
		81.2890,
		61.8525,
		61.4469
	};
const	double InlitializeOppPosition_Y[5]={
		42.2002,
		22.9046,
		60.4876,
		23.1527,
		60.3599
	};
const	double InlitializeOppPosition_Z[5]={
		-90,
		180,
		180,
		180,
		180
	};
const double PI = 3.1415926;

const Vector3D CONSTGATE={FRIGHT,(FTOP+FBOT)/2,0};		///zhuyi
const Vector3D TOPGATE={93,72,0};
const Vector3D BOTGATE={93,9,0};

void NormalGame ( Environment *env );
void FreeBallGame(Environment *env);
void PlaceBallGame(Environment *env);
void PenaltyBallGame(Environment *env);
void FreeKickGame(Environment *env);
void GoalKickGame(Environment *env);
void FreeGoalie( Environment* env);
#endif // Strategy_H

⌨️ 快捷键说明

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