comp.c revision 1.7 1 1.7 jsm /* $NetBSD: comp.c,v 1.7 1999/09/18 19:38:52 jsm Exp $ */
2 1.4 cgd
3 1.1 cgd /*
4 1.3 jtc * Copyright (c) 1982, 1993
5 1.3 jtc * The Regents of the University of California. All rights reserved.
6 1.1 cgd *
7 1.1 cgd * Redistribution and use in source and binary forms, with or without
8 1.1 cgd * modification, are permitted provided that the following conditions
9 1.1 cgd * are met:
10 1.1 cgd * 1. Redistributions of source code must retain the above copyright
11 1.1 cgd * notice, this list of conditions and the following disclaimer.
12 1.1 cgd * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 cgd * notice, this list of conditions and the following disclaimer in the
14 1.1 cgd * documentation and/or other materials provided with the distribution.
15 1.1 cgd * 3. All advertising materials mentioning features or use of this software
16 1.1 cgd * must display the following acknowledgement:
17 1.1 cgd * This product includes software developed by the University of
18 1.1 cgd * California, Berkeley and its contributors.
19 1.1 cgd * 4. Neither the name of the University nor the names of its contributors
20 1.1 cgd * may be used to endorse or promote products derived from this software
21 1.1 cgd * without specific prior written permission.
22 1.1 cgd *
23 1.1 cgd * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 1.1 cgd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 1.1 cgd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 1.1 cgd * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 1.1 cgd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 1.1 cgd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 1.1 cgd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 1.1 cgd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 1.1 cgd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 1.1 cgd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 1.1 cgd * SUCH DAMAGE.
34 1.1 cgd */
35 1.1 cgd
36 1.5 lukem #include <sys/cdefs.h>
37 1.1 cgd #ifndef lint
38 1.4 cgd #if 0
39 1.4 cgd static char sccsid[] = "@(#)comp.c 8.1 (Berkeley) 5/31/93";
40 1.4 cgd #else
41 1.7 jsm __RCSID("$NetBSD: comp.c,v 1.7 1999/09/18 19:38:52 jsm Exp $");
42 1.4 cgd #endif
43 1.1 cgd #endif /* not lint */
44 1.1 cgd
45 1.1 cgd # include "mille.h"
46 1.1 cgd
47 1.1 cgd /*
48 1.1 cgd * @(#)comp.c 1.1 (Berkeley) 4/1/82
49 1.1 cgd */
50 1.1 cgd
51 1.1 cgd # define V_VALUABLE 40
52 1.1 cgd
53 1.5 lukem void
54 1.1 cgd calcmove()
55 1.1 cgd {
56 1.5 lukem CARD card;
57 1.5 lukem int *value;
58 1.5 lukem PLAY *pp, *op;
59 1.5 lukem bool foundend, cango, canstop, foundlow;
60 1.5 lukem unsgn int i, count200, badcount, nummin, nummax, diff;
61 1.5 lukem int curmin, curmax;
62 1.5 lukem CARD safe, oppos;
63 1.5 lukem int valbuf[HAND_SZ], count[NUM_CARDS];
64 1.5 lukem bool playit[HAND_SZ];
65 1.1 cgd
66 1.1 cgd wmove(Score, ERR_Y, ERR_X); /* get rid of error messages */
67 1.1 cgd wclrtoeol(Score);
68 1.1 cgd pp = &Player[COMP];
69 1.1 cgd op = &Player[PLAYER];
70 1.1 cgd safe = 0;
71 1.1 cgd cango = 0;
72 1.1 cgd canstop = FALSE;
73 1.1 cgd foundend = FALSE;
74 1.3 jtc
75 1.3 jtc /* Try for a Coup Forre, and see what we have. */
76 1.1 cgd for (i = 0; i < NUM_CARDS; i++)
77 1.1 cgd count[i] = 0;
78 1.1 cgd for (i = 0; i < HAND_SZ; i++) {
79 1.1 cgd card = pp->hand[i];
80 1.1 cgd switch (card) {
81 1.1 cgd case C_STOP: case C_CRASH:
82 1.1 cgd case C_FLAT: case C_EMPTY:
83 1.5 lukem if ((playit[i] = canplay(pp, op, card)) != 0)
84 1.1 cgd canstop = TRUE;
85 1.1 cgd goto norm;
86 1.1 cgd case C_LIMIT:
87 1.1 cgd if ((playit[i] = canplay(pp, op, card))
88 1.1 cgd && Numseen[C_25] == Numcards[C_25]
89 1.1 cgd && Numseen[C_50] == Numcards[C_50])
90 1.1 cgd canstop = TRUE;
91 1.1 cgd goto norm;
92 1.1 cgd case C_25: case C_50: case C_75:
93 1.1 cgd case C_100: case C_200:
94 1.1 cgd if ((playit[i] = canplay(pp, op, card))
95 1.1 cgd && pp->mileage + Value[card] == End)
96 1.1 cgd foundend = TRUE;
97 1.1 cgd goto norm;
98 1.1 cgd default:
99 1.1 cgd playit[i] = canplay(pp, op, card);
100 1.1 cgd norm:
101 1.1 cgd if (playit[i])
102 1.1 cgd ++cango;
103 1.1 cgd break;
104 1.1 cgd case C_GAS_SAFE: case C_DRIVE_SAFE:
105 1.1 cgd case C_SPARE_SAFE: case C_RIGHT_WAY:
106 1.1 cgd if (pp->battle == opposite(card) ||
107 1.1 cgd (pp->speed == C_LIMIT && card == C_RIGHT_WAY)) {
108 1.1 cgd Movetype = M_PLAY;
109 1.1 cgd Card_no = i;
110 1.1 cgd return;
111 1.1 cgd }
112 1.1 cgd ++safe;
113 1.1 cgd playit[i] = TRUE;
114 1.1 cgd break;
115 1.1 cgd }
116 1.3 jtc if (card >= 0)
117 1.3 jtc ++count[card];
118 1.1 cgd }
119 1.3 jtc
120 1.3 jtc /* No Coup Forre. Draw to fill hand, then restart, as needed. */
121 1.1 cgd if (pp->hand[0] == C_INIT && Topcard > Deck) {
122 1.1 cgd Movetype = M_DRAW;
123 1.1 cgd return;
124 1.1 cgd }
125 1.3 jtc
126 1.1 cgd #ifdef DEBUG
127 1.1 cgd if (Debug)
128 1.1 cgd fprintf(outf, "CALCMOVE: cango = %d, canstop = %d, safe = %d\n",
129 1.1 cgd cango, canstop, safe);
130 1.1 cgd #endif
131 1.1 cgd if (foundend)
132 1.1 cgd foundend = !check_ext(TRUE);
133 1.1 cgd for (i = 0; safe && i < HAND_SZ; i++) {
134 1.1 cgd if (issafety(pp->hand[i])) {
135 1.1 cgd if (onecard(op) || (foundend && cango && !canstop)) {
136 1.1 cgd #ifdef DEBUG
137 1.1 cgd if (Debug)
138 1.1 cgd fprintf(outf,
139 1.1 cgd "CALCMOVE: onecard(op) = %d, foundend = %d\n",
140 1.1 cgd onecard(op), foundend);
141 1.1 cgd #endif
142 1.1 cgd playsafe:
143 1.1 cgd Movetype = M_PLAY;
144 1.1 cgd Card_no = i;
145 1.1 cgd return;
146 1.1 cgd }
147 1.1 cgd oppos = opposite(pp->hand[i]);
148 1.1 cgd if (Numseen[oppos] == Numcards[oppos] &&
149 1.1 cgd !(pp->hand[i] == C_RIGHT_WAY &&
150 1.1 cgd Numseen[C_LIMIT] != Numcards[C_LIMIT]))
151 1.1 cgd goto playsafe;
152 1.1 cgd else if (!cango
153 1.1 cgd && (op->can_go || !pp->can_go || Topcard < Deck)) {
154 1.1 cgd card = (Topcard - Deck) - roll(1, 10);
155 1.1 cgd if ((!pp->mileage) != (!op->mileage))
156 1.1 cgd card -= 7;
157 1.1 cgd #ifdef DEBUG
158 1.1 cgd if (Debug)
159 1.1 cgd fprintf(outf,
160 1.1 cgd "CALCMOVE: card = %d, DECK_SZ / 4 = %d\n",
161 1.1 cgd card, DECK_SZ / 4);
162 1.1 cgd #endif
163 1.1 cgd if (card < DECK_SZ / 4)
164 1.1 cgd goto playsafe;
165 1.1 cgd }
166 1.1 cgd safe--;
167 1.1 cgd playit[i] = cango;
168 1.1 cgd }
169 1.1 cgd }
170 1.1 cgd if (!pp->can_go && !isrepair(pp->battle))
171 1.1 cgd Numneed[opposite(pp->battle)]++;
172 1.1 cgd redoit:
173 1.1 cgd foundlow = (cango || count[C_END_LIMIT] != 0
174 1.1 cgd || Numseen[C_LIMIT] == Numcards[C_LIMIT]
175 1.1 cgd || pp->safety[S_RIGHT_WAY] != S_UNKNOWN);
176 1.1 cgd foundend = FALSE;
177 1.1 cgd count200 = pp->nummiles[C_200];
178 1.1 cgd badcount = 0;
179 1.1 cgd curmax = -1;
180 1.1 cgd curmin = 101;
181 1.1 cgd nummin = -1;
182 1.1 cgd nummax = -1;
183 1.1 cgd value = valbuf;
184 1.1 cgd for (i = 0; i < HAND_SZ; i++) {
185 1.1 cgd card = pp->hand[i];
186 1.1 cgd if (issafety(card) || playit[i] == (cango != 0)) {
187 1.1 cgd #ifdef DEBUG
188 1.1 cgd if (Debug)
189 1.1 cgd fprintf(outf, "CALCMOVE: switch(\"%s\")\n",
190 1.1 cgd C_name[card]);
191 1.1 cgd #endif
192 1.1 cgd switch (card) {
193 1.1 cgd case C_25: case C_50:
194 1.1 cgd diff = End - pp->mileage;
195 1.1 cgd /* avoid getting too close */
196 1.1 cgd if (Topcard > Deck && cango && diff <= 100
197 1.7 jsm && (int)diff / Value[card] > count[card]
198 1.1 cgd && (card == C_25 || diff % 50 == 0)) {
199 1.1 cgd if (card == C_50 && diff - 50 == 25
200 1.1 cgd && count[C_25] > 0)
201 1.1 cgd goto okay;
202 1.1 cgd *value = 0;
203 1.1 cgd if (--cango <= 0)
204 1.1 cgd goto redoit;
205 1.1 cgd break;
206 1.1 cgd }
207 1.1 cgd okay:
208 1.1 cgd *value = (Value[card] >> 3);
209 1.1 cgd if (pp->speed == C_LIMIT)
210 1.1 cgd ++*value;
211 1.1 cgd else
212 1.1 cgd --*value;
213 1.1 cgd if (!foundlow
214 1.1 cgd && (card == C_50 || count[C_50] == 0)) {
215 1.1 cgd *value = (pp->mileage ? 10 : 20);
216 1.1 cgd foundlow = TRUE;
217 1.1 cgd }
218 1.1 cgd goto miles;
219 1.1 cgd case C_200:
220 1.1 cgd if (++count200 > 2) {
221 1.1 cgd *value = 0;
222 1.1 cgd break;
223 1.1 cgd }
224 1.1 cgd case C_75: case C_100:
225 1.1 cgd *value = (Value[card] >> 3);
226 1.1 cgd if (pp->speed == C_LIMIT)
227 1.1 cgd --*value;
228 1.1 cgd else
229 1.1 cgd ++*value;
230 1.1 cgd miles:
231 1.1 cgd if (pp->mileage + Value[card] > End)
232 1.1 cgd *value = (End == 700 ? card : 0);
233 1.1 cgd else if (pp->mileage + Value[card] == End) {
234 1.1 cgd *value = (foundend ? card : V_VALUABLE);
235 1.1 cgd foundend = TRUE;
236 1.1 cgd }
237 1.1 cgd break;
238 1.1 cgd case C_END_LIMIT:
239 1.1 cgd if (pp->safety[S_RIGHT_WAY] != S_UNKNOWN)
240 1.1 cgd *value = (pp->safety[S_RIGHT_WAY] ==
241 1.1 cgd S_PLAYED ? -1 : 1);
242 1.1 cgd else if (pp->speed == C_LIMIT &&
243 1.1 cgd End - pp->mileage <= 50)
244 1.1 cgd *value = 1;
245 1.1 cgd else if (pp->speed == C_LIMIT
246 1.1 cgd || Numseen[C_LIMIT] != Numcards[C_LIMIT]) {
247 1.1 cgd safe = S_RIGHT_WAY;
248 1.1 cgd oppos = C_LIMIT;
249 1.1 cgd goto repair;
250 1.1 cgd }
251 1.1 cgd else {
252 1.1 cgd *value = 0;
253 1.1 cgd --count[C_END_LIMIT];
254 1.1 cgd }
255 1.1 cgd break;
256 1.1 cgd case C_REPAIRS: case C_SPARE: case C_GAS:
257 1.1 cgd safe = safety(card) - S_CONV;
258 1.1 cgd oppos = opposite(card);
259 1.1 cgd if (pp->safety[safe] != S_UNKNOWN)
260 1.1 cgd *value = (pp->safety[safe] ==
261 1.1 cgd S_PLAYED ? -1 : 1);
262 1.1 cgd else if (pp->battle != oppos
263 1.1 cgd && (Numseen[oppos] == Numcards[oppos] ||
264 1.1 cgd Numseen[oppos] + count[card] >
265 1.1 cgd Numcards[oppos])) {
266 1.1 cgd *value = 0;
267 1.1 cgd --count[card];
268 1.1 cgd }
269 1.1 cgd else {
270 1.1 cgd repair:
271 1.1 cgd *value = Numcards[oppos] * 6;
272 1.1 cgd *value += Numseen[card] -
273 1.1 cgd Numseen[oppos];
274 1.1 cgd if (!cango)
275 1.1 cgd *value /= (count[card]*count[card]);
276 1.1 cgd count[card]--;
277 1.1 cgd }
278 1.1 cgd break;
279 1.1 cgd case C_GO:
280 1.1 cgd if (pp->safety[S_RIGHT_WAY] != S_UNKNOWN)
281 1.1 cgd *value = (pp->safety[S_RIGHT_WAY] ==
282 1.1 cgd S_PLAYED ? -1 : 2);
283 1.1 cgd else if (pp->can_go
284 1.1 cgd && Numgos + count[C_GO] == Numneed[C_GO]) {
285 1.1 cgd *value = 0;
286 1.1 cgd --count[C_GO];
287 1.1 cgd }
288 1.1 cgd else {
289 1.1 cgd *value = Numneed[C_GO] * 3;
290 1.1 cgd *value += (Numseen[C_GO] - Numgos);
291 1.1 cgd *value /= (count[C_GO] * count[C_GO]);
292 1.1 cgd count[C_GO]--;
293 1.1 cgd }
294 1.1 cgd break;
295 1.1 cgd case C_LIMIT:
296 1.1 cgd if (op->mileage + 50 >= End) {
297 1.1 cgd *value = (End == 700 && !cango);
298 1.1 cgd break;
299 1.1 cgd }
300 1.1 cgd if (canstop || (cango && !op->can_go))
301 1.1 cgd *value = 1;
302 1.1 cgd else {
303 1.1 cgd *value = (pp->safety[S_RIGHT_WAY] !=
304 1.1 cgd S_UNKNOWN ? 2 : 3);
305 1.1 cgd safe = S_RIGHT_WAY;
306 1.1 cgd oppos = C_END_LIMIT;
307 1.1 cgd goto normbad;
308 1.1 cgd }
309 1.1 cgd break;
310 1.1 cgd case C_CRASH: case C_EMPTY: case C_FLAT:
311 1.1 cgd safe = safety(card) - S_CONV;
312 1.1 cgd oppos = opposite(card);
313 1.1 cgd *value = (pp->safety[safe]!=S_UNKNOWN ? 3 : 4);
314 1.1 cgd normbad:
315 1.1 cgd if (op->safety[safe] == S_PLAYED)
316 1.1 cgd *value = -1;
317 1.1 cgd else {
318 1.1 cgd *value *= Numneed[oppos] +
319 1.1 cgd Numseen[oppos] + 2;
320 1.1 cgd if (!pp->mileage || foundend ||
321 1.1 cgd onecard(op))
322 1.1 cgd *value += 5;
323 1.1 cgd if (op->mileage == 0 || onecard(op))
324 1.1 cgd *value += 5;
325 1.1 cgd if (op->speed == C_LIMIT)
326 1.1 cgd *value -= 3;
327 1.1 cgd if (cango &&
328 1.1 cgd pp->safety[safe] != S_UNKNOWN)
329 1.1 cgd *value += 3;
330 1.1 cgd if (!cango)
331 1.1 cgd *value /= ++badcount;
332 1.1 cgd }
333 1.1 cgd break;
334 1.1 cgd case C_STOP:
335 1.1 cgd if (op->safety[S_RIGHT_WAY] == S_PLAYED)
336 1.1 cgd *value = -1;
337 1.1 cgd else {
338 1.1 cgd *value = (pp->safety[S_RIGHT_WAY] !=
339 1.1 cgd S_UNKNOWN ? 3 : 4);
340 1.1 cgd *value *= Numcards[C_STOP] +
341 1.1 cgd Numseen[C_GO];
342 1.1 cgd if (!pp->mileage || foundend ||
343 1.1 cgd onecard(op))
344 1.1 cgd *value += 5;
345 1.1 cgd if (!cango)
346 1.1 cgd *value /= ++badcount;
347 1.1 cgd if (op->mileage == 0)
348 1.1 cgd *value += 5;
349 1.1 cgd if ((card == C_LIMIT &&
350 1.1 cgd op->speed == C_LIMIT) ||
351 1.1 cgd !op->can_go)
352 1.1 cgd *value -= 5;
353 1.1 cgd if (cango && pp->safety[S_RIGHT_WAY] !=
354 1.1 cgd S_UNKNOWN)
355 1.1 cgd *value += 5;
356 1.1 cgd }
357 1.1 cgd break;
358 1.1 cgd case C_GAS_SAFE: case C_DRIVE_SAFE:
359 1.1 cgd case C_SPARE_SAFE: case C_RIGHT_WAY:
360 1.1 cgd *value = cango ? 0 : 101;
361 1.1 cgd break;
362 1.1 cgd case C_INIT:
363 1.1 cgd *value = 0;
364 1.1 cgd break;
365 1.1 cgd }
366 1.1 cgd }
367 1.1 cgd else
368 1.1 cgd *value = cango ? 0 : 101;
369 1.1 cgd if (card != C_INIT) {
370 1.1 cgd if (*value >= curmax) {
371 1.1 cgd nummax = i;
372 1.1 cgd curmax = *value;
373 1.1 cgd }
374 1.1 cgd if (*value <= curmin) {
375 1.1 cgd nummin = i;
376 1.1 cgd curmin = *value;
377 1.1 cgd }
378 1.1 cgd }
379 1.1 cgd #ifdef DEBUG
380 1.1 cgd if (Debug)
381 1.1 cgd mvprintw(i + 6, 2, "%3d %-14s", *value,
382 1.1 cgd C_name[pp->hand[i]]);
383 1.1 cgd #endif
384 1.1 cgd value++;
385 1.1 cgd }
386 1.1 cgd if (!pp->can_go && !isrepair(pp->battle))
387 1.1 cgd Numneed[opposite(pp->battle)]++;
388 1.1 cgd if (cango) {
389 1.1 cgd play_it:
390 1.1 cgd mvaddstr(MOVE_Y + 1, MOVE_X, "PLAY\n");
391 1.3 jtc Movetype = M_PLAY;
392 1.3 jtc Card_no = nummax;
393 1.1 cgd }
394 1.1 cgd else {
395 1.1 cgd if (issafety(pp->hand[nummin])) { /* NEVER discard a safety */
396 1.1 cgd nummax = nummin;
397 1.1 cgd goto play_it;
398 1.1 cgd }
399 1.1 cgd mvaddstr(MOVE_Y + 1, MOVE_X, "DISCARD\n");
400 1.3 jtc Movetype = M_DISCARD;
401 1.3 jtc Card_no = nummin;
402 1.1 cgd }
403 1.1 cgd mvprintw(MOVE_Y + 2, MOVE_X, "%16s", C_name[pp->hand[Card_no]]);
404 1.1 cgd }
405 1.1 cgd
406 1.3 jtc /*
407 1.3 jtc * Return true if the given player could conceivably win with his next card.
408 1.3 jtc */
409 1.5 lukem int
410 1.1 cgd onecard(pp)
411 1.6 jsm const PLAY *pp;
412 1.1 cgd {
413 1.5 lukem CARD bat, spd, card;
414 1.1 cgd
415 1.1 cgd bat = pp->battle;
416 1.1 cgd spd = pp->speed;
417 1.1 cgd card = -1;
418 1.1 cgd if (pp->can_go || ((isrepair(bat) || bat == C_STOP || spd == C_LIMIT) &&
419 1.1 cgd Numseen[S_RIGHT_WAY] != 0) ||
420 1.5 lukem (bat >= 0 && Numseen[safety(bat)] != 0))
421 1.1 cgd switch (End - pp->mileage) {
422 1.1 cgd case 200:
423 1.1 cgd if (pp->nummiles[C_200] == 2)
424 1.1 cgd return FALSE;
425 1.1 cgd card = C_200;
426 1.1 cgd /* FALLTHROUGH */
427 1.1 cgd case 100:
428 1.1 cgd case 75:
429 1.1 cgd if (card == -1)
430 1.1 cgd card = (End - pp->mileage == 75 ? C_75 : C_100);
431 1.1 cgd if (spd == C_LIMIT)
432 1.1 cgd return Numseen[S_RIGHT_WAY] == 0;
433 1.1 cgd case 50:
434 1.1 cgd case 25:
435 1.1 cgd if (card == -1)
436 1.1 cgd card = (End - pp->mileage == 25 ? C_25 : C_50);
437 1.1 cgd return Numseen[card] != Numcards[card];
438 1.1 cgd }
439 1.1 cgd return FALSE;
440 1.1 cgd }
441 1.1 cgd
442 1.5 lukem int
443 1.1 cgd canplay(pp, op, card)
444 1.6 jsm const PLAY *pp, *op;
445 1.5 lukem CARD card;
446 1.1 cgd {
447 1.1 cgd switch (card) {
448 1.1 cgd case C_200:
449 1.1 cgd if (pp->nummiles[C_200] == 2)
450 1.1 cgd break;
451 1.1 cgd /* FALLTHROUGH */
452 1.1 cgd case C_75: case C_100:
453 1.1 cgd if (pp->speed == C_LIMIT)
454 1.1 cgd break;
455 1.1 cgd /* FALLTHROUGH */
456 1.1 cgd case C_50:
457 1.1 cgd if (pp->mileage + Value[card] > End)
458 1.1 cgd break;
459 1.1 cgd /* FALLTHROUGH */
460 1.1 cgd case C_25:
461 1.1 cgd if (pp->can_go)
462 1.1 cgd return TRUE;
463 1.1 cgd break;
464 1.1 cgd case C_EMPTY: case C_FLAT: case C_CRASH:
465 1.1 cgd case C_STOP:
466 1.1 cgd if (op->can_go && op->safety[safety(card) - S_CONV] != S_PLAYED)
467 1.1 cgd return TRUE;
468 1.1 cgd break;
469 1.1 cgd case C_LIMIT:
470 1.1 cgd if (op->speed != C_LIMIT &&
471 1.1 cgd op->safety[S_RIGHT_WAY] != S_PLAYED &&
472 1.1 cgd op->mileage + 50 < End)
473 1.1 cgd return TRUE;
474 1.1 cgd break;
475 1.1 cgd case C_GAS: case C_SPARE: case C_REPAIRS:
476 1.1 cgd if (pp->battle == opposite(card))
477 1.1 cgd return TRUE;
478 1.1 cgd break;
479 1.1 cgd case C_GO:
480 1.1 cgd if (!pp->can_go &&
481 1.1 cgd (isrepair(pp->battle) || pp->battle == C_STOP))
482 1.1 cgd return TRUE;
483 1.1 cgd break;
484 1.1 cgd case C_END_LIMIT:
485 1.1 cgd if (pp->speed == C_LIMIT)
486 1.1 cgd return TRUE;
487 1.1 cgd }
488 1.1 cgd return FALSE;
489 1.1 cgd }
490