📄 interface.cpp
字号:
/**************************************************************************** 文件名称:Interface.cpp
* 摘 要:该文件部分或全部实现了Interface.h中所声明的函数。
*
* 当前版本:2.0
* 作 者:Moon, Dr Jun Jo, 李迅
* 完成日期:2005年10月24日
***************************************************************************/
#include <windows.h>
#include <cmath>
#include <cstdlib>
#include "Interface.h"
#include "Strategy.h"
char TeamPath[MAX_PATH]; // 策略所在路径"c:\strategy\yellow\" 或者 "c:\strategy\blue\"
// dll主函数
BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
// 取得dll程序所在的路径
GetModuleFileName((HMODULE)hModule, TeamPath, MAX_PATH);
return TRUE;
}
// 定义策略对象
Strategys s;
extern "C" __declspec(dllexport) void Create ( Environment &env )
{
for(int i = 0; i< MAX_PATH; i++)
{
// 判断本程序是处在黄队还是蓝队
if(( TeamPath[i+0] == 'y' || TeamPath[i+0] == 'Y')
&&(TeamPath[i+1] == 'e' || TeamPath[i+1] == 'E')
&&(TeamPath[i+2] == 'l' || TeamPath[i+2] == 'L')
&&(TeamPath[i+3] == 'l' || TeamPath[i+3] == 'L')
&&(TeamPath[i+4] == 'o' || TeamPath[i+4] == 'O')
&&(TeamPath[i+5] == 'w' || TeamPath[i+5] == 'W')
&&(TeamPath[i+6] == '\\'))
{
s.ourside = YELLOW_TEAM;
break;
}
s.ourside = BLUE_TEAM;
}
}
// 连接服务器时最先(在服务器上点击"send"后)执行的函数(执行一次)
extern "C" __declspec(dllexport) void Destroy ( Environment &env )
{
}
// 退出仿真程序前最后执行的一个函数(执行一次)
extern "C" __declspec(dllexport) void Strategy ( Environment &env )
{
// 策略对象初始化
s.initializtion(env);
switch (env.gameState)
{
case FREE_BALL:
s.FreeBall();
break;
case PLACE_KICK:
s.PlaceKick();
break;
case PENALTY_KICK:
s.PenaltyKick();
break;
case FREE_KICK:
s.FreeKick();
break;
case GOAL_KICK:
s.GoalKick();
break;
case NORMAL:
s.Normal();
break;
}
// 给服务器发送本周期数据(机器人轮速)
s.sendDataToServer(env);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -