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[] = "@(#)one.c	5.1 (Berkeley) 5/29/85";
   9: #endif not lint
  10: 
  11: #include "back.h"
  12: 
  13: makmove (i)
  14: register int    i;
  15: 
  16: {
  17:     register int    n, d;
  18:     int     max;
  19: 
  20:     d = d0;
  21:     n = abs(g[i]-p[i]);
  22:     max = (*offptr < 0? 7: last());
  23:     if (board[p[i]]*cturn <= 0)
  24:         return (checkd(d)+2);
  25:     if (g[i] != home && board[g[i]]*cturn < -1)
  26:         return (checkd(d)+3);
  27:     if (i || D0 == D1)  {
  28:         if (n == max? D1 < n: D1 != n)
  29:             return (checkd(d)+1);
  30:     } else  {
  31:         if (n == max? D0 < n && D1 < n: D0 != n && D1 != n)
  32:             return (checkd(d)+1);
  33:         if (n == max? D0 < n: D0 != n)  {
  34:             if (d0)
  35:                 return (checkd(d)+1);
  36:             swap;
  37:         }
  38:     }
  39:     if (g[i] == home && *offptr < 0)
  40:         return (checkd(d)+4);
  41:     h[i] = 0;
  42:     board[p[i]] -= cturn;
  43:     if (g[i] != home)  {
  44:         if (board[g[i]] == -cturn)  {
  45:             board[home] -= cturn;
  46:             board[g[i]] = 0;
  47:             h[i] = 1;
  48:             if (abs(bar-g[i]) < 7)  {
  49:                 (*inopp)--;
  50:                 if (*offopp >= 0)
  51:                     *offopp -= 15;
  52:             }
  53:         }
  54:         board[g[i]] += cturn;
  55:         if (abs(home-g[i]) < 7 && abs(home-p[i]) > 6)  {
  56:             (*inptr)++;
  57:             if (*inptr+*offptr == 0)
  58:                 *offptr += 15;
  59:         }
  60:     } else {
  61:         (*offptr)++;
  62:         (*inptr)--;
  63:     }
  64:     return (0);
  65: }
  66: 
  67: moverr (i)
  68: register int    i;
  69: 
  70: {
  71:     register int    j;
  72: 
  73:     if (tflag)
  74:         curmove (20,0);
  75:     else
  76:         writec ('\n');
  77:     writel ("Error:  ");
  78:     for (j = 0; j <= i; j++)  {
  79:         wrint (p[j]);
  80:         writec ('-');
  81:         wrint (g[j]);
  82:         if (j < i)
  83:             writec (',');
  84:     }
  85:     writel ("... ");
  86:     movback (i);
  87: }
  88: 
  89: 
  90: checkd (d)
  91: register int    d;
  92: 
  93: {
  94:     if (d0 != d)
  95:         swap;
  96:     return (0);
  97: }
  98: 
  99: last ()  {
 100:     register int    i;
 101: 
 102:     for (i = home-6*cturn; i != home; i += cturn)
 103:         if (board[i]*cturn > 0)
 104:             return (abs(home-i));
 105: }
 106: 
 107: movback (i)
 108: register int    i;
 109: 
 110: {
 111:     register int    j;
 112: 
 113:     for (j = i-1; j >= 0; j--)
 114:         backone(j);
 115: }
 116: 
 117: backone (i)
 118: register int    i;
 119: 
 120: {
 121:     board[p[i]] += cturn;
 122:     if (g[i] != home)  {
 123:         board[g[i]] -= cturn;
 124:         if (abs(g[i]-home) < 7 && abs(p[i]-home) > 6)  {
 125:             (*inptr)--;
 126:             if (*inptr+*offptr < 15 && *offptr >= 0)
 127:                 *offptr -= 15;
 128:         }
 129:     } else  {
 130:         (*offptr)--;
 131:         (*inptr)++;
 132:     }
 133:     if (h[i])  {
 134:         board[home] += cturn;
 135:         board[g[i]] = -cturn;
 136:         if (abs(bar-g[i]) < 7)  {
 137:             (*inopp)++;
 138:             if (*inopp+*offopp == 0)
 139:                 *offopp += 15;
 140:         }
 141:     }
 142: }

Defined functions

backone defined in line 117; used 2 times
checkd defined in line 90; used 6 times
last defined in line 99; used 1 times
  • in line 22
moverr defined in line 67; used 4 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: 2720
Valid CSS Valid XHTML 1.0 Strict