BSD 4_3_Net_2 release
[unix-history] / usr / src / games / mille / comp.c
index a6f912b..64929fe 100644 (file)
@@ -1,18 +1,39 @@
 /*
  * Copyright (c) 1982 Regents of the University of California.
 /*
  * Copyright (c) 1982 Regents of the University of California.
- * All rights reserved.  The Berkeley software License Agreement
- * specifies the terms and conditions for redistribution.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 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
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-char copyright[] =
-"@(#) Copyright (c) 1982 Regents of the University of California.\n\
- All rights reserved.\n";
-#endif not lint
-
-#ifndef lint
-static char sccsid[] = "@(#)comp.c     5.1 (Berkeley) %G%";
-#endif not lint
+static char sccsid[] = "@(#)comp.c     5.4 (Berkeley) 6/1/90";
+#endif /* not lint */
 
 # include      "mille.h"
 
 
 # include      "mille.h"
 
@@ -88,18 +109,22 @@ norm:
                Movetype = M_DRAW;
                return;
        }
                Movetype = M_DRAW;
                return;
        }
+#ifdef DEBUG
        if (Debug)
                fprintf(outf, "CALCMOVE: cango = %d, canstop = %d, safe = %d\n",
                        cango, canstop, safe);
        if (Debug)
                fprintf(outf, "CALCMOVE: cango = %d, canstop = %d, safe = %d\n",
                        cango, canstop, safe);
+#endif
        if (foundend)
                foundend = !check_ext(TRUE);
        for (i = 0; safe && i < HAND_SZ; i++) {
                if (issafety(pp->hand[i])) {
                        if (onecard(op) || (foundend && cango && !canstop)) {
        if (foundend)
                foundend = !check_ext(TRUE);
        for (i = 0; safe && i < HAND_SZ; i++) {
                if (issafety(pp->hand[i])) {
                        if (onecard(op) || (foundend && cango && !canstop)) {
+#ifdef DEBUG
                                if (Debug)
                                        fprintf(outf,
                                                "CALCMOVE: onecard(op) = %d, foundend = %d\n",
                                                onecard(op), foundend);
                                if (Debug)
                                        fprintf(outf,
                                                "CALCMOVE: onecard(op) = %d, foundend = %d\n",
                                                onecard(op), foundend);
+#endif
 playsafe:
                                Movetype = M_PLAY;
                                Card_no = i;
 playsafe:
                                Movetype = M_PLAY;
                                Card_no = i;
@@ -115,10 +140,12 @@ playsafe:
                                card = (Topcard - Deck) - roll(1, 10);
                                if ((!pp->mileage) != (!op->mileage))
                                        card -= 7;
                                card = (Topcard - Deck) - roll(1, 10);
                                if ((!pp->mileage) != (!op->mileage))
                                        card -= 7;
+#ifdef DEBUG
                                if (Debug)
                                        fprintf(outf,
                                                "CALCMOVE: card = %d, DECK_SZ / 4 = %d\n",
                                                card, DECK_SZ / 4);
                                if (Debug)
                                        fprintf(outf,
                                                "CALCMOVE: card = %d, DECK_SZ / 4 = %d\n",
                                                card, DECK_SZ / 4);
+#endif
                                if (card < DECK_SZ / 4)
                                        goto playsafe;
                        }
                                if (card < DECK_SZ / 4)
                                        goto playsafe;
                        }
@@ -143,9 +170,11 @@ redoit:
        for (i = 0; i < HAND_SZ; i++) {
                card = pp->hand[i];
                if (issafety(card) || playit[i] == (cango != 0)) {
        for (i = 0; i < HAND_SZ; i++) {
                card = pp->hand[i];
                if (issafety(card) || playit[i] == (cango != 0)) {
+#ifdef DEBUG
                        if (Debug)
                                fprintf(outf, "CALCMOVE: switch(\"%s\")\n",
                                        C_name[card]);
                        if (Debug)
                                fprintf(outf, "CALCMOVE: switch(\"%s\")\n",
                                        C_name[card]);
+#endif
                        switch (card) {
                          case C_25:    case C_50:
                                diff = End - pp->mileage;
                        switch (card) {
                          case C_25:    case C_50:
                                diff = End - pp->mileage;
@@ -333,9 +362,11 @@ normbad:
                                curmin = *value;
                        }
                }
                                curmin = *value;
                        }
                }
+#ifdef DEBUG
                if (Debug)
                        mvprintw(i + 6, 2, "%3d %-14s", *value,
                                 C_name[pp->hand[i]]);
                if (Debug)
                        mvprintw(i + 6, 2, "%3d %-14s", *value,
                                 C_name[pp->hand[i]]);
+#endif
                value++;
        }
        if (!pp->can_go && !isrepair(pp->battle))
                value++;
        }
        if (!pp->can_go && !isrepair(pp->battle))
@@ -343,9 +374,13 @@ normbad:
        if (cango) {
 play_it:
                mvaddstr(MOVE_Y + 1, MOVE_X, "PLAY\n");
        if (cango) {
 play_it:
                mvaddstr(MOVE_Y + 1, MOVE_X, "PLAY\n");
+#ifdef DEBUG
                if (Debug)
                        getmove();
                if (!Debug || Movetype == M_DRAW) {
                if (Debug)
                        getmove();
                if (!Debug || Movetype == M_DRAW) {
+#else
+               if (Movetype == M_DRAW) {
+#endif
                        Movetype = M_PLAY;
                        Card_no = nummax;
                }
                        Movetype = M_PLAY;
                        Card_no = nummax;
                }
@@ -356,9 +391,13 @@ play_it:
                        goto play_it;
                }
                mvaddstr(MOVE_Y + 1, MOVE_X, "DISCARD\n");
                        goto play_it;
                }
                mvaddstr(MOVE_Y + 1, MOVE_X, "DISCARD\n");
+#ifdef DEBUG
                if (Debug)
                        getmove();
                if (!Debug || Movetype == M_DRAW) {
                if (Debug)
                        getmove();
                if (!Debug || Movetype == M_DRAW) {
+#else
+               if (Movetype == M_DRAW) {
+#endif
                        Movetype = M_DISCARD;
                        Card_no = nummin;
                }
                        Movetype = M_DISCARD;
                        Card_no = nummin;
                }