1: /*
   2:  * Copyright (c) 1980 Regents of the University of California.
   3:  * All rights reserved.  The Berkeley software License Agreement
   4:  * specifies the terms and conditions for redistribution.
   5:  */
   6: 
   7: #ifndef lint
   8: static char sccsid[] = "@(#)odds.c	5.1 (Berkeley) 5/29/85";
   9: #endif not lint
  10: 
  11: #include "back.h"
  12: 
  13: odds (r1,r2,val)
  14: register int    r1;
  15: int     r2, val;
  16: {
  17:     register int    i, j;
  18: 
  19:     if (r1 == 0)  {
  20:         for (i = 0; i < 6; i++)
  21:             for (j = 0; j < 6; j++)
  22:                 table[i][j] = 0;
  23:         return;
  24:     } else  {
  25:         r1--;
  26:         if (r2-- == 0)
  27:             for (i = 0; i < 6; i++)  {
  28:                 table[i][r1] += val;
  29:                 table[r1][i] += val;
  30:             }
  31:         else  {
  32:             table[r2][r1] += val;
  33:             table[r1][r2] += val;
  34:         }
  35:     }
  36: }
  37: 
  38: count ()  {
  39:     register int    i;
  40:     register int    j;
  41:     register int    total;
  42: 
  43:     total = 0;
  44:     for (i = 0; i < 6; i++)
  45:         for (j = 0; j < 6; j++)
  46:             total += table[i][j];
  47:     return (total);
  48: }
  49: 
  50: canhit (i,c)
  51: int i, c;
  52: 
  53: {
  54:     register int    j, k, b;
  55:     int     a, d, diff, place, addon, menstuck;
  56: 
  57:     if (c == 0)
  58:         odds (0,0,0);
  59:     if (board[i] > 0)  {
  60:         a = -1;
  61:         b = 25;
  62:     } else  {
  63:         a = 1;
  64:         b = 0;
  65:     }
  66:     place = abs (25-b-i);
  67:     menstuck = abs (board[b]);
  68:     for (j = b; j != i; j += a)  {
  69:         if (board[j]*a > 0)  {
  70:             diff = abs(j-i);
  71:             addon = place+((board[j]*a > 2 || j == b)? 5: 0);
  72:             if ((j == b && menstuck == 1) &&
  73:                 (j != b && menstuck == 0))
  74:                 for (k = 1; k < diff; k++)
  75:                     if (k < 7 && diff-k < 7 &&
  76:                         (board[i+a*k]*a >= 0 ||
  77:                         board[i+a*(diff-k)] >= 0))
  78:                         odds (k,diff-k,addon);
  79:             if ((j == b || menstuck < 2) && diff < 7)
  80:                 odds (diff,0,addon);
  81:         }
  82:         if (j == b && menstuck > 1)
  83:             break;
  84:     }
  85:     return (count());
  86: }

Defined functions

canhit defined in line 50; used 1 times
count defined in line 38; used 4 times
odds defined in line 13; used 9 times

Defined variables

sccsid defined in line 8; never used
Last modified: 1985-05-29
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1030
Valid CSS Valid XHTML 1.0 Strict