Hello,
Is it just me, or the code for war declarations for
the newbie robots is a bit too convoluted?
It seems it is trying to find the enemy team with the
most number of players and declare war on it, and then
declaring peace with everybody else. But it's buggy.
I am thinking about simplifying it to: declare war on
all players not on the robot's team.
Here's a snippet from robotd/update_players.c
declare_intents()
/* war & peace. Done initially */
/* BUGS */
declare_intents()
{
register i;
register struct player *j;
int teams[16], maxt = 0;
int newhostile, pl=0;
extern char *team_to_string();
if(me_p->alive < 100 || !isAlive(me)) /* 10
seconds into game */
return;
if(_state.player_type == PT_OGGER ||
_state.player_type == PT_DOGFIGHTER)
return;
newhostile = me->p_hostile;
bzero(teams, sizeof(teams));
for(i=0, j=players; i<MAXPLAYER; i++,j++) {
if(j->p_status == PFREE) continue;
if(j->p_flags & PFROBOT) continue;
if(me->p_team == j->p_team || j->p_team == 0 ||
j->p_team == ALLTEAM)
continue;
teams[j->p_team]++;
pl++;
}
if(pl){
for(i=1; i< 9; i *= 2)
if(teams[i] > maxt)
maxt = i;
mprintf("max team = %s\n",
team_to_string(maxt));
}
/*
else
maxt = -1;
*/
/* peace */
for(i=1; i< 9; i *= 2){
if(i == maxt) continue;
if((i & me->p_hostile) && !(i & me->p_swar)){
mprintf("declaring peace with %s\n",
team_to_string(i));
newhostile ^= i;
}
}
_state.warteam = maxt;
/* war */
if(maxt != -1){
if(!((maxt & me->p_swar) || (maxt &
me->p_hostile))){
mprintf("declare war with %s\n",
team_to_string(maxt));
newhostile ^= maxt;
}
}
if(newhostile != me->p_hostile)
sendWarReq(newhostile);
}