|
|
1.1 ! root 1: static char sccsid[] = " odds.c 4.1 82/05/11 "; ! 2: ! 3: #include "back.h" ! 4: ! 5: odds (r1,r2,val) ! 6: register int r1; ! 7: int r2, val; ! 8: { ! 9: register int i, j; ! 10: ! 11: if (r1 == 0) { ! 12: for (i = 0; i < 6; i++) ! 13: for (j = 0; j < 6; j++) ! 14: table[i][j] = 0; ! 15: return; ! 16: } else { ! 17: r1--; ! 18: if (r2-- == 0) ! 19: for (i = 0; i < 6; i++) { ! 20: table[i][r1] += val; ! 21: table[r1][i] += val; ! 22: } ! 23: else { ! 24: table[r2][r1] += val; ! 25: table[r1][r2] += val; ! 26: } ! 27: } ! 28: } ! 29: ! 30: count () { ! 31: register int i; ! 32: register int j; ! 33: register int total; ! 34: ! 35: total = 0; ! 36: for (i = 0; i < 6; i++) ! 37: for (j = 0; j < 6; j++) ! 38: total += table[i][j]; ! 39: return (total); ! 40: } ! 41: ! 42: canhit (i,c) ! 43: int i, c; ! 44: ! 45: { ! 46: register int j, k, b; ! 47: int a, d, diff, place, addon, menstuck; ! 48: ! 49: if (c == 0) ! 50: odds (0,0,0); ! 51: if (board[i] > 0) { ! 52: a = -1; ! 53: b = 25; ! 54: } else { ! 55: a = 1; ! 56: b = 0; ! 57: } ! 58: place = abs (25-b-i); ! 59: menstuck = abs (board[b]); ! 60: for (j = b; j != i; j += a) { ! 61: if (board[j]*a > 0) { ! 62: diff = abs(j-i); ! 63: addon = place+((board[j]*a > 2 || j == b)? 5: 0); ! 64: if ((j == b && menstuck == 1) && ! 65: (j != b && menstuck == 0)) ! 66: for (k = 1; k < diff; k++) ! 67: if (k < 7 && diff-k < 7 && ! 68: (board[i+a*k]*a >= 0 || ! 69: board[i+a*(diff-k)] >= 0)) ! 70: odds (k,diff-k,addon); ! 71: if ((j == b || menstuck < 2) && diff < 7) ! 72: odds (diff,0,addon); ! 73: } ! 74: if (j == b && menstuck > 1) ! 75: break; ! 76: } ! 77: return (count()); ! 78: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.