Beispiel #1
0
bool DlgMatchResult::isGame3Necessary() const
{
  // is a 3rd game possible?
  //
  // TODO: the number of two won games for a victory is hardcoded here!
  int round = ma.getMatchGroup().getRound();
  bool game3Possible = (ma.getCategory().getMaxNumGamesInRound(round) > 2);
  if (!game3Possible)
  {
    return false;
  }

  // is a third game necessary?
  bool g1Valid = ui->game1Widget->hasValidScore();
  bool g2Valid = ui->game2Widget->hasValidScore();
  if (g1Valid && g2Valid)
  {
    auto sc1 = ui->game1Widget->getScore();
    auto sc2 = ui->game2Widget->getScore();
    assert(sc1 != nullptr);
    assert(sc2 != nullptr);

    return (sc1->getWinner() != sc2->getWinner());
  }

  return false;
}
Beispiel #2
0
void DlgMatchResult::updateControls()
{
  // is a third game necessary?
  bool game3Necessary = isGame3Necessary();

  // enable or disable the widget for the 3rd game
  ui->game3Widget->setEnabled(game3Necessary);

  // is the currently selected result valid?
  bool validResult = hasValidResult();

  // enable or disable the okay-button
  ui->btnOkay->setEnabled(validResult);

  // hide the winner / loser / draw labels if we have no valid result
  if (!validResult)
  {
    ui->laWinnerName->setVisible(false);
    ui->laLoserName->setVisible(false);
    ui->laDraw->setVisible(false);
  } else {
    auto sc1 = ui->game1Widget->getScore();
    auto sc2 = ui->game2Widget->getScore();
    assert(sc1 != nullptr);
    assert(sc2 != nullptr);

    // switch the "draw" label on or off
    bool isDraw = (!game3Necessary && (sc1->getWinner() != sc2->getWinner()));
    ui->laDraw->setVisible(isDraw);

    // switch / set the winner label
    auto matchScore = getMatchScore();
    assert(matchScore != nullptr);
    QString winnerLabel;
    QString loserLabel;
    if (matchScore->getWinner() == 1)
    {
      winnerLabel = ma.getPlayerPair1().getDisplayName();
      loserLabel = ma.getPlayerPair2().getDisplayName();
    } else {
      winnerLabel = ma.getPlayerPair2().getDisplayName();
      loserLabel = ma.getPlayerPair1().getDisplayName();
    }
    if (!isDraw)
    {
      ui->laWinnerName->setVisible(true);
      ui->laWinnerName->setText(tr("Winner: ") + winnerLabel);
      ui->laLoserName->setVisible(true);
      ui->laLoserName->setText(tr("Loser: ") + loserLabel);
    } else {
      ui->laWinnerName->setVisible(false);
      ui->laLoserName->setVisible(false);
    }
  }

}
bool GameOver::_isWinnerSet(const mgen::FieldSetDepth depth) const {
	if (depth == mgen::SHALLOW) {
		return _m_winner_isSet;
	} else {
		return _m_winner_isSet && mgen::validation::validateFieldDeep(getWinner());
	}
}
Beispiel #4
0
void Babality::onFinish(std::string name){
	Character* winner = getWinner(name);
	SoundManager::Instance()->playSoundOnce("baby_cry", 0);
	winner->setMovement(VICTORY_MOVEMENT);
	winner->setCurrentSprite();
	winner->isVictory = true;

}
Beispiel #5
0
int main(int argc, const char * argv[]) {
    file = fopen(path, "r");
    
	// RKS NOTE: Get file line by line
    while(fgets(line, 30, file) > 0) {
        char *cards = strtok(line, " ");

		char player1[10];
		char player2[10];

		int counter = 1;

		int cardCounterPlayer1 = 0;
        int cardCounterPlayer2 = 0;

		// RKS NOTE: Start reading first card
		player1[cardCounterPlayer1++] = cards[0];
        player1[cardCounterPlayer1++] = cards[1];
		
		// RKS NOTE: Let's separate who plays WTF
		while (cards != NULL) {
			cards = strtok(NULL, " ");
			
			if (cards != NULL) {
				if (counter < 5) {
					player1[cardCounterPlayer1++] = cards[0];
                    player1[cardCounterPlayer1++] = cards[1];
				} else {
					player2[cardCounterPlayer2++] = cards[0];
                    player2[cardCounterPlayer2++] = cards[1];
				}
			}
			
			counter++;
		}
        
        // RKS NOTE: Calculate who wins!
        if (counter > 2) {
            int winner = getWinner(player1, player2);

            if (winner == 0) {
                scorePlayer1++;
            } else if (winner == 1) {
                scorePlayer2++;
            } else {
                scoreDraw++;
            }
        }
    }
    
    fclose(file);
    
    printf("SCORE Player 1: %i\n", scorePlayer1);
    printf("SCORE Player 2: %i\n", scorePlayer2);
    printf("SCORE Empates: %i\n", scoreDraw);
}
bool GameOver::operator==(const GameOver& other) const {
	return true
		 && _isReasonSet(mgen::SHALLOW) == other._isReasonSet(mgen::SHALLOW)
		 && _isWinnerSet(mgen::SHALLOW) == other._isWinnerSet(mgen::SHALLOW)
		 && _isLoserSet(mgen::SHALLOW) == other._isLoserSet(mgen::SHALLOW)
		 && _isEndStateSet(mgen::SHALLOW) == other._isEndStateSet(mgen::SHALLOW)
		 && getReason() == other.getReason()
		 && getWinner() == other.getWinner()
		 && getLoser() == other.getLoser()
		 && getEndState() == other.getEndState();
}
Beispiel #7
0
   void SOM::train(const float *input){
     // {{{ open
 
     const Neuron &s = getWinner(input);
     
     for(unsigned int i=0;i<m_vecNeurons.size();++i){
       Neuron &r = m_vecNeurons[i];
       for(unsigned int d=0;d<m_uiDataDim;++d){
         r.prototype.get()[d] += m_fEpsilon * som::def_h_func(s.gridpos.get(),r.gridpos.get(),m_fSigma,m_uiSomDim) * ( input[d]-r.prototype.get()[d] );
       }
     }
   }
Beispiel #8
0
void Babality::onPreFinish(std::string name){
	SoundManager::Instance()->playSoundOnce("pre_babality", 0);
	SDL_Delay(2000);
	Character* victim = getVictim(name);
	Character* winner = getWinner(name);
	winner->setMovement("");
	winner->isBabality = true;
	victim->setMovement(BABALITY_MOVEMENT);
	victim->isLazy = false;
	victim->setCurrentSprite();
	victim->isBabality = true;
}
Beispiel #9
0
void runGame (void) {
    // create a dummy game
    int disciplines[] = DEFAULT_DISCIPLINES;
    int dice[] = DEFAULT_DICE;
    Game g = newGame (disciplines, dice);
    
    printf ("Running a test game...\n");
    // roll the dice
    int diceScore;
    diceScore = rollDice ();
    // progress the game
    throwDice (g, diceScore);
    
    printf ("Deciding on the action...\n");
    action newAction;
    newAction = decideAction (g);
    while (!getWinner (g)) {
        // if the player PASSES
        if (newAction.actionCode == PASS) {
            diceScore = rollDice ();
            // progress the game
            throwDice (g, diceScore);
        }
        else
        {
            if (isLegalAction (g, newAction)) {
                makeAction (g, newAction);
            } else {
                printf (">>> I'm sorry but you can't do that!\n");
            }
        }
        // get the next turn
        newAction = decideAction (g);
        
    }
    // the game is over
    printf ("\nGame over. Player %d wins\n", getWinner (g));
    disposeGame (g);
}
Beispiel #10
0
int heuristicForState(GameState* gs, int player, int other) {
	if (isDraw(gs))
		return 0;

	int term_stat = getWinner(gs);
	if (term_stat == player)
		return 1000;

	if (term_stat)
		return -1000;

	
	return getHeuristic(gs, player, other);
		     
}
Beispiel #11
0
void checkWin(GameState* gs) {
	int win = getWinner(gs);
	
	if (win) {
		printf("Game over! %d wins!\n", win);
		printGameState(gs);
		exit(0);
	}

	if (isDraw(gs)) {
		printf("Game over! Draw!\n");
		printGameState(gs);
		exit(0);
	}
	     
}
//Dumb play - a random move
int dumbPlay(int pieceType)
{
  int randomColumn;
  randomColumn = rand()%GRID_N;//0 to GRID_N -1 number
  
  //End if board is full
  if(boardFull())
  {
    if(isParent)
    {
      gameOver(EMPTY_SPACE);
      return -1;
    }
    else
    {
      return -1;
    }
  }
  
  while(columnFull(randomColumn))
  {
    //That column is full
    //Generate another random one
    //Reseed
    //srand(time(NULL));
    randomColumn = rand()%GRID_N;//0 to GRID_N -1 number
  }
  
  //Got a column that is not full
  //Place piece there
  placePiece(randomColumn,pieceType);
  
  //Check that we did not just randomly win
   if(getWinner(pieceType) == pieceType)
   {
      if(isParent)
      {
	//Call game over function
	gameOver(pieceType);
      }
      else
      {
	 return randomColumn;
      }
   }
   return randomColumn;
}
Beispiel #13
0
int main(void) {
	fillDeck();
	shuffleDeck();
	passCard(playerHand, Player);
	passCard(playerHand, Player);
	PrintHand();
	printf("You score is (%i).        ", scorePlayerHand);
	do {
		CheckHand();
		Ask();
		Choice();
		PrintHand();
		printf("You score is (%i).    ", scorePlayerHand);
	} while ((userAnswer == 'y' || userAnswer == 'Y'));
	getWinner();
	return 0;
}
MainWindow::MainWindow(QWidget *parent) :
    QWidget(parent)
{
    main_layout = new QGridLayout(this);

    // make game board [ROWSxCOLUMNS]
    for(int i = 0; i < ROWS; i++){
        for(int j = 0; j < COLUMNS; j++){
            Game_cells[i][j] = new GameCells();

            connect(Game_cells[i][j], SIGNAL(gameCellClicked()), this, SLOT(getWinner()));
            main_layout->addWidget(Game_cells[i][j], i, j);
            }
        }

    Game_cells[0][0]->setMaxMoveNumber(max_move);

    this->setLayout(main_layout);
    this->setWindowTitle("tic-tac-toe");
}
void waitForChildMove(int childIndex)
{ 
  //Get move from reading
  int columnRead = readTurn(receiveIDs[childIndex]);
  
  //Make this move on parent board
  //Set the child board as the active board
  activeBoard = &parentBoardsArray[childIndex];
  
  placePiece(columnRead, CHILD_PIECE);
  
  //Check for full and win
  if(getWinner(CHILD_PIECE) == CHILD_PIECE)
  {
    //Child won
    gameOver(CHILD_PIECE);
  }
  else if(boardFull())
  {
    gameOver(EMPTY_SPACE);
  } 
}
Beispiel #16
0
void sortsPerformanceHybridVsMergeVsMergeBu()
{
	int startVal = 100;
	int endVal = pow(startVal, 4);
	int numRepeat = 1;
	
	for (int i = startVal; i <= endVal; i *= 10)
	{
		double mergeTime = sortTime(0, i, numRepeat);
		double hybridTime = sortTime(2, i, numRepeat);
		double mergeBuTime = sortTime(3, i, numRepeat);
		
		cout << "n: " << i << "   ";
		cout << "merge   : " << mergeTime << " | ";
		cout << "hybrid  : " << hybridTime << " | ";
		cout << "mergeBu : " << mergeBuTime << " ";
		cout << " >>  ";
		
		cout << getWinner(mergeTime, mergeBuTime, hybridTime);
		cout << endl;
	}
}
int main(int argc, char *argv[]) {
    int disciplines[] = DEFAULT_DISCIPLINES;
    disciplines[2] = STUDENT_BPS;
    disciplines[7] = STUDENT_BPS;
    disciplines[11] = STUDENT_BQN;
    disciplines[16] = STUDENT_BQN;
    int dice[] = DEFAULT_DICE;
    int i = 0;
    int automation = TRUE;
    int diceRoll = 1;
    char *vertices[54];
    char *sides[72];

    //nanosecond seeding
    struct timespec ts;
    clock_gettime(CLOCK_MONOTONIC, &ts);

    populatePaths(vertices);
    populateSides(sides);

    printf("Automatic(1) or Human(0): ");
    scanf("%d", &automation);

    //seeding starts now
    srand((time_t)ts.tv_nsec);

    Game g = newGame(disciplines, dice);
    action a;

    while(getKPILeader(g) < 150  &&  getTurnNumber(g) < 9003) {
        if(automation == FALSE) {
            printf("Enter dice roll: ");
            scanf("%d", &diceRoll);
        } else {
            diceRoll = rand() % 10 + 2;
        }

        throwDice(g, diceRoll);
        printf("diceRoll = %d\n", diceRoll);

        printf("\n");
        printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
        printf("Turn: %d\n", getTurnNumber(g));
        printf("Player %d's turn\n", getWhoseTurn(g));

        printf("\n");
        printf("You have %d ARCs\n", getARCs(g, getWhoseTurn(g)));
        i = 0;
        while(i < 72) {
            if(getARC(g, sides[i]) == getWhoseTurn(g)) { 
                printf("You have an ARC on %s\\0\n", sides[i]);
            }
            i++;
        }
        printf("You have %d Campuses\n", getCampuses(g, getWhoseTurn(g)));
        printf("You have %d GO8s\n", getGO8s(g, getWhoseTurn(g)));
        i = 0;
        while(i < 54) {
            if(getCampus(g, vertices[i]) == getWhoseTurn(g)) { 
                printf("You have a campus on %s\\0\n", vertices[i]);
            }
            if(getCampus(g, vertices[i]) == getWhoseTurn(g) + 3) {
                printf("You have a GO8 on %s\\0\n", vertices[i]);
            }
            i++;
        }
        printf("You have %d Publications\n", getPublications(g, getWhoseTurn(g)));
        printf("You have %d IP Patents\n", getIPs(g, getWhoseTurn(g)));
        printf("\n");
        
        printf("Students:\n");
        printf("You have %d THD Students\n", getStudents(g, getWhoseTurn(g), STUDENT_THD));
        printf("You have %d BPS Students\n", getStudents(g, getWhoseTurn(g), STUDENT_BPS));
        printf("You have %d BQN Students\n", getStudents(g, getWhoseTurn(g), STUDENT_BQN));
        printf("You have %d MJ Students\n", getStudents(g, getWhoseTurn(g), STUDENT_MJ));
        printf("You have %d MTV Students\n", getStudents(g, getWhoseTurn(g), STUDENT_MTV));
        printf("You have %d MMONEY Students\n", getStudents(g, getWhoseTurn(g), STUDENT_MMONEY));
        printf("\n");

        if(automation == FALSE) {
            a = getHumanAction();
        } else {
            a = getAIAction(g);
        }

        while(a.actionCode != PASS) {
            if(isLegalAction(g, a)) {
                if(a.actionCode == START_SPINOFF) {
                    if(rand() % 3 > 1) {
                        a.actionCode = OBTAIN_IP_PATENT;
                    } else {
                        a.actionCode = OBTAIN_PUBLICATION;
                    }
                }
                makeAction(g, a);
            } else {
                printf("Illegal Action");
            }
            printf("\n");
            printf("Player %d's turn\n", getWhoseTurn(g));

            printf("You have %d ARCs\n", getARCs(g, getWhoseTurn(g)));
            printf("You have %d Campuses\n", getCampuses(g, getWhoseTurn(g)));
            printf("You have %d GO8s\n", getGO8s(g, getWhoseTurn(g)));
            printf("You have %d Publications\n", getPublications(g, getWhoseTurn(g)));
            printf("You have %d IP Patents\n", getIPs(g, getWhoseTurn(g)));
            printf("\n");
            printf("Students:\n");
            printf("You have %d THD Students\n", getStudents(g, getWhoseTurn(g), STUDENT_THD));
            printf("You have %d BPS Students\n", getStudents(g, getWhoseTurn(g), STUDENT_BPS));
            printf("You have %d BQN Students\n", getStudents(g, getWhoseTurn(g), STUDENT_BQN));
            printf("You have %d MJ Students\n", getStudents(g, getWhoseTurn(g), STUDENT_MJ));
            printf("You have %d MTV Students\n", getStudents(g, getWhoseTurn(g), STUDENT_MTV));
            printf("You have %d MMONEY Students\n", getStudents(g, getWhoseTurn(g), STUDENT_MMONEY));
            printf("\n");

            if(automation == FALSE) {
                a = getHumanAction();
            } else {
                a = getAIAction(g);
            }

        }
        printf("Player 1 KPI points : %d\n", getKPIpoints(g, UNI_A));
        printf("Player 2 KPI points : %d\n", getKPIpoints(g, UNI_B));
        printf("Player 3 KPI points : %d\n", getKPIpoints(g, UNI_C));
    }
    printf("Winner: Player %d\n", getWinner(g));    
    disposeGame(g);
    return EXIT_SUCCESS;
}
Beispiel #18
0
int isGameWon() {
	return getWinner(globalState);
}
Beispiel #19
0
void Tron::paintEvent(QPaintEvent *e)
{
	QPainter p(this);

	p.drawPixmap(e->rect().topLeft(), *Renderer::self()->getPlayField(), e->rect());

	if (gamePaused) // if game is paused, print message
	{
		QString message = i18n("Game paused");
		QPixmap messageBox = Renderer::self()->messageBox(message);
		QPoint point(width() / 2 - messageBox.width() / 2, height() / 2 - messageBox.height() / 2);
		p.drawPixmap(point, messageBox, e->rect());
	}
	else if (gameEnded) // If game ended, print "Crash!"
	{
		QString message = QString();

		if (Settings::gameType() != Settings::EnumGameType::Snake) {
			if (hasWinner())
			{
				int winner = getWinner();
				int loser = 1 - winner;

				QString winnerName = players[winner]->getName();
				QString loserName = players[loser]->getName();
				int winnerScore = players[winner]->getScore();
				int loserScore = players[loser]->getScore();

				message += i18np("%1 has won versus %2 with %4 versus %3 point!", "%1 has won versus %2 with %4 versus %3 points!", winnerName, loserName, loserScore, winnerScore);
				message += QLatin1Char( '\n' );
			}
			else
			{
				QString name1 = players[0]->getName();
				QString name2 = players[1]->getName();
				int points1 = players[0]->getScore();
				int points2 = players[1]->getScore();

				message += i18nc("%2 = 'x points' [player %1], %4 = 'x points' [player %3]",
					"%1 (%2) versus %3 (%4)",
					name2, i18np("%1 point", "%1 points", points2),
					name1, i18np("%1 point", "%1 points", points1));
				message += QLatin1Char( '\n' );
			}
		}
		else
		{
			int points = players[0]->getScore();

			message += i18np("KSnake game ended with 1 point", "KSnake game ended with %1 points", points);
			message += QLatin1Char( '\n' );
		}

		if (Settings::gameType() == Settings::EnumGameType::PlayerVSPlayer) {
			message += i18n("The game starts when each player has pressed one of their direction keys!");
		}
		else {
			message += i18n("Press any of your direction keys to start!");
		}

		QPixmap messageBox = Renderer::self()->messageBox(message);
		QPoint point(width() / 2 - messageBox.width() / 2, height() / 2 - messageBox.height() / 2);
		p.drawPixmap(point, messageBox, e->rect());
	}
}
Beispiel #20
0
bool Tron::hasWinner()
{
	return getWinner() == 0 || getWinner() == 1;
}
Beispiel #21
0
int getWeight(GameTreeNode* node, int movesLeft) {
	int toR, move, best_weight;
	if (getWinner(node->gs) || isDraw(node->gs) || movesLeft == 0)
		return heuristicForState(node->gs, node->player, node->other_player);

	GameState** possibleMoves = (GameState**) malloc(sizeof(GameState*) * node->gs->width);
	int validMoves = 0;
	for (int possibleMove = 0; possibleMove < node->gs->width; possibleMove++) {
		if (!canMove(node->gs, possibleMove)) {
			continue;
		}
		
		possibleMoves[validMoves] = stateForMove(node->gs, possibleMove, (node->turn ? node->player : node->other_player));
		validMoves++;
	}

	// order possibleMoves by the heuristic
	g_node = node;
	if (node->turn) {
		// qsort_r is apparently non-standard, and won't work with emscripten. So we'll need to use a global.
		qsort(possibleMoves, validMoves, sizeof(GameState*), ascComp); 
	} else {
		qsort(possibleMoves, validMoves, sizeof(GameState*), desComp); 
	}

	best_weight = (node->turn ? INT_MIN : INT_MAX);

	for (move = 0; move < validMoves; move++) {
		// see if the game state is already in the hash table
		GameState* inTable = lookupInTable(node->ht, possibleMoves[move]);
		int child_weight;
		int child_last_move;
		if (inTable != NULL) {
			child_weight = inTable->weight;
			child_last_move = possibleMoves[move]->last_move;

		} else {
			GameTreeNode* child = newGameTreeNode(possibleMoves[move], node->player, node->other_player, !(node->turn),
							      node->alpha, node->beta, node->ht);
			child_weight = getWeight(child, movesLeft - 1);
			child_last_move = child->gs->last_move;
			free(child);
		}

	

		possibleMoves[move]->weight = child_weight;
		addToTable(node->ht, possibleMoves[move]);

		if (movesLeft == LOOK_AHEAD)
			printf("Move %d has weight %d\n", child_last_move, child_weight);

		// alpha-beta pruning
		if (!node->turn) {
			// min node
			if (child_weight <= node->alpha) {
				// MAX ensures we will never go here
				toR = child_weight;
				goto done;
			}
			node->beta = (node->beta < child_weight ? node->beta : child_weight);
		} else {
			// max node
			if (child_weight >= node->beta) {
				// MIN ensures we will never go here
				toR = child_weight;
				goto done;
			}
			node->alpha = (node->alpha > child_weight ? node->alpha : child_weight);
		}

		if (!(node->turn)) {
			// min node
			if (best_weight > child_weight) {
				best_weight = child_weight;
				node->best_move = child_last_move;
			}
		} else {
			// max node
			if (best_weight < child_weight) {
				best_weight = child_weight;
				node->best_move = child_last_move;
			}
		}

		
	}
	toR = best_weight;
done:
	for (int i = 0; i < validMoves; i++) {
		freeGameState(possibleMoves[i]);
	}

	free(possibleMoves);
	return toR;
}
Beispiel #22
0
void getWinnerTest()
{
        State current;
        PLAYER winner;

        initState(&current);
        current.field[1][1] = PLAYER1;
        current.field[0][0] = PLAYER1;
        current.field[2][2] = PLAYER1;
        getWinner(current, &winner);
        assert(winner == PLAYER1);

        initState(&current);
        current.field[1][1] = PLAYER1;
        current.field[0][2] = PLAYER1;
        current.field[2][0] = PLAYER1;
        getWinner(current, &winner);
        assert(winner == PLAYER1);

        initState(&current);
        current.field[0][0] = PLAYER1;
        current.field[0][1] = PLAYER1;
        current.field[0][2] = PLAYER1;
        getWinner(current, &winner);
        assert(winner == PLAYER1);

        initState(&current);
        current.field[0][0] = PLAYER1;
        current.field[1][0] = PLAYER1;
        current.field[2][0] = PLAYER1;
        getWinner(current, &winner);
        assert(winner == PLAYER1); 
        
        initState(&current);
        current.field[1][1] = PLAYER2;
        current.field[0][0] = PLAYER2;
        current.field[2][2] = PLAYER2;
        getWinner(current, &winner);
        assert(winner == PLAYER2);

        initState(&current);
        current.field[1][1] = PLAYER2;
        current.field[0][2] = PLAYER2;
        current.field[2][0] = PLAYER2;
        getWinner(current, &winner);
        assert(winner == PLAYER2);

        initState(&current);
        current.field[0][0] = PLAYER2;
        current.field[0][1] = PLAYER2;
        current.field[0][2] = PLAYER2;
        getWinner(current, &winner);
        assert(winner == PLAYER2);

        initState(&current);
        current.field[0][0] = PLAYER2;
        current.field[1][0] = PLAYER2;
        current.field[2][0] = PLAYER2;
        getWinner(current, &winner);
        assert(winner == PLAYER2);
}
    pair<double,double> CoCheckersExperiment::playGame(
        shared_ptr<NEAT::GeneticIndividual> ind1,
        shared_ptr<NEAT::GeneticIndividual> ind2
    )
    {
        //You get 1 point just for entering the game, wahooo!
        pair<double,double> rewards(1.0,1.0);

#if DEBUG_GAME_ANNOUNCER
        cout << "Playing game\n";
#endif

        populateSubstrate(ind1,0);
        populateSubstrate(ind2,1);

        uchar b[8][8];

        //cout << "Playing games with HyperNEAT as black\n";
        //for (handCodedType=0;handCodedType<5;handCodedType++)

        for (testCases=0;testCases<2;testCases++)
        {
            if (testCases==0)
            {
                individualBlack = ind1;
                individualWhite = ind2;
            }
            else //testCases==1
            {
                individualBlack = ind2;
                individualWhite = ind1;
            }

            resetBoard(b);

            int retval=-1;
            int rounds=0;

            for (rounds=0;rounds<CHECKERS_MAX_ROUNDS&&retval==-1;rounds++)
            {
                //cout << "Round: " << rounds << endl;
                moveToMake = CheckersMove();

                if (testCases==0)
                {
                    currentSubstrateIndex=0;
                }
                else //testCases==1
                {
                    currentSubstrateIndex=1;
                }

                //cout << "Black is thinking...\n";
                evaluatemax(b,CheckersNEATDatatype(INT_MAX/2),0,2);

#if CHECKERS_EXPERIMENT_DEBUG
                cout << "BLACK MAKING MOVE\n";

                printBoard(b);
#endif

                if (moveToMake.from.x==255)
                {
                    //black loses
                    cout << "BLACK LOSES!\n";
                    retval = WHITE;
                }
                else
                {
                    makeMove(moveToMake,b);
                    retval = getWinner(b,WHITE);
                }

#if CHECKERS_EXPERIMENT_LOG_EVALUATIONS
                memcpy(gameLog[rounds*2],b,sizeof(uchar)*8*8);
#endif

#if COCHECKERS_EXPERIMENT_DEBUG
                printBoard(b);
                CREATE_PAUSE("");
#endif

                if (retval==-1)
                {
                    //printBoard(b);

                    moveToMake = CheckersMove();
                    {
                        //progress_timer t;
                        if (testCases==0)
                        {
                            currentSubstrateIndex=1;
                        }
                        else //testCases==1
                        {
                            currentSubstrateIndex=0;
                        }

                        //cout << "White is thinking...\n";
                        evaluatemin(b,CheckersNEATDatatype(INT_MAX/2),0,3);
                        //cout << "SimpleCheckers time: ";
                    }

#if COCHECKERS_EXPERIMENT_DEBUG
                    cout << "WHITE MAKING MOVE\n";

                    printBoard(b);
#endif

                    if (moveToMake.from.x==255)
                    {
                        //white loses
                        cout << "WHITE LOSES BECAUSE THERE'S NO MOVES LEFT!\n";
                        retval = BLACK;
#if COCHECKERS_EXPERIMENT_DEBUG
                        printBoard(b);
                        CREATE_PAUSE("");
#endif
                    }
                    else
                    {
                        makeMove(moveToMake,b);
                        retval = getWinner(b,BLACK);
                    }

#if COCHECKERS_EXPERIMENT_DEBUG
                    printBoard(b);
                    CREATE_PAUSE("");
#endif
                }

#if CHECKERS_EXPERIMENT_LOG_EVALUATIONS
                memcpy(gameLog[rounds*2+1],b,sizeof(uchar)*8*8);
#endif
            }

            if (retval==BLACK)
            {
#if DEBUG_GAME_ANNOUNCER
                cout << "BLACK WON!\n";
#endif
                if (ind1==individualBlack)
                {
                    rewards.first += 800;
                    rewards.first += (CHECKERS_MAX_ROUNDS-rounds);
                }
                else
                {
                    rewards.second += 800;
                    rewards.second += (CHECKERS_MAX_ROUNDS-rounds);
                }

            }
            else if (retval==-1) //draw
            {
#if DEBUG_GAME_ANNOUNCER
                cout << "WE TIED!\n";
#endif
                //rewards.first += 200;
                //rewards.second += 200;
            }
            else //White wins
            {
#if DEBUG_GAME_ANNOUNCER
                cout << "WHITE WON\n";
#endif
                if (ind1==individualWhite)
                {
                    rewards.first += 800;
                    rewards.first += (CHECKERS_MAX_ROUNDS-rounds);
                }
                else
                {
                    rewards.second += 800;
                    rewards.second += (CHECKERS_MAX_ROUNDS-rounds);
                }
            }

            int whiteMen,blackMen,whiteKings,blackKings;

            //countPieces(gi.board,whiteMen,blackMen,whiteKings,blackKings);
            countPieces(b,whiteMen,blackMen,whiteKings,blackKings);

            if (ind1==individualWhite)
            {
                rewards.first += (2 * (whiteMen) );
                rewards.first += (3 * (whiteKings) );

                rewards.second += (2 * (blackMen) );
                rewards.second += (3 * (blackKings) );
            }
            else
            {
                rewards.first += (2 * (blackMen) );
                rewards.first += (3 * (blackKings) );

                rewards.second += (2 * (whiteMen) );
                rewards.second += (3 * (whiteKings) );
            }
        }

#if DEBUG_GAME_ANNOUNCER
        cout << "Fitness earned: " << rewards.first << " & " << rewards.second << endl;
        CREATE_PAUSE("");
#endif

        return rewards;
    }
//Smart play - intelligently try to win or block child from winning
//Return the colummn that was played
int smartPlay(int pieceType)
{
  //Trying placing piece in every column, checking for win, remove if not a win
  int i;
  for(i=0; i< GRID_N; i++)
  {
    if(columnFull(i)==0)
    {
      //Column is not full
      //Place peice
      placePiece(i,pieceType);
      //Check for win only if parent
      if(getWinner(pieceType) == pieceType)
      {
	//If win, move is done, game is over
	//Call game over function
	if(isParent)
	{
	  gameOver(pieceType);
	}
	else
	{
	  return i;
	}
      }
      else
      {
	//If not win, remove peice - go to next iteration
	removePiece(i);
      }
    }
  }
  
  //Trying placing piece in every column, checking for opponent win - block this by placing own piece there
  int opponentType;
  if(pieceType == PARENT_PIECE)
  {
    opponentType = CHILD_PIECE;
  }
  else if(pieceType == CHILD_PIECE)
  {
    opponentType = PARENT_PIECE;
  }
  else
  {
    printf("Sweet jesus! What kind of piece is that!?\n");
  }
  
  for(i=0; i< GRID_N; i++)
  {
    if(columnFull(i)==0)
    {
      //Column is not full
      //Place opponent peice
      placePiece(i,opponentType);
      //Check for win by opponent
      if(getWinner(opponentType) == opponentType)
      {
	//If win, block this move by
	//Remove opponent peice
	removePiece(i);
	//Place your peice
	placePiece(i,pieceType);
	return i;
      }
      else
      {
	//If not win, remove opponent peice - go to next iteration
	removePiece(i);
      }
    }
  }
  
  //At this point you could not win and could not block opponent from winning
  //Do a random dumb move
  return dumbPlay(pieceType);
}