|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1980 Regents of the University of California. ! 3: * All rights reserved. ! 4: * ! 5: * Redistribution and use in source and binary forms are permitted ! 6: * provided that: (1) source distributions retain this entire copyright ! 7: * notice and comment, and (2) distributions including binaries display ! 8: * the following acknowledgement: ``This product includes software ! 9: * developed by the University of California, Berkeley and its contributors'' ! 10: * in the documentation or other materials provided with the distribution ! 11: * and in all advertising materials mentioning features or use of this ! 12: * software. Neither the name of the University nor the names of its ! 13: * contributors may be used to endorse or promote products derived ! 14: * from this software without specific prior written permission. ! 15: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR ! 16: * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED ! 17: * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ! 18: */ ! 19: ! 20: #ifndef lint ! 21: static char sccsid[] = "@(#)odds.c 5.4 (Berkeley) 6/1/90"; ! 22: #endif /* not lint */ ! 23: ! 24: #include "back.h" ! 25: ! 26: odds (r1,r2,val) ! 27: register int r1; ! 28: int r2, val; ! 29: { ! 30: register int i, j; ! 31: ! 32: if (r1 == 0) { ! 33: for (i = 0; i < 6; i++) ! 34: for (j = 0; j < 6; j++) ! 35: table[i][j] = 0; ! 36: return; ! 37: } else { ! 38: r1--; ! 39: if (r2-- == 0) ! 40: for (i = 0; i < 6; i++) { ! 41: table[i][r1] += val; ! 42: table[r1][i] += val; ! 43: } ! 44: else { ! 45: table[r2][r1] += val; ! 46: table[r1][r2] += val; ! 47: } ! 48: } ! 49: } ! 50: ! 51: count () { ! 52: register int i; ! 53: register int j; ! 54: register int total; ! 55: ! 56: total = 0; ! 57: for (i = 0; i < 6; i++) ! 58: for (j = 0; j < 6; j++) ! 59: total += table[i][j]; ! 60: return (total); ! 61: } ! 62: ! 63: canhit (i,c) ! 64: int i, c; ! 65: ! 66: { ! 67: register int j, k, b; ! 68: int a, d, diff, place, addon, menstuck; ! 69: ! 70: if (c == 0) ! 71: odds (0,0,0); ! 72: if (board[i] > 0) { ! 73: a = -1; ! 74: b = 25; ! 75: } else { ! 76: a = 1; ! 77: b = 0; ! 78: } ! 79: place = abs (25-b-i); ! 80: menstuck = abs (board[b]); ! 81: for (j = b; j != i; j += a) { ! 82: if (board[j]*a > 0) { ! 83: diff = abs(j-i); ! 84: addon = place+((board[j]*a > 2 || j == b)? 5: 0); ! 85: if ((j == b && menstuck == 1) && ! 86: (j != b && menstuck == 0)) ! 87: for (k = 1; k < diff; k++) ! 88: if (k < 7 && diff-k < 7 && ! 89: (board[i+a*k]*a >= 0 || ! 90: board[i+a*(diff-k)] >= 0)) ! 91: odds (k,diff-k,addon); ! 92: if ((j == b || menstuck < 2) && diff < 7) ! 93: odds (diff,0,addon); ! 94: } ! 95: if (j == b && menstuck > 1) ! 96: break; ! 97: } ! 98: return (count()); ! 99: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.