Exemplo n.º 1
0
void st03::play(){
	while(getPoint()){
		if(getPoint())increaseHealth();
		if(getPoint())increaseSpeed();
	}
	int d=(~0U>>1),x,y;
	for(int i=1;i<=N;++i)
		for(int j=1;j<=M;++j)
			if(askWhat(i,j)==EMPTY){
				int t1=abs(i-getX())+abs(j-getY());
				if(t1>getSp())continue;
				for(int k=1;k<=N;++k)
					for(int l=1;l<=M;++l)
						if(askWhat(k,l)!=EMPTY){
							int tmp=abs(i-k)+abs(j-l);
							if(tmp<d)d=tmp,x=i,y=j;
						}
			}
	move(x,y);
	for(int i=-1;i<2;++i)
		for(int j=-1;j<2;++j){
			if(i&&j)continue;
			if((!i)&&(!j))continue;
			if(askWhat(x+i,y+j)!=EMPTY){
				attack(x+i,y+j);
				return;
			}
		}
}
Exemplo n.º 2
0
void ch_att::getMap() // Get all infos about the map and the players.
{
	for (int i=1;i<=MAX_PLAYER;i++)
	 if (i!=myID)
	  {
		p[i].status=DEAD;
		p[i].lastx=p[i].x;
		p[i].lasty=p[i].y;
		p[i].x=0;
		p[i].y=0;
		p[i].hp=askHP(i);
	  }
	for (int i=1,dis,id;i<=N;i++)
	 for (int j=1;j<=M;j++)
	  {
		g[i][j]=askWhat(i,j);
		if (g[i][j]>EMPTY && g[i][j]!=myID)
		 {
			id=g[i][j];
			p[id].x=i;
			p[id].y=j;
			p[id].status=ALIVE;
			if (p[id].lastx>0)
			 {
				dis=abs1(p[id].lastx-p[id].x)+abs1(p[id].lasty-p[id].y);
				p[id].maxmove=max1(p[id].maxmove,dis);
				p[id].sp=(long)(speedEstimate*p[id].maxmove);
			 }
		 }
	  }
	for (int i=1;i<=MAX_PLAYER;i++)
	 if (i!=myID && p[i].status==DEAD)
	  p[i].dietime++;
}
Exemplo n.º 3
0
void testAI::play()
{
    while(getPoint())
    {
        increaseSpeed();
        increaseStrength();
        increaseHealth();
    }
    int i,j,x,y,flag=0,t1,t2;
    x=getX();
    y=getY();
    for(i=1;i<=N;i++)
    {
        for(j=1;j<=M;j++)
        {
            if(abs(i-x)+abs(j-y)<=getSp())
            {
                if(askWhat(i-1,j)>0 || askWhat(i+1,j)>0 || askWhat(i,j-1)>0 || askWhat(i,j+1)>0)
                {
                    move(i,j);
                    flag=1;
                    break;
                }
                t1=i;t2=j;
            }
        }
        if(flag)break;
    }
    if(!flag)move(t1,t2);
    if(askWhat(i-1,j)>0)
    {
        attack(i-1,j);
        return;
    }
    if(askWhat(i+1,j)>0)
    {
        attack(i+1,j);
        return;
    }
    if(askWhat(i,j-1)>0)
    {
        attack(i,j-1);
        return;
    }
    if(askWhat(i,j+1)>0)
    {
        attack(i,j+1);
        return;
    }

}