1. Anywhere where me_p is called, it is first initialized to something sane at the beginning of that function. Dunno if this is necessary, but it doesn't hurt. This is not what you are doing. You are defining a new local variable called me_p that is overriding the global one. Bad coding style. If me_p is getting called before it is initialized in socket.c, you should figure out why and fix it. 2. Anywhere where me_p->closest_pl or p->closest_pl is NULL'd out, I re-wrote the code so it leaves it alone. p->closest_pl = NULL. For some reason, once this is done, closest_pl stays NULL for the rest of the program until you kill the program and restart it. It's clear that setting closest_pl to NULL means something, that the player isn't near a planet. Setting it to some random planet will just make the bot make mistakes. What would be the correct thing to do, would be to fix the bug in closest_planet() that makes it fail, rather than just making random changes with no clue what effect they will have. BTW, the bug in closest_planet can fix be fixed thusly: --- update_players.c.old Wed May 17 20:52:41 2006 +++ update_players.c Wed May 17 20:50:11 2006 @@ -1320,7 +1320,7 @@ { register k; - register struct planet *pl, *rp = NULL; + register struct planet *pl, *rp = opl; register d, mdist = INT_MAX; if(opl && (mdist = ihypot((double)(j->p_x - opl->pl_x), Sorry, I'm too lazy to install yet another revision control system. 3. Replaced all instances of mfprintf with regular fprintf. mfprintf causes SIGSEVs, but I don't know why. Function looks fine to me, but it extensively uses parameter overlloading, it's tough to debug. So just don't use it!!! It probably has to do with it using varargs instead of stdargs. You should convert it to stdargs. 4. Added some code somewhere to check "pl" is good. Every once in a while, this turns into NULL for unknown reasons. The situation clears itself after a while. Again, find out why it's set to NULL, and fix that.