home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / OPENSTEP / Games / NeXTGo-3.0-MIS / fioe.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-07-06  |  1.8 KB  |  63 lines

  1. #include "comment.header"
  2.  
  3. /* $Id: fioe.c,v 1.3 1997/07/06 19:34:59 ergo Exp $ */
  4.  
  5. /*
  6.  * $Log: fioe.c,v $
  7.  * Revision 1.3  1997/07/06 19:34:59  ergo
  8.  * actual version
  9.  *
  10.  * Revision 1.2  1997/05/04 18:57:04  ergo
  11.  * added time control for moves
  12.  *
  13.  */
  14.  
  15. extern unsigned char p[19][19];
  16. extern int MAXX, MAXY;
  17. extern int currentStone;
  18.  
  19. int fioe(int i, int j)
  20. {
  21.   /* check top edge */
  22.   if (i == 0)
  23.     {
  24.       if ((j == 0) && ((p[1][0] == currentStone) && (p[0][1] == currentStone))) return 1;
  25.       if ((j == MAXY - 1) && ((p[1][MAXY - 1] == currentStone) && (p[0][MAXY - 2] == currentStone))) return 1;
  26.       if ((p[1][j] == currentStone) &&
  27.       ((p[0][j - 1] == currentStone) && (p[0][j + 1] == currentStone))) return 1;
  28.       else
  29.     return 0;
  30.     }
  31.   /* check bottom edge */
  32.   if (i == MAXX - 1)
  33.     {
  34.       if ((j == 0) && ((p[MAXX - 2][0] == currentStone) && (p[MAXX - 1][1] == currentStone))) return 1;
  35.       if ((j == MAXY - 1) && ((p[MAXX - 2][MAXY - 1] == currentStone) && (p[MAXX - 1][MAXY - 2] == currentStone))) return 1;
  36.       if ((p[MAXX - 2][j] == currentStone) &&
  37.       ((p[MAXX - 1][j - 1] == currentStone) && (p[MAXX - 1][j + 1] == currentStone)))
  38.     return 1;
  39.       else
  40.     return 0;
  41.     }
  42.   /* check left edge */
  43.   if (j == 0)
  44.     if ((p[i][1] == currentStone) &&
  45.     ((p[i - 1] [0] == currentStone) && (p[i + 1][0] == currentStone)))
  46.       return 1;
  47.     else
  48.       return 0;
  49.   /* check right edge */
  50.   if (j == MAXY - 1)
  51.     if ((p[i][MAXY - 2] == currentStone) &&
  52.     ((p[i - 1][MAXY - 1] == currentStone) && (p[i + 1][MAXY - 1] == currentStone)))
  53.       return 1;
  54.     else
  55.       return 0;
  56.   /* check center pieces */
  57.   if (((p[i][j - 1] == currentStone) && (p[i][j + 1] == currentStone)) &&
  58.       ((p[i - 1][j] == currentStone) && (p[i + 1][j] == currentStone)))
  59.     return 1;
  60.   else
  61.     return 0;
  62. }  /* fioe */
  63.