Example #1
0
void FindWinner::buildWinningMovesSet()
{
  winningMoves_m.clear();
  IntSet moves;

  moves.clear();

  for ( int row = 0; row < WINNER_ARRAY_ROWS; row++ )
  {
    for ( int col = 0; col < WINNER_ARRAY_COLS; col++ )
    {
      moves.insert(winningMovesArray_m[row][col]);
    }
   
    winningMoves_m.insert(moves);
    moves.clear();
  }

}
Example #2
0
void FindWinner::buildBlockedMovesVector()
{
  // Clear out the vector
  blockedMoves_m.clear();

  // Create a set of int sets to load into the vector
  IntSetSet setOfSets;

  // Create a set of ints to load into the set of int sets
  IntSet currentSet;

  int* array_p = blockedMovesArray_m;

  int move1 = 0;
  int move2 = 0;

  for ( int i = 0; i < FW_POSSIBLE_MOVES; i++ )
  {
    // Read the first number out of the set and move the pointer
    if ( i != *array_p )
      throw runtime_error("Problem in blockedMovesArray reader");

    array_p++;

    // While the value referred to by the pointer isn't 0, get two 
    // numbers, put them in a set, then put that set into the current 
    // set of sets, and clear that set.

    while ( BMA_END_MARKER != *array_p )
    {
      move1 = *array_p++;
      move2 = *array_p++;

      currentSet.insert(move1);
      currentSet.insert(move2);

      setOfSets.insert(currentSet);

      currentSet.clear();
    }

    // When the pointer is at a 0, add the set of sets to the
    // vector, clear the set of sets, and move the pointer

    blockedMoves_m.push_back(setOfSets);
    setOfSets.clear();

    array_p++;
  }
}