diff --git a/include/MinimaxSearch.h b/include/MinimaxSearch.h index c02fdd0..526694e 100644 --- a/include/MinimaxSearch.h +++ b/include/MinimaxSearch.h @@ -14,7 +14,7 @@ class MinimaxSearch { private: static const int MIN_DEPTH = 5; - static const int MAX_DEPTH = 6; + static const int MAX_DEPTH = 9; Heuristic heuristic; double minValue(std::unique_ptr &board, int currentDepth); diff --git a/src/GeneticSimulation.cpp b/src/GeneticSimulation.cpp index 1a71ce0..8178d7a 100644 --- a/src/GeneticSimulation.cpp +++ b/src/GeneticSimulation.cpp @@ -100,17 +100,17 @@ void GeneticSimulation::simulateRound(int roundNum){ fileOut<< "Ties: \t\t" << cntTies<< std::endl; fileOut<< "End popultion size: \t" << population.size() << std::endl; } - + /* int n = population.size(); for (int i = 0; i < n; ++i) { Specimen temp = population.front(); - population.pop(); - s << "+++++++++++++++++++++++++++++++" << std::endl; - s << "START: " << std::endl; - s << temp.getStartHeuristics().coefficientsToString(); - s << "END: " << std::endl; - s << temp.getEndHeuristics().coefficientsToString(); + population.pop_front(); + fileOut << "+++++++++++++++++++++++++++++++" << std::endl; + fileOut << "START: " << std::endl; + fileOut << temp.getStartHeuristics().coefficientsToString(); + fileOut << "END: " << std::endl; + fileOut << temp.getEndHeuristics().coefficientsToString(); } - + */ } diff --git a/src/main.cpp b/src/main.cpp index 312ecd3..b896cb4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -16,14 +16,25 @@ void serverGame(int userID, int oppID){ Client c(userID, oppID); std::unique_ptr board (new BitBoard); - Heuristic heur_test; - MinimaxSearch searchDriver(heur_test); - + + int startValues[Heuristic::numFeatures] = {-1, -90, -98, -46, -99, -16, -30, 46, 35, 46, -79}; + int endValues[Heuristic::numFeatures] = {-31, -42, -71, -19, -97, 21, -67, 27, 57, -46, -24}; + + Heuristic startHeur; + Heuristic endHeur; + + for(int i=0; i curMove; int isMoveRequested; bool isFirstMove = true; - + bool isEndGame = false; std::string player; //if black, make first move and give to client connection std::string firstMoveStr = c.amIBlack(); @@ -56,6 +67,13 @@ void serverGame(int userID, int oppID){ while(gameNotOver) { + if(!isEndGame) + if(board->getTotalPieceCount() < 12){ + MinimaxSearch e(endHeur); + searchDriver = e; + isEndGame = true; + } + std::cout << "\n=======================================" << std::endl; std::cout << "waiting on " << board->player() << "..." << std::endl; @@ -95,11 +113,12 @@ void serverGame(int userID, int oppID){ void geneticSimulation(int numSpecimen){ GeneticSimulation gs(numSpecimen); - int numRounds = 20; + int numRounds = 6; for(int i = 0; i < numRounds; i++){ gs.simulateRound(i); + gs.printWinners(); } - gs.printWinners(); + } int main(int argc, const char * argv[]) {