求助!机器人足球
这是三v三的,现在的主流.#ifndef strategy_h #define strategy_h // the following ifdef block ** the standard way of creating macros which make exporting // from a dll simpler. all files within th** dll are compiled with the strategy_exports // symbol defined on the command line. th** symbol should not be defined on any project // that uses th** dll. th** way any other project whose source files include th** file see // strategy_api functions as being imported from a dll, wheras th** dll sees symbols // defined with th** 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; // 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; // who**all 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; //field top y coordinate const double fbot = 6.3730; //field bottom y coordinate const double gtopy = 49.6801; //goal top y coordinate const double gboty = 33.9320; //goal bottom coordinate const double gright = 97.3632; //right goal bach coordinate const double gleft = 2.8748; //left goal back coordinate const double frightx = 93.4259; //field right x coordinate const double fleftx = 6.8118; //field left x coordinate const double offset=4.5; int max; int min; int mid1; int mid2; int min1,min2; int old_role; int area1,area2; double rb_d**[5]; double rb_time[5]; double rb_angle[5]; double toffset1; double d**[6]; typedef struct //机器人坐标 { double x, y, z; } vector3d; typedef struct { double x, y; } vector2d; 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 { double x,y; } point; typedef struct //环境结构变量中边界的定义 { double left, right, top, bottom; //边界信息 } bounds1; typedef struct //环境信息模型 { robot home[players_per_side]; //本方机器人数据 opponentrobot opponent[players_per_side]; //对方机器人数据 ball currentball, lastball, predictedball; //球的数据 bounds fieldbounds, goalbounds; //场地信息 long gamestate; //比赛状态 long who**all; //控球方 void *userdata; //用户数据 } environment; int flaghome1home2; typedef void (*mystrategyproc)(environment*); /* must be implemented */ extern "c" strategy_api void create ( environment *env ); // 比赛开始时系统调用,用于出市话用户定义的一些数据 extern "c" strategy_api void strategy ( environment *env );//比赛过程中系统调用,每秒调用60次,**周期为1/60秒 extern "c" strategy_api void destroy ( environment *env ); // 比赛结束后系统调用,释放空间 /* 全局指针env:数据的输入和输出均要对改变量进行操作,实现**环境与代码之间的通信,例如:要想获 得1号机器人的坐标,只需读取env->home[1].pos即可;设置一号机器人的轮速,只需对env->home[1].velocityleft, env->home[1].velocityright修改 */ #endif // strategy_h 20210311