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

📄 vcdll.cpp

📁 非常好的机器人足球比赛平台
💻 CPP
字号:
//////////////////////////////////////////////////////////////////////////
// DUT 5vs5 RoboCup Team DLL FrameWork 
// Specified Edition for M$ Visual C++
//
// Please don't modify any definition given by the DUT RoboCup Competition Committee.
// This is not compatible with the server of earlier version.
//
// Technology support e-Mail: guangbincui@gmail.com
//////////////////////////////////////////////////////////////////////////

// 注意:函数体的内容可以根据自己的需要改变
// 例如你在DLL中要使用OOP技术,你完全可以重写初始化和存储部分
// 但是请务必保持所有给定接口(函数)的声明部分

// 另:如果在VC++中出现如下编译问题 
// unexpected end of file while looking for precompiled header directive
// 请在Project->Settings->C/C++->Category->Precompiled Headers页
// 选择Not using precompiled headers

#include <windows.h>
#include "CppConst.h"
#include "vcdll.h"

// 以下两项名称中请勿使用圆括号"("和")"

// 球队的名称,请勿超过10个汉字(20个ASCII字符),否则多余部分会被忽略
#define  CTEAMNAME 	         "球队名字";  
// 作者的姓名,请勿超过7个汉字(14个ASCII字符),否则多余部分会被忽略
#define  CTEAMAUTHORS        "作者名字";  

MatchState		matchState;
RobotState		teamAState[5];
OpsState		teamBState[5];
BallState		ballState;
RobotState		*pMyTeam;
OpsState		*pOpsTeam;
int 			myTeamNo;
bool			bTransform;

BOOL APIENTRY DllMain( HANDLE hModule, 
                       DWORD  ul_reason_for_call, 
                       LPVOID lpReserved
					 )
{
    return TRUE;
}


//////////////////////////////////////////////////////////////////////////
// 初始化球队信息
//////////////////////////////////////////////////////////////////////////
__declspec( dllexport ) void _stdcall initdll(int initTeamNo)
{
	myTeamNo = initTeamNo;
    pMyTeam = teamAState;
	pOpsTeam = teamBState;
	if(1 == initTeamNo) 
    {
		bTransform = false;
	} 
    else 
    {
		bTransform = true;
	}
}

//////////////////////////////////////////////////////////////////////////
// 比赛信息
//////////////////////////////////////////////////////////////////////////
__declspec( dllexport ) void _stdcall tellmatchstate(MatchState ams,
                                                     RobotState atmAs[5], 
													 OpsState atmBs[5], 
                                                     BallState abs)
{
	memcpy(&matchState, &ams, sizeof(MatchState));
	memcpy(teamAState, atmAs, sizeof(RobotState)*5);
	memcpy(teamBState, atmBs, sizeof(OpsState)*5);
	memcpy(&ballState, &abs, sizeof(BallState));	
}

//////////////////////////////////////////////////////////////////////////
// 取得球队的名称
//////////////////////////////////////////////////////////////////////////
__declspec( dllexport ) char* _stdcall teamname()
{
	return CTEAMNAME;
}

//////////////////////////////////////////////////////////////////////////
// 取得球队的作者名
//////////////////////////////////////////////////////////////////////////
__declspec( dllexport ) char* _stdcall teamauthor()
{
	return CTEAMAUTHORS;
}

//////////////////////////////////////////////////////////////////////////
// 设定球员的动作
// 当前此函数代码是随便设置的,球员随机跑动,可踢球时就朝正前方踢
//////////////////////////////////////////////////////////////////////////
__declspec( dllexport ) void _stdcall setaction(TCommand * pMyCMD)
{
	int randNum = rand();

	for (int i = 0 ; i < 5 ; i++ )
	{
		if ((teamAState[i].pos.x-ballState.pos.x)*(teamAState[i].pos.x-ballState.pos.x)
			+(teamAState[i].pos.y-ballState.pos.y)*(teamAState[i].pos.y-ballState.pos.y)
			<= CKICKABLEDIST )
		{
			pMyCMD[i].CommandType = Com_Kick;
			pMyCMD[i].ComParam0   = 0;
			pMyCMD[i].ComParam1   = CMAXPOWER;
		}
		else if (randNum < 5000)
		{
			pMyCMD[i].CommandType = Com_Turn;
			pMyCMD[i].ComParam0 = 10*i;
		}
		else
		{
			pMyCMD[i].CommandType = Com_Dash;
			pMyCMD[i].ComParam0   = CMAXPOWER * 0.5;
		}
	}
}

//////////////////////////////////////////////////////////////////////////
// 退出动态链接库,回收资源
//////////////////////////////////////////////////////////////////////////
__declspec( dllexport ) void _stdcall exitdll()
{
    // 如果有动态分配的内存,请在此释放
}



















⌨️ 快捷键说明

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