Parallel cleanups in the C and scratch Python code.
[super-star-trek.git] / src / ai.c
index b4b35b9ed93f8be79999b3d72b0d786d7232972b..80465ba11e33fb9574d0f24a8a2c1fde5ace37ba 100644 (file)
--- a/src/ai.c
+++ b/src/ai.c
@@ -10,8 +10,8 @@ static bool tryexit(coord look, int ienm, int loccom, bool irun)
     iq.y = game.quadrant.y+(look.y+(QUADSIZE-1))/QUADSIZE - 1;
     if (!VALID_QUADRANT(iq.x,iq.y) ||
        game.state.galaxy[iq.x][iq.y].supernova ||
-       game.state.galaxy[iq.x][iq.y].klingons > 8)
-       return false; /* no can do -- neg energy, supernovae, or >8 Klingons */
+       game.state.galaxy[iq.x][iq.y].klingons > MAXKLQUAD-1)
+       return false; /* no can do -- neg energy, supernovae, or >MAXKLQUAD-1 Klingons */
     if (ienm == IHR) return false; /* Romulans cannot escape! */
     if (!irun) {
        /* avoid intruding on another commander's territory */
@@ -155,7 +155,7 @@ static void movebaddy(coord com, int loccom, feature ienm)
                motion -= game.skill*(2.0-square(Rand()));
        }
        if (idebug)
-           proutn("=== MOTION = %1.2f, FORCES = %1.2f, ", motion, forces);
+           proutn("=== MOTION = %d, FORCES = %1.2f, ", motion, forces);
        /* don't move if no motion */
        if (motion==0) return;
        /* Limit motion according to skill */
@@ -231,7 +231,7 @@ static void movebaddy(coord com, int loccom, feature ienm)
        
     }
     if (idebug)
-       prout("");
+       skip(1);
     /* Put commander in place within same quadrant */
     game.quad[com.x][com.y] = IHDOT;
     game.quad[next.x][next.y] = ienm;
@@ -296,12 +296,13 @@ static bool movescom(coord iq, bool flag, bool *ipage)
 
     if (same(iq, game.quadrant) || !VALID_QUADRANT(iq.x, iq.y) ||
        game.state.galaxy[iq.x][iq.y].supernova ||
-       game.state.galaxy[iq.x][iq.y].klingons > 8
+       game.state.galaxy[iq.x][iq.y].klingons > MAXKLQUAD-1
        return 1;
     if (flag) {
        /* Avoid quadrants with bases if we want to avoid Enterprise */
        for_starbases(i)
-           if (game.state.baseq[i].x==iq.x && game.state.baseq[i].y==iq.y) return 1;
+           if (same(game.state.baseq[i], iq)) 
+               return true;
     }
     if (game.justin && !game.iscate) return true;
     /* do the move */
@@ -329,8 +330,8 @@ static bool movescom(coord iq, bool flag, bool *ipage)
     }
     /* check for a helpful planet */
     for (i = 0; i < game.inplan; i++) {
-       if (game.state.plnets[i].w.x==game.state.kscmdr.x && game.state.plnets[i].w.y==game.state.kscmdr.y &&
-           game.state.plnets[i].crystals == 1) {
+       if (same(game.state.plnets[i].w, game.state.kscmdr) &&
+           game.state.plnets[i].crystals == present) {
            /* destroy the planet */
            DESTROY(&game.state.plnets[i]);
            game.state.galaxy[game.state.kscmdr.x][game.state.kscmdr.y].planet = NOPLANET;
@@ -412,7 +413,7 @@ void scom(bool *ipage)
            ibq = game.state.baseq[i];
            if (same(ibq, game.quadrant) || same(ibq, game.battle) ||
                game.state.galaxy[ibq.x][ibq.y].supernova ||
-               game.state.galaxy[ibq.x][ibq.y].klingons > 8
+               game.state.galaxy[ibq.x][ibq.y].klingons > MAXKLQUAD-1
                continue;
            /* if there is a commander, an no other base is appropriate,
               we will take the one with the commander */