BSD 4_3_Tahoe release
[unix-history] / usr / src / games / mille / comp.c
index c5faa90..271ec83 100644 (file)
@@ -1,3 +1,24 @@
+/*
+ * Copyright (c) 1982 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley.  The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)comp.c     5.3 (Berkeley) 6/18/88";
+#endif /* not lint */
+
 # include      "mille.h"
 
 /*
 # include      "mille.h"
 
 /*
@@ -72,18 +93,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;
@@ -99,10 +124,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;
                        }
@@ -127,9 +154,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;
@@ -317,9 +346,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))
@@ -327,9 +358,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;
                }
@@ -340,9 +375,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;
                }