Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mbluemer committed May 2, 2017
2 parents 51e6447 + 784af2a commit f09370c
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 15 deletions.
2 changes: 1 addition & 1 deletion include/MinimaxSearch.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<BitBoard> &board, int currentDepth);
Expand Down
16 changes: 8 additions & 8 deletions src/GeneticSimulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

*/

}
31 changes: 25 additions & 6 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,25 @@ void serverGame(int userID, int oppID){
Client c(userID, oppID);

std::unique_ptr<BitBoard> 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<Heuristic::numFeatures;i++)
startHeur.set(i, startValues[i]);
for(int i=0; i<Heuristic::numFeatures;i++)
endHeur.set(i, endValues[i]);

MinimaxSearch searchDriver(startHeur);

std::unique_ptr<Move> 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();
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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[]) {
Expand Down

0 comments on commit f09370c

Please sign in to comment.