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

  1. #include "comment.header"
  2.  
  3. /* $Id: openregn.c,v 1.3 1997/07/06 19:35:04 ergo Exp $ */
  4.  
  5. /*
  6.  * $Log: openregn.c,v $
  7.  * Revision 1.3  1997/07/06 19:35:04  ergo
  8.  * actual version
  9.  *
  10.  * Revision 1.2  1997/05/04 18:57:09  ergo
  11.  * added time control for moves
  12.  *
  13.  */
  14.  
  15. #define EMPTY 0
  16.  
  17. extern unsigned char p[19][19];
  18.  
  19. int openregion(int i1, int j1, int i2, int j2)
  20.      /* check if region from i1, j1 to i2, j2 is open */
  21. {
  22.   int minx, maxx, miny, maxy, x, y;
  23.   
  24.   /* exchange upper and lower limits */
  25.   
  26.   if (i1 < i2)
  27.     {
  28.       miny = i1;
  29.       maxy = i2;
  30.     }
  31.   else
  32.     {
  33.       miny = i2;
  34.       maxy = i1;
  35.     }
  36.   
  37.   if (j1 < j2)
  38.     {
  39.       minx = j1;
  40.       maxx = j2;
  41.     }
  42.   else
  43.     {
  44.       minx = j2;
  45.       maxx = j1;
  46.     }
  47.   
  48.   /* check for empty region */
  49.   for (y = miny; y <= maxy; y++)
  50.     for (x = minx; x <= maxx; x++)
  51.       if (p[y][x] != EMPTY) return 0;
  52.   return 1;
  53. }  /* end openregion */
  54.