diff --git a/ai b/ai index c52646f..9fef26e 100644 --- a/ai +++ b/ai @@ -5,28 +5,8 @@ n # Player 1 if n == AI player1 y # Player 2 if n == AI player2 -y +n 2 # next player -. . . . . . . . . . . . . . . . . . . -. . . . . . . . . . . . . . . . . . . -. . . . . . . . . . . . . . . . . . . -. . . . . . . . . . . . . . . . . . . -. . . . . . . . . . 1 . . . . . . . . -. . . . . . . . 2 2 . . . . . . . . . -. . . . . . . 1 2 1 . . . . . . . . . -. . . . . 1 2 2 2 2 1 . . . . . . . . -. . . . . 1 2 1 1 2 1 1 . . . . . . . -. . . . . 1 1 1 2 1 2 . . . . . . . . -. . . . . . 2 1 2 2 2 2 1 . . . . . . -. . . . . . . 1 2 . . . 1 . . . . . . -. . . . . . . 2 . . . . . . . . . . . -. . . . . . 1 . . . . . . . . . . . . -. . . . . . . . . . . . . . . . . . . -. . . . . . . . . . . . . . . . . . . -. . . . . . . . . . . . . . . . . . . -. . . . . . . . . . . . . . . . . . . -. . . . . . . . . . . . . . . . . . . - . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . diff --git a/src/BotHenry.class.cpp b/src/BotHenry.class.cpp index b0ab293..130a859 100644 --- a/src/BotHenry.class.cpp +++ b/src/BotHenry.class.cpp @@ -128,7 +128,7 @@ unsigned short int BotHenry::play(std::map grid, char valu if (ret[3]) std::cout << "\tgetAttack(3): " << ret[3] << " (" << ((ret[3] & 0xFFFF) >> 8) <<","<< (ret[3] & 0xFF) <<")"<(end - startAlgo).count() << " ms thread: "<< std::chrono::duration(end - realStart).count() << " ms \n"; + std::cout << std::chrono::duration(end - startAlgo).count() << " ms "<< std::fixed << std::setprecision(2) << std::chrono::duration(end - realStart).count() / 1000 << " s \n"; run = true; score_done = false; return ret[0]; @@ -297,6 +297,10 @@ char mode, bool noDouble, char currentPoint, char oponentPoint, char depth, unsi pos = moves.front() & 0xFFFF; BotHenry::undoPlay(grid, moves.front() & 0xFFFF); moves.erase(moves.begin()); + for(int mov: (moves)) { + if (depth == MAX_DEPTH) + std::cout << "\t\t( why le x et y inverser?" << ((int)((mov & 0xFFFF) >> 8)) << "," << ((int)((mov & 0xFFFF) & 0xFF)) << ") s:" << (int)(mov >> 16) << std::endl; + } if (tmpScore >= alpha) alpha = tmpScore; if (tmpScore < beta) diff --git a/src/GameManager.class.cpp b/src/GameManager.class.cpp index bceb9bf..5d77154 100644 --- a/src/GameManager.class.cpp +++ b/src/GameManager.class.cpp @@ -45,14 +45,24 @@ GameManager::GameManager( bool asking ) : this->noDoubleThrees = false; std::cout << "Human player 1 (Y/n): "; std::getline(std::cin, res); - if (res.at(0) == 'n') + if (res.at(0) == 'n' && !this->gameMode) this->PlayerOne = new BotHenry(); + else if(res.at(0) == 'n') + { + std::cout << "ai can only be play in standard mode" << std::endl; + throw std::exception(); + } else this->PlayerOne = new Human(); std::cout << "Human player 2 (Y/n): "; std::getline(std::cin, res); - if (res.at(0) == 'n') + if (res.at(0) == 'n' && !this->gameMode) this->PlayerTwo = new BotHenry(); + else if(res.at(0) == 'n') + { + std::cout << "ai can only be play in standard mode" << std::endl; + throw std::exception(); + } else this->PlayerTwo = new Human(); } diff --git a/src/main.cpp b/src/main.cpp index d9c408b..0c104d1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -11,10 +11,15 @@ int main( int argc, char const **argv ) bool quit(false); GameManager *GameMan; // GameManager::instance(); - if (argc == 2 && strncmp("default", argv[1], 7) == 0) - GameMan = GameManager::instance(false); - else - GameMan = GameManager::instance(true); + try { + if (argc == 2 && strncmp("default", argv[1], 7) == 0) + GameMan = GameManager::instance(false); + else + GameMan = GameManager::instance(true); + } catch (std::exception &e) { + delete GameMan; + return 0; + } SDLMan = new SDLManager(); GameMan->printGrid(SDLMan); SDLMan->render(); @@ -33,7 +38,6 @@ int main( int argc, char const **argv ) } } } catch (std::exception &e) { - std::cout << e.what() << std::endl; quit = true; } }