poj 2729.Robocode

Robocode
#include
#include

const int MAX_TANK=10;
const int MAX_COMMAND=1000;
const int MAX_SHOT=1000;
const int SCALE=6;
const int MAX_X=13+(SCALE-1)*12;
const int MAX_Y=13+(SCALE-1)*12;

struct Tank{
	char name[16];
	int x, y;
	int face;
	int exist;
	int move;
};
struct Shot{
	int x, y;
	int face;
	int exist;
};
struct Command{
	int time;
	char tankName[16];
	char type[16];
	int angle;
};
int N, M;
Tank tanks[MAX_TANK];
Shot shots[MAX_SHOT];
Command cmds[MAX_COMMAND];
int tanksMap[MAX_X][MAX_Y];
int shotsMap[MAX_X][MAX_Y];

int main()
{
	char winTankName[16];
	int i, j, k;
	
	while(cin>>N>>M&&!(N==0&&M==0)){
		//读入坦克和命令数据.得到坦克集合和它们在战场上的分布情况. 
		for(i=0;i>tanks[i].name>>tanks[i].x>>tanks[i].y>>tanks[i].face;
			tanks[i].x=tanks[i].x*SCALE/10;
			tanks[i].y=tanks[i].y*SCALE/10;
			tanksMap[tanks[i].x][tanks[i].y]=i;
			tanks[i].exist=1;
			tanks[i].move=0;
		}
		for(i=0;i>cmds[i].time>>cmds[i].tankName>>cmds[i].type;
			if(strcmp(cmds[i].type,"TURN")==0){
				cin>>cmds[i].angle;
			}
			cmds[i].time*=SCALE;
		}
		
		//模拟战斗过程
		int totalShots=0;
		int curCmdInd=0;
		int t=0;
		while(true){
			//得到当前时刻战场上炮弹分布.
			for(i=0;i=0){
						tanks[i].x--;
					}
					else if(tanks[i].face==90&&tanks[i].y-1>=0){
						tanks[i].y--;
					}
					tanksMap[tanks[i].x][tanks[i].y]=i;
				}
			} 
			//判断战斗是否结束
			if(curCmdInd==M){
				int end=1;
				for(i=0;i

你可能感兴趣的:(poj)