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

📄 collection.cpp

📁 AI-CODE坦克机器人 《C++语言学习利器 —AI-CODE坦克机器人》-杜飞雪-源代码
💻 CPP
字号:
#include <airobot/cpp/SimpleRobot.hpp>

/**
 * 这个类对应一个机器人,根据需要实现相应的Action处理函数,
 * 就可以订制自己的机器人。
 */
class Collection : public SimpleRobot
{
	private:
		//存储自己的速度值(最多只保存100个数)
		double velocity[100];
		//存储自己的坐标值(最多只保存10轮,每轮最多100个数)
		double x[10][100];
	public:
		/**
		 * 每个单位时间都会触发
		 */
		void onTick(TickAction* action)
		{
			int time = (int)(getTime()%100);
			int round = getCurrentRound()%10;
			
			velocity[time] = getVelocity();
			x[round][time] = getX();
		}
};

/**
 * 机器人程序入口
 */
int main(int argC, char* argV[])
{
	Robot* robot = new Collection();
	return startup(argC, argV, robot);
}


															

⌨️ 快捷键说明

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