Exemple #1
0
void scan(void)
{
    for(uint8 i = 0; i<16; ++i)
    {
        ScanColumn(i);
        PrintColumn(i);
    }
}
Exemple #2
0
/******************************************************************************
*  ScanBoard - scans board for current player's legal moves                   *
******************************************************************************/
BOOLEAN_T
ScanBoard(MyProgram *data, int pr, int pc)
{
   NEIGHBOR_A_T neighbors;


   /*  scan picked cell's neighbors and if any are not all empty scan
    *  each direction until find a legal move in a given direction
    */
   if ( ScanNeighbors(data, pr, pc, neighbors) )
   {
      if ( neighbors[0][0] != PIECE_EMPTY )
      {
         if ( ScanDiag(data, pr, pc, DIR_NW) )
            return(TRUE);
      }

      if ( neighbors[0][1] != PIECE_EMPTY )
      {
         if ( ScanColumn(data, pr, pc, DIR_N) )
            return(TRUE);
      }

      if ( neighbors[0][2] != PIECE_EMPTY )
      {
         if ( ScanDiag(data, pr, pc, DIR_NE) )
            return(TRUE);
      }

      if ( neighbors[1][0] != PIECE_EMPTY )
      {
         if ( ScanRow(data, pr, pc, DIR_W) )
            return(TRUE);
      }

      if ( neighbors[1][2] != PIECE_EMPTY )
      {
         if ( ScanRow(data, pr, pc, DIR_E) )
            return(TRUE);
      }

      if ( neighbors[2][0] != PIECE_EMPTY )
      {
         if ( ScanDiag(data, pr, pc, DIR_SW) )
            return(TRUE);
      }

      if ( neighbors[2][1] != PIECE_EMPTY )
      {
         if ( ScanColumn(data, pr, pc, DIR_S) )
            return(TRUE);
      }

      if ( neighbors[2][2] != PIECE_EMPTY )
      {
         if ( ScanDiag(data, pr, pc, DIR_SE) )
            return(TRUE);
      }
   }

   return(FALSE);
}