diff --git a/src/perfect/bufferedFile.cpp b/src/perfect/bufferedFile.cpp index 292d5c2d..bb897a44 100644 --- a/src/perfect/bufferedFile.cpp +++ b/src/perfect/bufferedFile.cpp @@ -12,7 +12,7 @@ // Name: bufferedFile() // Desc: Creates a cyclic array. The passed file is used as temporary data buffer for the cyclic array. //----------------------------------------------------------------------------- -bufferedFileClass::bufferedFileClass(unsigned int numberOfThreads, unsigned int bufferSizeInBytes, const char *fileName) +BufferedFile::BufferedFile(unsigned int numberOfThreads, unsigned int bufferSizeInBytes, const char *fileName) { // locals unsigned int curThread; @@ -49,10 +49,10 @@ bufferedFileClass::bufferedFileClass(unsigned int numberOfThreads, unsigned int } //----------------------------------------------------------------------------- -// Name: ~bufferedFileClass() -// Desc: bufferedFileClass class destructor +// Name: ~BufferedFile() +// Desc: BufferedFile class destructor //----------------------------------------------------------------------------- -bufferedFileClass::~bufferedFileClass() +BufferedFile::~BufferedFile() { // flush buffers flushBuffers(); @@ -74,7 +74,7 @@ bufferedFileClass::~bufferedFileClass() // Name: getFileSize() // Desc: //----------------------------------------------------------------------------- -long long bufferedFileClass::getFileSize() +long long BufferedFile::getFileSize() { LARGE_INTEGER liFileSize; GetFileSizeEx(hFile, &liFileSize); @@ -86,7 +86,7 @@ long long bufferedFileClass::getFileSize() // Name: flushBuffers() // Desc: //----------------------------------------------------------------------------- -bool bufferedFileClass::flushBuffers() +bool BufferedFile::flushBuffers() { for (unsigned int threadNo = 0; threadNo < numThreads; threadNo++) { writeDataToFile(hFile, curWritingPointer[threadNo] - bytesInWriteBuffer[threadNo], bytesInWriteBuffer[threadNo], &writeBuffer[threadNo * bufferSize + 0]); @@ -99,7 +99,7 @@ bool bufferedFileClass::flushBuffers() // Name: writeDataToFile() // Desc: Writes 'sizeInBytes'-bytes to the position 'offset' to the file. //----------------------------------------------------------------------------- -void bufferedFileClass::writeDataToFile(HANDLE hFile, long long offset, unsigned int sizeInBytes, void *pData) +void BufferedFile::writeDataToFile(HANDLE hFile, long long offset, unsigned int sizeInBytes, void *pData) { DWORD dwBytesWritten; LARGE_INTEGER liDistanceToMove; @@ -125,7 +125,7 @@ void bufferedFileClass::writeDataToFile(HANDLE hFile, long long offset, unsigned // Name: readDataFromFile() // Desc: Reads 'sizeInBytes'-bytes from the position 'offset' of the file. //----------------------------------------------------------------------------- -void bufferedFileClass::readDataFromFile(HANDLE hFile, long long offset, unsigned int sizeInBytes, void *pData) +void BufferedFile::readDataFromFile(HANDLE hFile, long long offset, unsigned int sizeInBytes, void *pData) { DWORD dwBytesRead; LARGE_INTEGER liDistanceToMove; @@ -151,7 +151,7 @@ void bufferedFileClass::readDataFromFile(HANDLE hFile, long long offset, unsigne // Name: writeBytes() // Desc: //----------------------------------------------------------------------------- -bool bufferedFileClass::writeBytes(unsigned int numBytes, unsigned char *pData) +bool BufferedFile::writeBytes(unsigned int numBytes, unsigned char *pData) { return writeBytes(0, curWritingPointer[0], numBytes, pData); } @@ -160,7 +160,7 @@ bool bufferedFileClass::writeBytes(unsigned int numBytes, unsigned char *pData) // Name: writeBytes() // Desc: //----------------------------------------------------------------------------- -bool bufferedFileClass::writeBytes(unsigned int threadNo, long long positionInFile, unsigned int numBytes, unsigned char *pData) +bool BufferedFile::writeBytes(unsigned int threadNo, long long positionInFile, unsigned int numBytes, unsigned char *pData) { // parameters ok? if (threadNo >= numThreads) return false; @@ -188,7 +188,7 @@ bool bufferedFileClass::writeBytes(unsigned int threadNo, long long positionInFi // Name: takeBytes() // Desc: //----------------------------------------------------------------------------- -bool bufferedFileClass::readBytes(unsigned int numBytes, unsigned char *pData) +bool BufferedFile::readBytes(unsigned int numBytes, unsigned char *pData) { return readBytes(0, curReadingPointer[0], numBytes, pData); } @@ -197,7 +197,7 @@ bool bufferedFileClass::readBytes(unsigned int numBytes, unsigned char *pData) // Name: takeBytes() // Desc: //----------------------------------------------------------------------------- -bool bufferedFileClass::readBytes(unsigned int threadNo, long long positionInFile, unsigned int numBytes, unsigned char *pData) +bool BufferedFile::readBytes(unsigned int threadNo, long long positionInFile, unsigned int numBytes, unsigned char *pData) { // parameters ok? if (threadNo >= numThreads) return false; diff --git a/src/perfect/bufferedFile.h b/src/perfect/bufferedFile.h index bbb8e7e5..abe76d20 100644 --- a/src/perfect/bufferedFile.h +++ b/src/perfect/bufferedFile.h @@ -17,7 +17,7 @@ using namespace std; /*** Klassen *********************************************************/ -class bufferedFileClass +class BufferedFile { private: // Variables @@ -39,8 +39,8 @@ private: public: // Constructor / destructor - bufferedFileClass(unsigned int numThreads, unsigned int bufferSizeInBytes, const char *fileName); - ~bufferedFileClass(); + BufferedFile(unsigned int numThreads, unsigned int bufferSizeInBytes, const char *fileName); + ~BufferedFile(); // Functions bool flushBuffers(); diff --git a/src/perfect/cyclicArray.cpp b/src/perfect/cyclicArray.cpp index 9250317d..c33c2892 100644 --- a/src/perfect/cyclicArray.cpp +++ b/src/perfect/cyclicArray.cpp @@ -1,5 +1,5 @@ /********************************************************************* - cyclicArray.cpp + CyclicArray.cpp Copyright (c) Thomas Weber. All rights reserved. Copyright (C) 2021 The Sanmill developers (see AUTHORS file) Licensed under the MIT License. @@ -9,10 +9,10 @@ #include "cyclicArray.h" //----------------------------------------------------------------------------- -// Name: cyclicArray() +// Name: CyclicArray() // Desc: Creates a cyclic array. The passed file is used as temporary data buffer for the cyclic array. //----------------------------------------------------------------------------- -cyclicArray::cyclicArray(unsigned int blockSizeInBytes, unsigned int numberOfBlocks, const char *fileName) +CyclicArray::CyclicArray(unsigned int blockSizeInBytes, unsigned int numberOfBlocks, const char *fileName) { // Init blocks blockSize = blockSizeInBytes; @@ -39,7 +39,7 @@ cyclicArray::cyclicArray(unsigned int blockSizeInBytes, unsigned int numberOfBlo // Name: ~randomAI() // Desc: randomAI class destructor //----------------------------------------------------------------------------- -cyclicArray::~cyclicArray() +CyclicArray::~CyclicArray() { // delete arrays delete[] readingBlock; @@ -53,7 +53,7 @@ cyclicArray::~cyclicArray() // Name: writeDataToFile() // Desc: Writes 'sizeInBytes'-bytes to the position 'offset' to the file. //----------------------------------------------------------------------------- -void cyclicArray::writeDataToFile(HANDLE hFile, long long offset, unsigned int sizeInBytes, void *pData) +void CyclicArray::writeDataToFile(HANDLE hFile, long long offset, unsigned int sizeInBytes, void *pData) { DWORD dwBytesWritten; LARGE_INTEGER liDistanceToMove; @@ -78,7 +78,7 @@ void cyclicArray::writeDataToFile(HANDLE hFile, long long offset, unsigned int s // Name: readDataFromFile() // Desc: Reads 'sizeInBytes'-bytes from the position 'offset' of the file. //----------------------------------------------------------------------------- -void cyclicArray::readDataFromFile(HANDLE hFile, long long offset, unsigned int sizeInBytes, void *pData) +void CyclicArray::readDataFromFile(HANDLE hFile, long long offset, unsigned int sizeInBytes, void *pData) { DWORD dwBytesRead; LARGE_INTEGER liDistanceToMove; @@ -104,7 +104,7 @@ void cyclicArray::readDataFromFile(HANDLE hFile, long long offset, unsigned int // Desc: Add the passed data to the cyclic array. If the writing pointer reaches the end of a block, // the data of the whole block is written to the file and the next block is considered for writing. //----------------------------------------------------------------------------- -bool cyclicArray::addBytes(unsigned int numBytes, unsigned char *pData) +bool CyclicArray::addBytes(unsigned int numBytes, unsigned char *pData) { // locals unsigned int bytesWritten = 0; @@ -148,7 +148,7 @@ bool cyclicArray::addBytes(unsigned int numBytes, unsigned char *pData) // Name: bytesAvailable() // Desc: //----------------------------------------------------------------------------- -bool cyclicArray::bytesAvailable() +bool CyclicArray::bytesAvailable() { if (curReadingBlock == curWritingBlock && curReadingPointer == curWritingPointer && readWriteInSameRound) return false; else return true; @@ -159,7 +159,7 @@ bool cyclicArray::bytesAvailable() // Desc: Load data from the cyclic array. If the reading pointer reaches the end of a block, // the data of the next whole block is read from the file. //----------------------------------------------------------------------------- -bool cyclicArray::takeBytes(unsigned int numBytes, unsigned char *pData) +bool CyclicArray::takeBytes(unsigned int numBytes, unsigned char *pData) { // locals unsigned int bytesRead = 0; @@ -207,7 +207,7 @@ bool cyclicArray::takeBytes(unsigned int numBytes, unsigned char *pData) // Desc: Load the passed file into the cyclic array. // The passed filename must be different than the passed filename to the constructor cyclicarray(). //----------------------------------------------------------------------------- -bool cyclicArray::loadFile(const char *fileName, LONGLONG &numBytesLoaded) +bool CyclicArray::loadFile(const char *fileName, LONGLONG &numBytesLoaded) { // locals HANDLE hLoadFile; @@ -277,7 +277,7 @@ bool cyclicArray::loadFile(const char *fileName, LONGLONG &numBytesLoaded) // Desc: Writes the whole current content of the cyclic array to the passed file. // The passed filename must be different than the passed filename to the constructor cyclicarray(). //----------------------------------------------------------------------------- -bool cyclicArray::saveFile(const char *fileName) +bool CyclicArray::saveFile(const char *fileName) { // locals unsigned char *dataInFile; diff --git a/src/perfect/cyclicArray.h b/src/perfect/cyclicArray.h index 85d84f48..a4fa9426 100644 --- a/src/perfect/cyclicArray.h +++ b/src/perfect/cyclicArray.h @@ -1,5 +1,5 @@ /*********************************************************************\ - cyclicArray.h + CyclicArray.h Copyright (c) Thomas Weber. All rights reserved. Copyright (C) 2021 The Sanmill developers (see AUTHORS file) Licensed under the MIT License. @@ -17,7 +17,7 @@ using namespace std; /*** Klassen *********************************************************/ -class cyclicArray +class CyclicArray { private: // Variables @@ -38,8 +38,8 @@ private: public: // Constructor / destructor - cyclicArray(unsigned int blockSizeInBytes, unsigned int numberOfBlocks, const char *fileName); - ~cyclicArray(); + CyclicArray(unsigned int blockSizeInBytes, unsigned int numberOfBlocks, const char *fileName); + ~CyclicArray(); // Functions bool addBytes(unsigned int numBytes, unsigned char *pData); diff --git a/src/perfect/millAI.cpp b/src/perfect/millAI.cpp index 0d50f79b..42141fb5 100644 --- a/src/perfect/millAI.cpp +++ b/src/perfect/millAI.cpp @@ -94,7 +94,7 @@ void fieldStruct::copyField(fieldStruct *destination) // Name: copyPlayer() // Desc: Only copies the values without array creation. //----------------------------------------------------------------------------- -void playerStruct::copyPlayer(playerStruct *destination) +void Player::copyPlayer(Player *destination) { unsigned int i; @@ -118,8 +118,8 @@ void fieldStruct::createField() // locals unsigned int i; - curPlayer = new playerStruct; - oppPlayer = new playerStruct; + curPlayer = new Player; + oppPlayer = new Player; curPlayer->id = playerOne; stonesSet = 0; diff --git a/src/perfect/millAI.h b/src/perfect/millAI.h index 59621a90..a799b531 100644 --- a/src/perfect/millAI.h +++ b/src/perfect/millAI.h @@ -20,7 +20,7 @@ /*** Klassen *********************************************************/ -class playerStruct +class Player { public: int id; // static @@ -31,7 +31,7 @@ public: unsigned int posTo[MAX_NUM_POS_MOVES]; // target board position of a possible move unsigned int posFrom[MAX_NUM_POS_MOVES]; // source board position of a possible move - void copyPlayer(playerStruct *destination); + void copyPlayer(Player *destination); }; class fieldStruct @@ -61,7 +61,7 @@ public: unsigned int stonesSet; // number of stones set in the setting phase bool settingPhase; // true if stonesSet < 18 unsigned int stoneMustBeRemoved; // number of stones which must be removed by the current player - playerStruct *curPlayer, *oppPlayer; // pointers to the current and opponent player + Player *curPlayer, *oppPlayer; // pointers to the current and opponent player // useful functions void printField(); @@ -77,18 +77,18 @@ private: void setNeighbour(unsigned int index, unsigned int firstNeighbour0, unsigned int secondNeighbour0, unsigned int firstNeighbour1, unsigned int secondNeighbour1); }; -class millAI abstract +class MillAI abstract { protected: fieldStruct dummyField; public: // Constructor / destructor - millAI() + MillAI() { dummyField.createField(); }; - ~millAI() + ~MillAI() { dummyField.deleteField(); }; diff --git a/src/perfect/minMaxKI.cpp b/src/perfect/minMaxKI.cpp index 644b731d..866eca47 100644 --- a/src/perfect/minMaxKI.cpp +++ b/src/perfect/minMaxKI.cpp @@ -371,7 +371,7 @@ inline void miniMaxAI::updateWarning(unsigned int firstStone, unsigned int secon // Name: updatePossibleMoves() // Desc: //----------------------------------------------------------------------------- -inline void miniMaxAI::updatePossibleMoves(unsigned int stone, playerStruct *stoneOwner, bool stoneRemoved, unsigned int ignoreStone) +inline void miniMaxAI::updatePossibleMoves(unsigned int stone, Player *stoneOwner, bool stoneRemoved, unsigned int ignoreStone) { // locals unsigned int neighbor, direction; @@ -500,7 +500,7 @@ void miniMaxAI::move(unsigned int threadNo, unsigned int idPossibility, bool opp // locals backupStruct *oldState = &oldStates[curSearchDepth]; possibilityStruct *tmpPossibility = (possibilityStruct *)pPossibilities; - playerStruct *tmpPlayer; + Player *tmpPlayer; unsigned int i; // calculate place of stone diff --git a/src/perfect/miniMax.h b/src/perfect/miniMax.h index 48deede9..0b13cdc0 100644 --- a/src/perfect/miniMax.h +++ b/src/perfect/miniMax.h @@ -457,13 +457,13 @@ private: struct initAlphaBetaVars : public threadManagerClass::threadVarsArrayItem, public alphaBetaDefaultThreadVars { - bufferedFileClass *bufferedFile; + BufferedFile *bufferedFile; bool initAlreadyDone; initAlphaBetaVars() { }; - initAlphaBetaVars(miniMax *pMiniMax, alphaBetaGlobalVars *alphaBetaVars, unsigned int layerNumber, bufferedFileClass *initArray, bool initAlreadyDone) : alphaBetaDefaultThreadVars(pMiniMax, alphaBetaVars, layerNumber) + initAlphaBetaVars(miniMax *pMiniMax, alphaBetaGlobalVars *alphaBetaVars, unsigned int layerNumber, BufferedFile *initArray, bool initAlreadyDone) : alphaBetaDefaultThreadVars(pMiniMax, alphaBetaVars, layerNumber) { this->bufferedFile = initArray; this->initAlreadyDone = initAlreadyDone; @@ -517,7 +517,7 @@ private: struct retroAnalysisThreadVars // thread specific variables for each thread in the retro analysis { - vector statesToProcess; // vector-queue containing the states, whose short knot value are known for sure. they have to be processed. if processed the state will be removed from list. indexing: [threadNo][plyNumber] + vector statesToProcess; // vector-queue containing the states, whose short knot value are known for sure. they have to be processed. if processed the state will be removed from list. indexing: [threadNo][plyNumber] vector> stateQueue; // Queue containing states, whose 'count value' shall be increased by one. Before writing 'count value' to 'count array' the writing positions are sorted for faster processing. long long numStatesToProcess; // Number of states in 'statesToProcess' which have to be processed unsigned int threadNo; @@ -567,13 +567,13 @@ private: struct initRetroAnalysisVars : public threadManagerClass::threadVarsArrayItem, public retroAnalysisDefaultThreadVars { - bufferedFileClass *bufferedFile; + BufferedFile *bufferedFile; bool initAlreadyDone; initRetroAnalysisVars() { }; - initRetroAnalysisVars(miniMax *pMiniMax, retroAnalysisGlobalVars *retroVars, unsigned int layerNumber, bufferedFileClass *initArray, bool initAlreadyDone) : retroAnalysisDefaultThreadVars(pMiniMax, retroVars, layerNumber) + initRetroAnalysisVars(miniMax *pMiniMax, retroAnalysisGlobalVars *retroVars, unsigned int layerNumber, BufferedFile *initArray, bool initAlreadyDone) : retroAnalysisDefaultThreadVars(pMiniMax, retroVars, layerNumber) { this->bufferedFile = initArray; this->initAlreadyDone = initAlreadyDone; diff --git a/src/perfect/miniMaxAI.h b/src/perfect/miniMaxAI.h index 9758d021..2a36e56c 100644 --- a/src/perfect/miniMaxAI.h +++ b/src/perfect/miniMaxAI.h @@ -21,7 +21,7 @@ #define VALUE_GAME_WON 1000.0f /*** Klassen *********************************************************/ -class miniMaxAI : public millAI, miniMax +class miniMaxAI : public MillAI, miniMax { protected: @@ -46,7 +46,7 @@ protected: unsigned int stoneMustBeRemoved; unsigned int stonePartOfMill[fieldStruct::size]; unsigned int warnings[fieldStruct::size]; - playerStruct *curPlayer, *oppPlayer; + Player *curPlayer, *oppPlayer; }; // Variables @@ -67,7 +67,7 @@ protected: unsigned int *getPossStoneRemove(unsigned int *numPossibilities, void **pPossibilities); // move functions - inline void updatePossibleMoves(unsigned int stone, playerStruct *stoneOwner, bool stoneRemoved, unsigned int ignoreStone); + inline void updatePossibleMoves(unsigned int stone, Player *stoneOwner, bool stoneRemoved, unsigned int ignoreStone); inline void updateWarning(unsigned int firstStone, unsigned int secondStone); inline void setWarning(unsigned int stoneOne, unsigned int stoneTwo, unsigned int stoneThree); inline void removeStone(unsigned int from, backupStruct *backup); diff --git a/src/perfect/miniMax_alphaBetaAlgorithmn.cpp b/src/perfect/miniMax_alphaBetaAlgorithmn.cpp index 962b1625..b8225018 100644 --- a/src/perfect/miniMax_alphaBetaAlgorithmn.cpp +++ b/src/perfect/miniMax_alphaBetaAlgorithmn.cpp @@ -85,7 +85,7 @@ void miniMax::alphaBetaSaveInDatabase(unsigned int threadNo, unsigned int layerN bool miniMax::initAlphaBeta(alphaBetaGlobalVars &alphaBetaVars) { // locals - bufferedFileClass *invalidArray; // + BufferedFile *invalidArray; // bool initAlreadyDone = false; // true if the initialization information is already available in a file stringstream ssInvArrayDirectory; // stringstream ssInvArrayFilePath; // @@ -99,7 +99,7 @@ bool miniMax::initAlphaBeta(alphaBetaGlobalVars &alphaBetaVars) // does initialization file exist ? CreateDirectoryA(ssInvArrayDirectory.str().c_str(), nullptr); - invalidArray = new bufferedFileClass(threadManager.getNumThreads(), FILE_BUFFER_SIZE, ssInvArrayFilePath.str().c_str()); + invalidArray = new BufferedFile(threadManager.getNumThreads(), FILE_BUFFER_SIZE, ssInvArrayFilePath.str().c_str()); if (invalidArray->getFileSize() == (LONGLONG)layerStats[alphaBetaVars.layerNumber].knotsInLayer) { PRINT(2, this, " Loading invalid states from file: " << ssInvArrayFilePath.str()); initAlreadyDone = true; diff --git a/src/perfect/miniMax_retroAnalysis.cpp b/src/perfect/miniMax_retroAnalysis.cpp index cff67c30..09237a39 100644 --- a/src/perfect/miniMax_retroAnalysis.cpp +++ b/src/perfect/miniMax_retroAnalysis.cpp @@ -112,7 +112,7 @@ bool miniMax::initRetroAnalysis(retroAnalysisGlobalVars &retroVars) unsigned int layerNumber; // layer number of the current process layer stringstream ssInitArrayPath; // path of the working directory stringstream ssInitArrayFilePath; // filename corresponding to a cyclic array file which is used for storage - bufferedFileClass *initArray; // + BufferedFile *initArray; // bool initAlreadyDone = false; // true if the initialization information is already available in a file // process each layer @@ -129,7 +129,7 @@ bool miniMax::initRetroAnalysis(retroAnalysisGlobalVars &retroVars) // does initialization file exist ? CreateDirectoryA(ssInitArrayPath.str().c_str(), nullptr); - initArray = new bufferedFileClass(threadManager.getNumThreads(), FILE_BUFFER_SIZE, ssInitArrayFilePath.str().c_str()); + initArray = new BufferedFile(threadManager.getNumThreads(), FILE_BUFFER_SIZE, ssInitArrayFilePath.str().c_str()); if (initArray->getFileSize() == (LONGLONG)layerStats[layerNumber].knotsInLayer) { PRINT(2, this, " Loading init states from file: " << ssInitArrayFilePath.str()); initAlreadyDone = true; @@ -738,7 +738,7 @@ bool miniMax::addStateToProcessQueue(retroAnalysisGlobalVars &retroVars, retroAn CreateDirectoryA(ssStatesToProcessPath.str().c_str(), nullptr); ssStatesToProcessFilePath.str(""); ssStatesToProcessFilePath << ssStatesToProcessPath.str() << "\\statesToProcessWithPlyCounter=" << plyNumber << "andThread=" << threadVars.threadNo << ".dat"; - threadVars.statesToProcess[plyNumber] = new cyclicArray(BLOCK_SIZE_IN_CYCLIC_ARRAY * sizeof(stateAdressStruct), (unsigned int)(retroVars.totalNumKnots / BLOCK_SIZE_IN_CYCLIC_ARRAY) + 1, ssStatesToProcessFilePath.str().c_str()); + threadVars.statesToProcess[plyNumber] = new CyclicArray(BLOCK_SIZE_IN_CYCLIC_ARRAY * sizeof(stateAdressStruct), (unsigned int)(retroVars.totalNumKnots / BLOCK_SIZE_IN_CYCLIC_ARRAY) + 1, ssStatesToProcessFilePath.str().c_str()); PRINT(4, this, " Created cyclic array: " << ssStatesToProcessFilePath.str()); } diff --git a/src/perfect/miniMax_retroAnalysis.h b/src/perfect/miniMax_retroAnalysis.h index ff29a7ac..ab62d36e 100644 --- a/src/perfect/miniMax_retroAnalysis.h +++ b/src/perfect/miniMax_retroAnalysis.h @@ -14,7 +14,7 @@ struct retroAnalysisQueueState struct retroAnalysisThreadVars // thread specific variables for each thread in the retro analysis { - vector statesToProcess; // vector-queue containing the states, whose short knot value are known for sure. they have to be processed. if processed the state will be removed from list. indexing: [threadNo][plyNumber] + vector statesToProcess; // vector-queue containing the states, whose short knot value are known for sure. they have to be processed. if processed the state will be removed from list. indexing: [threadNo][plyNumber] vector> stateQueue; // Queue containing states, whose 'count value' shall be increased by one. Before writing 'count value' to 'count array' the writing positions are sorted for faster processing. long long numStatesToProcess; // Number of states in 'statesToProcess' which have to be processed unsigned int threadNo; @@ -38,7 +38,7 @@ struct initRetroAnalysisVars unsigned int layerNumber; LONGLONG statesProcessed; unsigned int statsValueCounter[SKV_NUM_VALUES]; - bufferedFileClass *bufferedFile; + BufferedFile *bufferedFile; retroAnalysisVars *retroVars; bool initAlreadyDone; // true if the initialization information is already available in a file }; diff --git a/src/perfect/perfectAI.cpp b/src/perfect/perfectAI.cpp index a4220c35..814ce6c5 100644 --- a/src/perfect/perfectAI.cpp +++ b/src/perfect/perfectAI.cpp @@ -1080,7 +1080,7 @@ inline void perfectAI::threadVarsStruct::updateWarning(unsigned int firstStone, // Name: updatePossibleMoves() // Desc: //----------------------------------------------------------------------------- -inline void perfectAI::threadVarsStruct::updatePossibleMoves(unsigned int stone, playerStruct *stoneOwner, bool stoneRemoved, unsigned int ignoreStone) +inline void perfectAI::threadVarsStruct::updatePossibleMoves(unsigned int stone, Player *stoneOwner, bool stoneRemoved, unsigned int ignoreStone) { // locals unsigned int neighbor, direction; @@ -1210,7 +1210,7 @@ void perfectAI::move(unsigned int threadNo, unsigned int idPossibility, bool opp threadVarsStruct *tv = &threadVars[threadNo]; backupStruct *oldState = &tv->oldStates[tv->curSearchDepth]; possibilityStruct *tmpPossibility = (possibilityStruct *)pPossibilities; - playerStruct *tmpPlayer; + Player *tmpPlayer; unsigned int i; // calculate place of stone @@ -1740,7 +1740,7 @@ bool perfectAI::setSituation(unsigned int threadNo, unsigned int layerNum, unsig // Name: calcPossibleMoves() // Desc: //----------------------------------------------------------------------------- -void perfectAI::threadVarsStruct::calcPossibleMoves(playerStruct *player) +void perfectAI::threadVarsStruct::calcPossibleMoves(Player *player) { // locals unsigned int i, j, k, movingDirection; @@ -2089,7 +2089,7 @@ void perfectAI::getPredecessors(unsigned int threadNo, unsigned int *amountOfPre bool aStoneCanBeRemovedFromCurPlayer; bool millWasClosed; unsigned int from, to, dir, i; - playerStruct *tmpPlayer; + Player *tmpPlayer; unsigned int numberOfMillsCurrentPlayer = 0; unsigned int numberOfMillsOpponentPlayer = 0; diff --git a/src/perfect/perfectAI.h b/src/perfect/perfectAI.h index 1f6ba9c5..b674471e 100644 --- a/src/perfect/perfectAI.h +++ b/src/perfect/perfectAI.h @@ -75,7 +75,7 @@ #define NUM_SYM_OPERATIONS 16 /*** Klassen *********************************************************/ -class perfectAI : public millAI, public miniMax +class perfectAI : public MillAI, public miniMax { protected: @@ -118,7 +118,7 @@ protected: unsigned int stonesSet; unsigned int stoneMustBeRemoved; unsigned int stonePartOfMill[fieldStruct::size]; - playerStruct *curPlayer, *oppPlayer; + Player *curPlayer, *oppPlayer; }; // preCalcedVars.dat @@ -173,7 +173,7 @@ protected: unsigned int *getPossStoneRemove(unsigned int *numPossibilities, void **pPossibilities); // move functions - inline void updatePossibleMoves(unsigned int stone, playerStruct *stoneOwner, bool stoneRemoved, unsigned int ignoreStone); + inline void updatePossibleMoves(unsigned int stone, Player *stoneOwner, bool stoneRemoved, unsigned int ignoreStone); inline void updateWarning(unsigned int firstStone, unsigned int secondStone); inline void setWarning(unsigned int stoneOne, unsigned int stoneTwo, unsigned int stoneThree); inline void removeStone(unsigned int from, backupStruct *backup); @@ -184,7 +184,7 @@ protected: unsigned int getLayerAndStateNumber(unsigned int &layerNum, unsigned int &stateNumber); void setWarningAndMill(unsigned int stone, unsigned int firstNeighbour, unsigned int secondNeighbour); bool fieldIntegrityOK(unsigned int numberOfMillsCurrentPlayer, unsigned int numberOfMillsOpponentPlayer, bool aStoneCanBeRemovedFromCurPlayer); - void calcPossibleMoves(playerStruct *player); + void calcPossibleMoves(Player *player); void storePredecessor(unsigned int numberOfMillsCurrentPlayer, unsigned int numberOfMillsOpponentPlayer, unsigned int *amountOfPred, retroAnalysisPredVars *predVars); }; threadVarsStruct *threadVars; diff --git a/src/perfect/position.cpp b/src/perfect/position.cpp index 4e679e92..cc7f7500 100644 --- a/src/perfect/position.cpp +++ b/src/perfect/position.cpp @@ -52,7 +52,7 @@ void Position::exit() // Name: beginNewGame() // Desc: Reinitializes the Position object. //----------------------------------------------------------------------------- -void Position::beginNewGame(millAI *firstPlayerAI, millAI *secondPlayerAI, int currentPlayer) +void Position::beginNewGame(MillAI *firstPlayerAI, MillAI *secondPlayerAI, int currentPlayer) { // free mem exit(); @@ -85,7 +85,7 @@ void Position::beginNewGame(millAI *firstPlayerAI, millAI *secondPlayerAI, int c // Name: startSettingPhase() // Desc: //----------------------------------------------------------------------------- -bool Position::startSettingPhase(millAI *firstPlayerAI, millAI *secondPlayerAI, int currentPlayer, bool settingPhase) +bool Position::startSettingPhase(MillAI *firstPlayerAI, MillAI *secondPlayerAI, int currentPlayer, bool settingPhase) { beginNewGame(firstPlayerAI, secondPlayerAI, currentPlayer); @@ -98,7 +98,7 @@ bool Position::startSettingPhase(millAI *firstPlayerAI, millAI *secondPlayerAI, // Name: setUpCalcPossibleMoves() // Desc: Calculates and set the number of possible moves for the passed player considering the game state stored in the 'board' variable. //----------------------------------------------------------------------------- -void Position::setUpCalcPossibleMoves(playerStruct *player) +void Position::setUpCalcPossibleMoves(Player *player) { // locals unsigned int i, j, k, movingDirection; @@ -160,7 +160,7 @@ bool Position::put_piece(unsigned int pos, int player) // locals unsigned int i; unsigned int numberOfMillsCurrentPlayer = 0, numberOfMillsOpponentPlayer = 0; - playerStruct *myPlayer = (player == field.curPlayer->id) ? field.curPlayer : field.oppPlayer; + Player *myPlayer = (player == field.curPlayer->id) ? field.curPlayer : field.oppPlayer; // check parameters if (player != fieldStruct::playerOne && player != fieldStruct::playerTwo) return false; @@ -275,7 +275,7 @@ void Position::getLog(unsigned int &numMovesDone, unsigned int *from, unsigned i //----------------------------------------------------------------------------- void Position::setNextPlayer() { - playerStruct *tmpPlayer; + Player *tmpPlayer; tmpPlayer = field.curPlayer; field.curPlayer = field.oppPlayer; @@ -306,7 +306,7 @@ bool Position::isOpponentPlayerHuman() // Name: setAI() // Desc: Assigns an AI to a player. //----------------------------------------------------------------------------- -void Position::setAI(int player, millAI *AI) +void Position::setAI(int player, MillAI *AI) { if (player == field.playerOne) { playerOneAI = AI; @@ -320,7 +320,7 @@ void Position::setAI(int player, millAI *AI) // Name: getChoiceOfSpecialAI() // Desc: Returns the move the passed AI would do. //----------------------------------------------------------------------------- -void Position::getChoiceOfSpecialAI(millAI *AI, unsigned int *pushFrom, unsigned int *pushTo) +void Position::getChoiceOfSpecialAI(MillAI *AI, unsigned int *pushFrom, unsigned int *pushTo) { fieldStruct theField; *pushFrom = field.size; @@ -358,7 +358,7 @@ void Position::getComputersChoice(unsigned int *pushFrom, unsigned int *pushTo) // Name: isNormalMovePossible() // Desc: 'Normal' in this context means, by moving the stone along a connection without jumping. //----------------------------------------------------------------------------- -bool Position::isNormalMovePossible(unsigned int from, unsigned int to, playerStruct *player) +bool Position::isNormalMovePossible(unsigned int from, unsigned int to, Player *player) { // locals unsigned int movingDirection, i; @@ -391,7 +391,7 @@ bool Position::isNormalMovePossible(unsigned int from, unsigned int to, playerSt // Name: calcPossibleMoves() // Desc: ... //----------------------------------------------------------------------------- -void Position::calcPossibleMoves(playerStruct *player) +void Position::calcPossibleMoves(Player *player) { // locals unsigned int i, j; @@ -676,7 +676,7 @@ bool Position::compareWithField(fieldStruct *compareField) // Name: comparePlayers() // Desc: Compares the two passed players and returns false if they differ. //----------------------------------------------------------------------------- -bool Position::comparePlayers(playerStruct *playerA, playerStruct *playerB) +bool Position::comparePlayers(Player *playerA, Player *playerB) { // unsigned int i; bool ret = true; diff --git a/src/perfect/position.h b/src/perfect/position.h index 5fb4f491..4fc5f963 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 *playerOneAI; // class-pointer to the AI of player one - millAI *playerTwoAI; // 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 board fieldStruct initialField; // undo of the last move is done by setting the initial board und performing all moves saved in history int winner; // playerId of the player who has won the game. zero if game is still running. @@ -46,9 +46,9 @@ private: // Functions void exit(); void setNextPlayer(); - void calcPossibleMoves(playerStruct *player); + void calcPossibleMoves(Player *player); void updateMillsAndWarnings(unsigned int newStone); - bool isNormalMovePossible(unsigned int from, unsigned int to, playerStruct *player); + bool isNormalMovePossible(unsigned int from, unsigned int to, Player *player); void setWarningAndMill(unsigned int stone, unsigned int firstNeighbour, unsigned int secondNeighbour, bool isNewStone); public: @@ -58,19 +58,19 @@ public: // Functions void undo_move(); - void beginNewGame(millAI *firstPlayerAI, millAI *secondPlayerAI, int currentPlayer); - void setAI(int player, millAI *AI); + 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); + bool comparePlayers(Player *playerA, Player *playerB); void printField(); - bool startSettingPhase(millAI *firstPlayerAI, millAI *secondPlayerAI, int currentPlayer, bool settingPhase); + bool startSettingPhase(MillAI *firstPlayerAI, MillAI *secondPlayerAI, int currentPlayer, bool settingPhase); bool put_piece(unsigned int pos, int player); bool settingPhaseHasFinished(); - void getChoiceOfSpecialAI(millAI *AI, unsigned int *pushFrom, unsigned int *pushTo); - void setUpCalcPossibleMoves(playerStruct *player); + void getChoiceOfSpecialAI(MillAI *AI, unsigned int *pushFrom, unsigned int *pushTo); + void setUpCalcPossibleMoves(Player *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 6005a3ca..fdf42588 100644 --- a/src/perfect/randomAI.h +++ b/src/perfect/randomAI.h @@ -15,7 +15,7 @@ /*** Klassen *********************************************************/ -class randomAI : public millAI +class randomAI : public MillAI { public: // Constructor / destructor