]> git.cameronkatri.com Git - bsdgames-darwin.git/blobdiff - mille/comp.c
- add or adjust /* FALLTHROUGH */ where appropriate
[bsdgames-darwin.git] / mille / comp.c
index 531fffd9e998edfd198726a0d9271f39cdce840c..83f8aa3a1aaf1f7e5497658449712c05a7a47928 100644 (file)
@@ -1,4 +1,4 @@
-/*     $NetBSD: comp.c,v 1.7 1999/09/18 19:38:52 jsm Exp $     */
+/*     $NetBSD: comp.c,v 1.13 2009/05/25 23:44:04 dholland Exp $       */
 
 /*
  * Copyright (c) 1982, 1993
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *
 #if 0
 static char sccsid[] = "@(#)comp.c     8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: comp.c,v 1.7 1999/09/18 19:38:52 jsm Exp $");
+__RCSID("$NetBSD: comp.c,v 1.13 2009/05/25 23:44:04 dholland Exp $");
 #endif
 #endif /* not lint */
 
-# include      "mille.h"
+#include "mille.h"
 
 /*
  * @(#)comp.c  1.1 (Berkeley) 4/1/82
  */
 
-# define       V_VALUABLE      40
+#define V_VALUABLE     40
 
 void
-calcmove()
+calcmove(void)
 {
        CARD            card;
        int             *value;
        PLAY            *pp, *op;
        bool            foundend, cango, canstop, foundlow;
-       unsgn int       i, count200, badcount, nummin, nummax, diff;
+       unsigned int    i, count200, badcount, nummin, nummax, diff;
        int             curmin, curmax;
        CARD            safe, oppos;
        int             valbuf[HAND_SZ], count[NUM_CARDS];
@@ -131,7 +127,7 @@ norm:
        if (foundend)
                foundend = !check_ext(TRUE);
        for (i = 0; safe && i < HAND_SZ; i++) {
-               if (issafety(pp->hand[i])) {
+               if (is_safety(pp->hand[i])) {
                        if (onecard(op) || (foundend && cango && !canstop)) {
 #ifdef DEBUG
                                if (Debug)
@@ -167,7 +163,7 @@ playsafe:
                        playit[i] = cango;
                }
        }
-       if (!pp->can_go && !isrepair(pp->battle))
+       if (!pp->can_go && !is_repair(pp->battle))
                Numneed[opposite(pp->battle)]++;
 redoit:
        foundlow = (cango || count[C_END_LIMIT] != 0
@@ -183,7 +179,7 @@ redoit:
        value = valbuf;
        for (i = 0; i < HAND_SZ; i++) {
                card = pp->hand[i];
-               if (issafety(card) || playit[i] == (cango != 0)) {
+               if (is_safety(card) || playit[i] == (cango != 0)) {
 #ifdef DEBUG
                        if (Debug)
                                fprintf(outf, "CALCMOVE: switch(\"%s\")\n",
@@ -346,9 +342,7 @@ normbad:
                                                *value /= ++badcount;
                                        if (op->mileage == 0)
                                                *value += 5;
-                                       if ((card == C_LIMIT &&
-                                            op->speed == C_LIMIT) ||
-                                           !op->can_go)
+                                       if (op->speed == C_LIMIT || !op->can_go)
                                                *value -= 5;
                                        if (cango && pp->safety[S_RIGHT_WAY] !=
                                                     S_UNKNOWN)
@@ -383,7 +377,7 @@ normbad:
 #endif
                value++;
        }
-       if (!pp->can_go && !isrepair(pp->battle))
+       if (!pp->can_go && !is_repair(pp->battle))
                Numneed[opposite(pp->battle)]++;
        if (cango) {
 play_it:
@@ -392,7 +386,7 @@ play_it:
                Card_no = nummax;
        }
        else {
-               if (issafety(pp->hand[nummin])) { /* NEVER discard a safety */
+               if (is_safety(pp->hand[nummin])) { /* NEVER discard a safety */
                        nummax = nummin;
                        goto play_it;
                }
@@ -407,15 +401,14 @@ play_it:
  * Return true if the given player could conceivably win with his next card.
  */
 int
-onecard(pp)
-       const PLAY      *pp;
+onecard(const PLAY *pp)
 {
        CARD    bat, spd, card;
 
        bat = pp->battle;
        spd = pp->speed;
        card = -1;
-       if (pp->can_go || ((isrepair(bat) || bat == C_STOP || spd == C_LIMIT) &&
+       if (pp->can_go || ((is_repair(bat) || bat == C_STOP || spd == C_LIMIT) &&
                           Numseen[S_RIGHT_WAY] != 0) ||
            (bat >= 0 && Numseen[safety(bat)] != 0))
                switch (End - pp->mileage) {
@@ -440,9 +433,7 @@ onecard(pp)
 }
 
 int
-canplay(pp, op, card)
-       const PLAY      *pp, *op;
-       CARD    card;
+canplay(const PLAY *pp, const PLAY *op, CARD card)
 {
        switch (card) {
          case C_200:
@@ -478,7 +469,7 @@ canplay(pp, op, card)
                break;
          case C_GO:
                if (!pp->can_go &&
-                   (isrepair(pp->battle) || pp->battle == C_STOP))
+                   (is_repair(pp->battle) || pp->battle == C_STOP))
                        return TRUE;
                break;
          case C_END_LIMIT: