Requires Windows, Mac, or Linux
else //AI turns. { Map.cSetter = Nat[Turn-1].NatColor; boolean search = true; while (search = true) //The loop ensures that the claimed zone is empty. The code inside picks the zone. { //Chooses a random empty zone adjacent to the zones already owned by the nation. for (;;) { Map.yZone = (int)(Math.random()*Map.sqrtZoneNumber); Map.xZone = (int)(Math.random()*Map.sqrtZoneNumber); int i = 5*Map.yZone + Map.xZone; if (i==0) //Upper left corner zone. { if (Map.z[i+1].Owner == Nat[Turn-1] || Map.z[i+Map.sqrtZoneNumber].Owner == Nat[Turn-1] && Map.z[Map.yZone*Map.sqrtZoneNumber+Map.xZone].Owner != null && Map.ClaimedZones<Map.ZoneNumber) { search = false; } } else { if (i==Map.sqrtZoneNumber-1) //Upper right corner zone. { if (Map.z[i-1].Owner == Nat[Turn-1] || Map.z[i+Map.sqrtZoneNumber].Owner == Nat[Turn-1] && Map.z[Map.yZone*Map.sqrtZoneNumber+Map.xZone].Owner != null && Map.ClaimedZones<Map.ZoneNumber) { search = false; } } else { if (i==Map.ZoneNumber-Map.sqrtZoneNumber-1) //Lower left corner zone. { if (Map.z[i+1].Owner == Nat[Turn-1] || Map.z[i-Map.sqrtZoneNumber].Owner == Nat[Turn-1] && Map.z[Map.yZone*Map.sqrtZoneNumber+Map.xZone].Owner != null && Map.ClaimedZones<Map.ZoneNumber) { search = false; } } else { if (i==Map.ZoneNumber-1) //Lower right corner zone. { if (Map.z[i-1].Owner == Nat[Turn-1] || Map.z[i-Map.sqrtZoneNumber].Owner == Nat[Turn-1] && Map.z[Map.yZone*Map.sqrtZoneNumber+Map.xZone].Owner != null && Map.ClaimedZones<Map.ZoneNumber) { search = false; } } else { if (i<Map.sqrtZoneNumber) //Top row zones (except corners). { if (Map.z[i-1].Owner == Nat[Turn-1] || Map.z[i+1].Owner == Nat[Turn-1] || Map.z[i+Map.sqrtZoneNumber].Owner == Nat[Turn-1] && Map.z[Map.yZone*Map.sqrtZoneNumber+Map.xZone].Owner != null && Map.ClaimedZones<Map.ZoneNumber) { search = false; } } else { if (Map.sqrtZoneNumber%i == 0) //Left column zones (except corners). { if (Map.z[i+1].Owner == Nat[Turn-1] || Map.z[i+Map.sqrtZoneNumber].Owner == Nat[Turn-1] || Map.z[i-Map.sqrtZoneNumber].Owner == Nat[Turn-1] && Map.z[Map.yZone*Map.sqrtZoneNumber+Map.xZone].Owner != null && Map.ClaimedZones<Map.ZoneNumber) { search = false; } } else { if (i>=Map.ZoneNumber-Map.sqrtZoneNumber) //Bottom row zones (except corners). { if (Map.z[i-1].Owner == Nat[Turn-1] || Map.z[i+1].Owner == Nat[Turn-1] || Map.z[i-Map.sqrtZoneNumber].Owner == Nat[Turn-1] && Map.z[Map.yZone*Map.sqrtZoneNumber+Map.xZone].Owner != null && Map.ClaimedZones<Map.ZoneNumber) { search = false; } } else { if (Map.sqrtZoneNumber%i == 4) //Right column zones (except corners). { if (Map.z[i-1].Owner == Nat[Turn-1] || Map.z[i+Map.sqrtZoneNumber].Owner == Nat[Turn-1] || Map.z[i-Map.sqrtZoneNumber].Owner == Nat[Turn-1] && Map.z[Map.yZone*Map.sqrtZoneNumber+Map.xZone].Owner != null && Map.ClaimedZones<Map.ZoneNumber) { search = false; } } else { if (Map.z[i-1].Owner == Nat[Turn-1] || Map.z[i+1].Owner == Nat[Turn-1] || Map.z[i-Map.sqrtZoneNumber].Owner == Nat[Turn-1] || Map.z[i+Map.sqrtZoneNumber].Owner == Nat[Turn-1] && Map.z[Map.yZone*Map.sqrtZoneNumber+Map.xZone].Owner != null && Map.ClaimedZones<Map.ZoneNumber) { search = false; }}}}}}}}} } } Map.z[Map.yZone*Map.sqrtZoneNumber+Map.xZone].claim(Nat[Turn-1]); //Claims the zone. }
else //AI turns. { search:for (;;) //The loop ensures that the claimed zone is empty. The code inside picks the zone. { //Chooses a random empty zone adjacent to the zones already owned by the nation... Sometimes. Map.yZone = (int)(Math.random()*Map.sqrtZoneNumber); Map.xZone = (int)(Math.random()*Map.sqrtZoneNumber); int i = Map.sqrtZoneNumber*Map.yZone + Map.xZone; if (i==0) {if (Map.z[i+1].Owner == Nat[Turn-1] || Map.z[i+Map.sqrtZoneNumber].Owner == Nat[Turn-1] && Map.z[Map.yZone*Map.sqrtZoneNumber+Map.xZone].Owner != null && Map.ClaimedZones<Map.ZoneNumber) {break search;}} //Upper left corner zone. else {if (i==Map.sqrtZoneNumber-1) {if (Map.z[i-1].Owner == Nat[Turn-1] || Map.z[i+Map.sqrtZoneNumber].Owner == Nat[Turn-1] && Map.z[Map.yZone*Map.sqrtZoneNumber+Map.xZone].Owner != null && Map.ClaimedZones<Map.ZoneNumber) {break search;}} //Upper right corner zone. else {if (i==Map.ZoneNumber-Map.sqrtZoneNumber-1) {if (Map.z[i+1].Owner == Nat[Turn-1] || Map.z[i-Map.sqrtZoneNumber].Owner == Nat[Turn-1] && Map.z[Map.yZone*Map.sqrtZoneNumber+Map.xZone].Owner != null && Map.ClaimedZones<Map.ZoneNumber) {break search;}} //Lower left corner zone. else {if (i==Map.ZoneNumber-1) {if (Map.z[i-1].Owner == Nat[Turn-1] || Map.z[i-Map.sqrtZoneNumber].Owner == Nat[Turn-1] && Map.z[Map.yZone*Map.sqrtZoneNumber+Map.xZone].Owner != null && Map.ClaimedZones<Map.ZoneNumber) {break search;}} //Lower right corner zone. else {if (i<Map.sqrtZoneNumber) {if (Map.z[i-1].Owner == Nat[Turn-1] || Map.z[i+1].Owner == Nat[Turn-1] || Map.z[i+Map.sqrtZoneNumber].Owner == Nat[Turn-1] && Map.z[Map.yZone*Map.sqrtZoneNumber+Map.xZone].Owner != null && Map.ClaimedZones<Map.ZoneNumber) {break search;}} //Top row zones (except corners). else {if (Map.sqrtZoneNumber%i == 0) {if (Map.z[i+1].Owner == Nat[Turn-1] || Map.z[i+Map.sqrtZoneNumber].Owner == Nat[Turn-1] || Map.z[i-Map.sqrtZoneNumber].Owner == Nat[Turn-1] && Map.z[Map.yZone*Map.sqrtZoneNumber+Map.xZone].Owner != null && Map.ClaimedZones<Map.ZoneNumber) {break search;}} //Left column zones (except corners). else {if (i>=Map.ZoneNumber-Map.sqrtZoneNumber) {if (Map.z[i-1].Owner == Nat[Turn-1] || Map.z[i+1].Owner == Nat[Turn-1] || Map.z[i-Map.sqrtZoneNumber].Owner == Nat[Turn-1] && Map.z[Map.yZone*Map.sqrtZoneNumber+Map.xZone].Owner != null && Map.ClaimedZones<Map.ZoneNumber) {break search;}} //Bottom row zones (except corners). else {if (Map.sqrtZoneNumber%i == 4) {if (Map.z[i-1].Owner == Nat[Turn-1] || Map.z[i+Map.sqrtZoneNumber].Owner == Nat[Turn-1] || Map.z[i-Map.sqrtZoneNumber].Owner == Nat[Turn-1] && Map.z[Map.yZone*Map.sqrtZoneNumber+Map.xZone].Owner != null && Map.ClaimedZones<Map.ZoneNumber) {break search;}}//Right column zones (except corners). else {if (Map.z[i-1].Owner == Nat[Turn-1] || Map.z[i+1].Owner == Nat[Turn-1] || Map.z[i-Map.sqrtZoneNumber].Owner == Nat[Turn-1] || Map.z[i+Map.sqrtZoneNumber].Owner == Nat[Turn-1] && Map.z[Map.yZone*Map.sqrtZoneNumber+Map.xZone].Owner != null && Map.ClaimedZones<Map.ZoneNumber) {break search;}}}}}}}}} //Middle zones. } Map.z[Map.yZone*Map.sqrtZoneNumber+Map.xZone].claim(Nat[Turn-1]); //Claims the zone. }
Edit: Don.
Formerly NeutronStar | FORRRREEEEVVVVEEEERR
yeah, i just remembered that i thought ftw (for the win) was wft, but backwards. That was fail.
but you did them
a slightly smaller fail