diff --git a/src/perfect/main.cpp b/src/perfect/main.cpp index 74e750a8..16ae8b30 100644 --- a/src/perfect/main.cpp +++ b/src/perfect/main.cpp @@ -27,7 +27,7 @@ int main(void) char ch[100]; unsigned int pushFrom, pushTo; Position *myGame = new Position(); - perfectAI *myKI = new perfectAI(databaseDirectory); + perfectAI *myAI = new perfectAI(databaseDirectory); SetPriorityClass(GetCurrentProcess(), BELOW_NORMAL_PRIORITY_CLASS); srand(GetTickCount()); @@ -37,24 +37,24 @@ int main(void) cout << "* Muehle *" << endl; cout << "*************************" << endl << endl; - myKI->setDatabasePath(databaseDirectory); + myAI->setDatabasePath(databaseDirectory); // begin #ifdef SELF_PLAY - myGame->beginNewGame(myKI, myKI, fieldStruct::playerOne); + myGame->beginNewGame(myAI, myAI, fieldStruct::playerOne); #else - myGame->beginNewGame(myKI, myKI, (rand() % 2) ? fieldStruct::playerOne : fieldStruct::playerTwo); + myGame->beginNewGame(myAI, myAI, (rand() % 2) ? fieldStruct::playerOne : fieldStruct::playerTwo); #endif // SELF_PLAY if (calculateDatabase) { // calculate - myKI->calculateDatabase(MAX_DEPTH_OF_TREE, false); + myAI->calculateDatabase(MAX_DEPTH_OF_TREE, false); // test database cout << endl << "Begin test starting from layer: "; startTestFromLayer; cout << endl << "End test at layer: "; endTestAtLayer; - myKI->testLayers(startTestFromLayer, endTestAtLayer); + myAI->testLayers(startTestFromLayer, endTestAtLayer); } else { diff --git a/src/perfect/millAI.h b/src/perfect/millAI.h index 2e352e5d..2ece3993 100644 --- a/src/perfect/millAI.h +++ b/src/perfect/millAI.h @@ -6,8 +6,8 @@ https://github.com/madweasel/madweasels-cpp \*********************************************************************/ -#ifndef MUEHLE_KI_H -#define MUEHLE_KI_H +#ifndef MUEHLE_AI_H +#define MUEHLE_AI_H #include #include diff --git a/src/perfect/miniMaxAI.h b/src/perfect/miniMaxAI.h index 6a13030d..333d7a73 100644 --- a/src/perfect/miniMaxAI.h +++ b/src/perfect/miniMaxAI.h @@ -6,8 +6,8 @@ https://github.com/madweasel/madweasels-cpp \*********************************************************************/ -#ifndef MINIMAXKI_H -#define MINIMAXKI_H +#ifndef MINIMAXAI_H +#define MINIMAXAI_H #include #include diff --git a/src/perfect/miniMaxWin.h b/src/perfect/miniMaxWin.h index 106405e7..133c6ea0 100644 --- a/src/perfect/miniMaxWin.h +++ b/src/perfect/miniMaxWin.h @@ -60,7 +60,7 @@ class miniMaxWinInspectDb protected: // General Variables - miniMax *pMiniMax = nullptr; // pointer to perfect KI class granting the access to the database + miniMax *pMiniMax = nullptr; // pointer to perfect AI class granting the access to the database miniMaxGuiField *pGuiField = nullptr; bool showingInspectionControls = false; unsigned int curShowedLayer = 0; // current showed layer @@ -113,7 +113,7 @@ protected: // Calculation variables wildWeasel::masterMind *ww = nullptr; // pointer to engine - miniMax *pMiniMax = nullptr; // pointer to perfect KI class granting the access to the database + miniMax *pMiniMax = nullptr; // pointer to perfect AI class granting the access to the database ostream *outputStream = nullptr; // pointer to a stream for the console output of the calculation done by the class miniMax stringbuf outputStringBuf; // buffer linked to the stream, for reading out of the stream into the buffer locale myLocale; // for formatting the output diff --git a/src/perfect/perfectAI.cpp b/src/perfect/perfectAI.cpp index b8eda117..a0b9e542 100644 --- a/src/perfect/perfectAI.cpp +++ b/src/perfect/perfectAI.cpp @@ -1,5 +1,5 @@ /********************************************************************* - perfectKI.cpp + perfectAI.cpp Copyright (c) Thomas Weber. All rights reserved. Copyright (C) 2021 The Sanmill developers (see AUTHORS file) Licensed under the MIT License. @@ -183,8 +183,8 @@ unsigned int fieldPosIsOfGroup[] = { GROUP_C, GROUP_D, GROUP_C, GROUP_D, GROUP_C }; //----------------------------------------------------------------------------- -// Name: perfectKI() -// Desc: perfectKI class constructor +// Name: perfectAI() +// Desc: perfectAI class constructor //----------------------------------------------------------------------------- perfectAI::perfectAI(const char *directory) { @@ -626,8 +626,8 @@ perfectAI::perfectAI(const char *directory) } //----------------------------------------------------------------------------- -// Name: ~perfectKI() -// Desc: perfectKI class destructor +// Name: ~perfectAI() +// Desc: perfectAI class destructor //----------------------------------------------------------------------------- perfectAI::~perfectAI() { @@ -676,10 +676,10 @@ void perfectAI::play(fieldStruct *theField, unsigned int *pushFrom, unsigned int // current state already calculated? if (isCurrentStateInDatabase(0)) { - cout << "perfectKI is using database!\n\n\n"; + cout << "perfectAI is using database!\n\n\n"; threadVars[0].depthOfFullTree = 3; } else { - cout << "perfectKI is thinking thinking with a depth of " << threadVars[0].depthOfFullTree << " steps!\n\n\n"; + cout << "perfectAI is thinking thinking with a depth of " << threadVars[0].depthOfFullTree << " steps!\n\n\n"; } // start the miniMax-algorithmn diff --git a/src/perfect/perfectAI.h b/src/perfect/perfectAI.h index 9e114004..75db2972 100644 --- a/src/perfect/perfectAI.h +++ b/src/perfect/perfectAI.h @@ -1,13 +1,13 @@ /*********************************************************************\ - perfectKI.h + perfectAI.h Copyright (c) Thomas Weber. All rights reserved. Copyright (C) 2021 The Sanmill developers (see AUTHORS file) Licensed under the MIT License. https://github.com/madweasel/madweasels-cpp \*********************************************************************/ -#ifndef PERFEKT_KI_H -#define PERFEKT_KI_H +#ifndef PERFEKT_AI_H +#define PERFEKT_AI_H #include #include diff --git a/src/perfect/position.cpp b/src/perfect/position.cpp index 3c674823..42a2e765 100644 --- a/src/perfect/position.cpp +++ b/src/perfect/position.cpp @@ -18,8 +18,8 @@ Position::Position() moveLogFrom = nullptr; moveLogTo = nullptr; - playerOneKI = nullptr; - playerTwoKI = nullptr; + playerOneAI = nullptr; + playerTwoAI = nullptr; movesDone = 0; field.createField(); @@ -52,7 +52,7 @@ void Position::deleteArrays() // Name: beginNewGame() // Desc: Reinitializes the Position object. //----------------------------------------------------------------------------- -void Position::beginNewGame(millAI *firstPlayerKI, millAI *secondPlayerKI, int currentPlayer) +void Position::beginNewGame(millAI *firstPlayerAI, millAI *secondPlayerAI, int currentPlayer) { // free mem deleteArrays(); @@ -72,8 +72,8 @@ void Position::beginNewGame(millAI *firstPlayerKI, millAI *secondPlayerKI, int c winner = 0; movesDone = 0; - playerOneKI = firstPlayerKI; - playerTwoKI = secondPlayerKI; + playerOneAI = firstPlayerAI; + playerTwoAI = secondPlayerAI; moveLogFrom = new unsigned int[MAX_NUM_MOVES]; moveLogTo = new unsigned int[MAX_NUM_MOVES]; @@ -85,9 +85,9 @@ void Position::beginNewGame(millAI *firstPlayerKI, millAI *secondPlayerKI, int c // Name: startSettingPhase() // Desc: //----------------------------------------------------------------------------- -bool Position::startSettingPhase(millAI *firstPlayerKI, millAI *secondPlayerKI, int currentPlayer, bool settingPhase) +bool Position::startSettingPhase(millAI *firstPlayerAI, millAI *secondPlayerAI, int currentPlayer, bool settingPhase) { - beginNewGame(firstPlayerKI, secondPlayerKI, currentPlayer); + beginNewGame(firstPlayerAI, secondPlayerAI, currentPlayer); field.settingPhase = settingPhase; @@ -283,8 +283,8 @@ void Position::setNextPlayer() //----------------------------------------------------------------------------- bool Position::isCurrentPlayerHuman() { - if (field.curPlayer->id == field.playerOne) return (playerOneKI == nullptr) ? true : false; - else return (playerTwoKI == nullptr) ? true : false; + if (field.curPlayer->id == field.playerOne) return (playerOneAI == nullptr) ? true : false; + else return (playerTwoAI == nullptr) ? true : false; } //----------------------------------------------------------------------------- @@ -293,36 +293,36 @@ bool Position::isCurrentPlayerHuman() //----------------------------------------------------------------------------- bool Position::isOpponentPlayerHuman() { - if (field.oppPlayer->id == field.playerOne) return (playerOneKI == nullptr) ? true : false; - else return (playerTwoKI == nullptr) ? true : false; + if (field.oppPlayer->id == field.playerOne) return (playerOneAI == nullptr) ? true : false; + else return (playerTwoAI == nullptr) ? true : false; } //----------------------------------------------------------------------------- -// Name: setKI() +// Name: setAI() // Desc: Assigns an AI to a player. //----------------------------------------------------------------------------- -void Position::setKI(int player, millAI *KI) +void Position::setAI(int player, millAI *AI) { if (player == field.playerOne) { - playerOneKI = KI; + playerOneAI = AI; } if (player == field.playerTwo) { - playerTwoKI = KI; + playerTwoAI = AI; } } //----------------------------------------------------------------------------- -// Name: getChoiceOfSpecialKI() +// Name: getChoiceOfSpecialAI() // Desc: Returns the move the passed AI would do. //----------------------------------------------------------------------------- -void Position::getChoiceOfSpecialKI(millAI *KI, unsigned int *pushFrom, unsigned int *pushTo) +void Position::getChoiceOfSpecialAI(millAI *AI, unsigned int *pushFrom, unsigned int *pushTo) { fieldStruct theField; *pushFrom = field.size; *pushTo = field.size; theField.createField(); field.copyField(&theField); - if (KI != nullptr && (field.settingPhase || field.curPlayer->numPossibleMoves > 0) && winner == 0) KI->play(&theField, pushFrom, pushTo); + if (AI != nullptr && (field.settingPhase || field.curPlayer->numPossibleMoves > 0) && winner == 0) AI->play(&theField, pushFrom, pushTo); theField.deleteField(); } @@ -340,9 +340,9 @@ void Position::getComputersChoice(unsigned int *pushFrom, unsigned int *pushTo) if ((field.settingPhase || field.curPlayer->numPossibleMoves > 0) && winner == 0) { if (field.curPlayer->id == field.playerOne) { - if (playerOneKI != nullptr) playerOneKI->play(&theField, pushFrom, pushTo); + if (playerOneAI != nullptr) playerOneAI->play(&theField, pushFrom, pushTo); } else { - if (playerTwoKI != nullptr) playerTwoKI->play(&theField, pushFrom, pushTo); + if (playerTwoAI != nullptr) playerTwoAI->play(&theField, pushFrom, pushTo); } } diff --git a/src/perfect/position.h b/src/perfect/position.h index c6b15b10..f936a670 100644 --- a/src/perfect/position.h +++ b/src/perfect/position.h @@ -36,8 +36,8 @@ class Position private: // Variables unsigned int *moveLogFrom, *moveLogTo, movesDone; // array containing the history of moves done - millAI *playerOneKI; // class-pointer to the AI of player one - millAI *playerTwoKI; // class-pointer to the AI of player two + millAI *playerOneAI; // class-pointer to the AI of player one + millAI *playerTwoAI; // class-pointer to the AI of player two fieldStruct field; // current field fieldStruct initialField; // undo of the last move is done by setting the initial field und performing all moves saved in history int winner; // playerId of the player who has won the game. zero if game is still running. @@ -58,18 +58,18 @@ public: // Functions void undo_move(); - void beginNewGame(millAI *firstPlayerKI, millAI *secondPlayerKI, int currentPlayer); - void setKI(int player, millAI *KI); + void beginNewGame(millAI *firstPlayerAI, millAI *secondPlayerAI, int currentPlayer); + void setAI(int player, millAI *AI); bool do_move(unsigned int pushFrom, unsigned int pushTo); void getComputersChoice(unsigned int *pushFrom, unsigned int *pushTo); bool setCurrentGameState(fieldStruct *curState); bool compareWithField(fieldStruct *compareField); bool comparePlayers(playerStruct *playerA, playerStruct *playerB); void printField(); - bool startSettingPhase(millAI *firstPlayerKI, millAI *secondPlayerKI, int currentPlayer, bool settingPhase); + bool startSettingPhase(millAI *firstPlayerAI, millAI *secondPlayerAI, int currentPlayer, bool settingPhase); bool putStone(unsigned int pos, int player); bool settingPhaseHasFinished(); - void getChoiceOfSpecialKI(millAI *KI, unsigned int *pushFrom, unsigned int *pushTo); + void getChoiceOfSpecialAI(millAI *AI, unsigned int *pushFrom, unsigned int *pushTo); void setUpCalcPossibleMoves(playerStruct *player); void setUpSetWarningAndMill(unsigned int stone, unsigned int firstNeighbour, unsigned int secondNeighbour); void calcNumberOfRestingStones(int &numWhiteStonesResting, int &numBlackStonesResting); diff --git a/src/perfect/randomAI.h b/src/perfect/randomAI.h index 25481576..6005a3ca 100644 --- a/src/perfect/randomAI.h +++ b/src/perfect/randomAI.h @@ -6,8 +6,8 @@ https://github.com/madweasel/madweasels-cpp \*********************************************************************/ -#ifndef RANDOM_KI_H -#define RANDOM_KI_H +#ifndef RANDOM_AI_H +#define RANDOM_AI_H #include #include