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

📄 strategysystem.cpp

📁 仿真机器人的经典代码
💻 CPP
字号:
// StrategySystem.cpp: implementation of the CStrategySystem class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "StrategySystem.h"

#include "DecisionMakingx.h"

//#define TEAMCOLOR BLUE_BALL
#define TEAMCOLOR YELLOW_BALL

#define PI 3.14159265358979323846
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CStrategySystem::CStrategySystem()
{
	Initialize();
	
}

CStrategySystem::~CStrategySystem()
{

}

void CStrategySystem::Step(Environment *env)
{
//	envo = env;

	RobotInford Robot[12];

	for (int i=0; i<4; i++)
	{
		Robot[i].x = (env->home [i+1].pos.x - 6.8118) * 2.54;
		Robot[i].y = (env->home [i+1].pos.y - 6.3730) * 2.54;
		Robot[i].theta = env->home [i+1].rotation / 180 * PI;
		
		Robot[i+5].x = (env->opponent [i].pos.x - 6.8118) * 2.54;
		Robot[i+5].y = (env->opponent [i].pos.y - 6.3730) * 2.54;
		Robot[i+5].theta = env->opponent [i].rotation / 180 * PI;
	}
		Robot[4].x = (env->home [0].pos.x - 6.8118) * 2.54;
		Robot[4].y = (env->home [0].pos.y - 6.3730) * 2.54;
		Robot[4].theta = env->home [0].rotation / 180 * PI;
		
		Robot[9].x = (env->opponent [0].pos.x - 6.8118) * 2.54;
		Robot[9].y = (env->opponent [0].pos.y - 6.3730) * 2.54;
		Robot[9].theta = env->opponent [0].rotation / 180 * PI;

	Robot[10].x = (env->currentBall.pos.x - 6.8118) * 2.54 ;
	Robot[10].y = (env->currentBall.pos.y- 6.3730) * 2.54 ;

	
	if (TEAMCOLOR == BLUE_BALL)
	{
		for(i=0;i<11;i++)
		{
			Robot[i].x = 220 - Robot[i].x;
			Robot[i].y = 180 - Robot[i].y;
			Robot[i].theta += PI;
		}
	}


	DEGame mode;
	mode.DEGameMode = Simu5;
	switch (env->gameState)
	{
	case FREE_BALL:
		mode.DEStartMode = FreeBall;
		break;
	case PLACE_KICK:
		mode.DEStartMode = NormalStart;
		break;
	case PENALTY_KICK:
		mode.DEStartMode = PenaltyKick;
		break;
	case FREE_KICK:
		mode.DEStartMode = FreeKick;
		break;
	case GOAL_KICK:
		mode.DEStartMode = GoalKick;
		break;
	default:
		mode.DEStartMode = NormalStart;
		break;
	}


	if (env->whosBall == TEAMCOLOR 
		|| env->whosBall == ANYONES_BALL)
	{
		mode.DEStartState = Attack;
	}
	else
	{
		mode.DEStartState = Defense;
	}


	InitDEG(mode);
	
	Startx(Robot);

	//set the velocity of robots
	for (i=1; i<5; i++)
	{
		env->home[i].velocityLeft = rbV[i].LeftValue;
		env->home[i].velocityRight = rbV[i].RightValue;
	}
	env->home[0].velocityLeft = rbV[5].LeftValue;
	env->home[0].velocityRight = rbV[5].RightValue;
}

⌨️ 快捷键说明

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