home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / gnushogi-1.1 / src / gnupdisp.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-04-22  |  1.7 KB  |  110 lines

  1.  
  2. #include "gnushogi.h"
  3.  
  4. #include "pattern.h"
  5.  
  6.  
  7. #define NO_MAIN
  8.  
  9. #include "version.h"
  10.  
  11. #include "main.c"
  12.  
  13.  
  14. /*
  15.  
  16. small_short PieceCnt[2];
  17. small_short PieceList[2][NO_SQUARES];
  18. small_short PieceIndex[NO_SQUARES];
  19.  
  20. small_short board[NO_SQUARES];
  21. small_short color[NO_SQUARES];
  22.  
  23. */
  24.  
  25. void
  26. test_distance ()
  27. {
  28.   short side, piece, f, t, d;
  29.  
  30.   for ( side = 0; side <= 1; side++ ) {
  31.     printf("SIDE = %d\n",side);
  32.     for ( piece = pawn; piece <= king; piece++ ) {
  33.       printf("PIECE = %d\n",piece);
  34.       for ( f = 0; f < NO_SQUARES; f++ ) {
  35.     printf("FROM %d TO ",f);
  36.     for ( t = 0; t < NO_SQUARES; t++ ) {
  37.       d = piece_distance(side,piece,f,t);
  38.       if ( d != CANNOT_REACH )
  39.         printf("%d:%d ",t,d);
  40.     }
  41.     printf("\n");
  42.       }
  43.     }
  44.   }
  45.  
  46. }
  47.  
  48.  
  49.  
  50. void
  51. main ()
  52.  
  53. {
  54.  
  55.   short d, sq, side; 
  56.   PatternFields pattern;
  57.   char s[80], *Lang = NULL; 
  58.  
  59.   InitConst (Lang);
  60.   Initialize_dist ();
  61.  
  62.   for (sq = 0; sq < NO_SQUARES; sq++ ) {
  63.     board[sq] = no_piece;
  64.     color[sq] = neutral;               
  65.   }                                  
  66.  
  67.   ClearCaptured ();
  68.  
  69.   for (side = 0; side <= 1; side++)
  70.     PieceCnt[side] = -1;
  71.  
  72. #ifdef TEST_DISTANCE
  73.  
  74.   strcpy(s,"g6i k5i g4i p9g p8g r* s3h p7g b8h B* S5f");
  75.  
  76.   if ( string_to_board_color (s) )
  77.     {
  78.       printf("ERROR IN string_to_board_color");
  79.       exit(1);
  80.     }
  81.   else
  82.     {
  83.       UpdateDisplay (0, 0, 1, 0);
  84.     }
  85.  
  86.   strcpy(s,"k8h g7h g6g p9f p8g p7f S5h");
  87.  
  88.   if ( string_to_patternfields (s, &pattern) )
  89.     {
  90.       printf("ERROR IN string_to_patternfields");
  91.       exit(1);
  92.     }
  93.   else
  94.     {
  95.       DisplayPattern (&pattern);
  96.     }
  97.  
  98.   d = pattern_distance (black, &pattern);
  99.  
  100.   printf("distance = %d\n", d);
  101.  
  102. #endif
  103.  
  104.   GetOpeningPatterns ();
  105.   ShowOpeningPatterns ();
  106.      
  107. }
  108.  
  109.  
  110.