collection.cpp

来自「AI-CODE坦克机器人 《C++语言学习利器 —AI-CODE坦克机器人》-」· C++ 代码 · 共 38 行

CPP
38
字号
#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 + =
减小字号Ctrl + -
显示快捷键?