perfect: NULL -> nullptr
This commit is contained in:
parent
e17b71c2b9
commit
f8287f04fd
|
@ -36,11 +36,11 @@ bufferedFileClass::bufferedFileClass(unsigned int numberOfThreads, unsigned int
|
|||
InitializeCriticalSection(&csIO);
|
||||
|
||||
// Open Database-File (FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH | FILE_FLAG_RANDOM_ACCESS)
|
||||
hFile = CreateFileA(fileName, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
hFile = CreateFileA(fileName, GENERIC_READ | GENERIC_WRITE, 0, nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
|
||||
// opened file succesfully
|
||||
if (hFile == INVALID_HANDLE_VALUE) {
|
||||
hFile = NULL;
|
||||
hFile = nullptr;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ bufferedFileClass::~bufferedFileClass()
|
|||
delete[] bytesInWriteBuffer;
|
||||
|
||||
// close file
|
||||
if (hFile != NULL) CloseHandle(hFile);
|
||||
if (hFile != nullptr) CloseHandle(hFile);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -108,9 +108,9 @@ void bufferedFileClass::writeDataToFile(HANDLE hFile, long long offset, unsigned
|
|||
liDistanceToMove.QuadPart = offset;
|
||||
|
||||
EnterCriticalSection(&csIO);
|
||||
while (!SetFilePointerEx(hFile, liDistanceToMove, NULL, FILE_BEGIN)) cout << endl << "SetFilePointerEx failed!";
|
||||
while (!SetFilePointerEx(hFile, liDistanceToMove, nullptr, FILE_BEGIN)) cout << endl << "SetFilePointerEx failed!";
|
||||
while (restingBytes > 0) {
|
||||
if (WriteFile(hFile, pData, sizeInBytes, &dwBytesWritten, NULL) == TRUE) {
|
||||
if (WriteFile(hFile, pData, sizeInBytes, &dwBytesWritten, nullptr) == TRUE) {
|
||||
restingBytes -= dwBytesWritten;
|
||||
pData = (void *)(((unsigned char *)pData) + dwBytesWritten);
|
||||
if (restingBytes > 0) cout << endl << "Still " << restingBytes << " to write!";
|
||||
|
@ -134,9 +134,9 @@ void bufferedFileClass::readDataFromFile(HANDLE hFile, long long offset, unsigne
|
|||
liDistanceToMove.QuadPart = offset;
|
||||
|
||||
EnterCriticalSection(&csIO);
|
||||
while (!SetFilePointerEx(hFile, liDistanceToMove, NULL, FILE_BEGIN)) cout << endl << "SetFilePointerEx failed!";
|
||||
while (!SetFilePointerEx(hFile, liDistanceToMove, nullptr, FILE_BEGIN)) cout << endl << "SetFilePointerEx failed!";
|
||||
while (restingBytes > 0) {
|
||||
if (ReadFile(hFile, pData, sizeInBytes, &dwBytesRead, NULL) == TRUE) {
|
||||
if (ReadFile(hFile, pData, sizeInBytes, &dwBytesRead, nullptr) == TRUE) {
|
||||
restingBytes -= dwBytesRead;
|
||||
pData = (void *)(((unsigned char *)pData) + dwBytesRead);
|
||||
if (restingBytes > 0) cout << endl << "Still " << restingBytes << " to read!";
|
||||
|
@ -164,7 +164,7 @@ bool bufferedFileClass::writeBytes(unsigned int threadNo, long long positionInFi
|
|||
{
|
||||
// parameters ok?
|
||||
if (threadNo >= numThreads) return false;
|
||||
if (pData == NULL) return false;
|
||||
if (pData == nullptr) return false;
|
||||
|
||||
// locals
|
||||
|
||||
|
@ -201,7 +201,7 @@ bool bufferedFileClass::readBytes(unsigned int threadNo, long long positionInFil
|
|||
{
|
||||
// parameters ok?
|
||||
if (threadNo >= numThreads) return false;
|
||||
if (pData == NULL) return false;
|
||||
if (pData == nullptr) return false;
|
||||
|
||||
// read from file into buffer if not enough data in buffer or if it is not an sequential reading operation?
|
||||
if (positionInFile != curReadingPointer[threadNo] || bytesInReadBuffer[threadNo] < numBytes) {
|
||||
|
|
|
@ -26,11 +26,11 @@ cyclicArray::cyclicArray(unsigned int blockSizeInBytes, unsigned int numberOfBlo
|
|||
curWritingBlock = 0;
|
||||
|
||||
// Open Database-File (FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH | FILE_FLAG_RANDOM_ACCESS)
|
||||
hFile = CreateFileA(fileName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
hFile = CreateFileA(fileName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
|
||||
// opened file succesfully
|
||||
if (hFile == INVALID_HANDLE_VALUE) {
|
||||
hFile = NULL;
|
||||
hFile = nullptr;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ cyclicArray::~cyclicArray()
|
|||
delete[] writingBlock;
|
||||
|
||||
// close file
|
||||
if (hFile != NULL) CloseHandle(hFile);
|
||||
if (hFile != nullptr) CloseHandle(hFile);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -61,10 +61,10 @@ void cyclicArray::writeDataToFile(HANDLE hFile, long long offset, unsigned int s
|
|||
|
||||
liDistanceToMove.QuadPart = offset;
|
||||
|
||||
while (!SetFilePointerEx(hFile, liDistanceToMove, NULL, FILE_BEGIN)) cout << endl << "SetFilePointerEx failed!";
|
||||
while (!SetFilePointerEx(hFile, liDistanceToMove, nullptr, FILE_BEGIN)) cout << endl << "SetFilePointerEx failed!";
|
||||
|
||||
while (restingBytes > 0) {
|
||||
if (WriteFile(hFile, pData, sizeInBytes, &dwBytesWritten, NULL) == TRUE) {
|
||||
if (WriteFile(hFile, pData, sizeInBytes, &dwBytesWritten, nullptr) == TRUE) {
|
||||
restingBytes -= dwBytesWritten;
|
||||
pData = (void *)(((unsigned char *)pData) + dwBytesWritten);
|
||||
if (restingBytes > 0) cout << endl << "Still " << restingBytes << " to write!";
|
||||
|
@ -86,10 +86,10 @@ void cyclicArray::readDataFromFile(HANDLE hFile, long long offset, unsigned int
|
|||
|
||||
liDistanceToMove.QuadPart = offset;
|
||||
|
||||
while (!SetFilePointerEx(hFile, liDistanceToMove, NULL, FILE_BEGIN)) cout << endl << "SetFilePointerEx failed!";
|
||||
while (!SetFilePointerEx(hFile, liDistanceToMove, nullptr, FILE_BEGIN)) cout << endl << "SetFilePointerEx failed!";
|
||||
|
||||
while (restingBytes > 0) {
|
||||
if (ReadFile(hFile, pData, sizeInBytes, &dwBytesRead, NULL) == TRUE) {
|
||||
if (ReadFile(hFile, pData, sizeInBytes, &dwBytesRead, nullptr) == TRUE) {
|
||||
restingBytes -= dwBytesRead;
|
||||
pData = (void *)(((unsigned char *)pData) + dwBytesRead);
|
||||
if (restingBytes > 0) cout << endl << "Still " << restingBytes << " to read!";
|
||||
|
@ -221,10 +221,10 @@ bool cyclicArray::loadFile(const char *fileName, LONGLONG &numBytesLoaded)
|
|||
numBytesLoaded = 0;
|
||||
|
||||
// cyclic array file must be open
|
||||
if (hFile == NULL) return false;
|
||||
if (hFile == nullptr) return false;
|
||||
|
||||
// Open Database-File (FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH | FILE_FLAG_RANDOM_ACCESS)
|
||||
hLoadFile = CreateFileA(fileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
hLoadFile = CreateFileA(fileName, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
|
||||
// opened file succesfully
|
||||
if (hLoadFile == INVALID_HANDLE_VALUE) {
|
||||
|
@ -288,12 +288,12 @@ bool cyclicArray::saveFile(const char *fileName)
|
|||
void *pointer;
|
||||
|
||||
// cyclic array file must be open
|
||||
if (hFile == NULL) {
|
||||
if (hFile == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Open Database-File (FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH | FILE_FLAG_RANDOM_ACCESS)
|
||||
hSaveFile = CreateFileA(fileName, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
hSaveFile = CreateFileA(fileName, GENERIC_WRITE, FILE_SHARE_WRITE, nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
|
||||
// opened file succesfully
|
||||
if (hSaveFile == INVALID_HANDLE_VALUE) {
|
||||
|
|
|
@ -75,7 +75,7 @@ void minMaxKI::play(fieldStruct *theField, unsigned int *pushFrom, unsigned int
|
|||
delete[] possibilities;
|
||||
|
||||
// release memory
|
||||
field = NULL;
|
||||
field = nullptr;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -120,7 +120,7 @@ unsigned int *minMaxKI::getPossSettingPhase(unsigned int *numPossibilities, void
|
|||
}
|
||||
|
||||
// possibility code is simple
|
||||
*pPossibilities = NULL;
|
||||
*pPossibilities = nullptr;
|
||||
|
||||
return idPossibility;
|
||||
}
|
||||
|
@ -204,7 +204,7 @@ unsigned int *minMaxKI::getPossStoneRemove(unsigned int *numPossibilities, void
|
|||
}
|
||||
|
||||
// possibility code is simple
|
||||
*pPossibilities = NULL;
|
||||
*pPossibilities = nullptr;
|
||||
|
||||
return idPossibility;
|
||||
}
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
miniMax::miniMax()
|
||||
{
|
||||
// init default values
|
||||
hFileShortKnotValues = NULL;
|
||||
hFilePlyInfo = NULL;
|
||||
hFileShortKnotValues = nullptr;
|
||||
hFilePlyInfo = nullptr;
|
||||
memoryUsed2 = 0;
|
||||
arrayInfos.c = this;
|
||||
arrayInfos.arrayInfosToBeUpdated.clear();
|
||||
|
@ -26,10 +26,10 @@ miniMax::miniMax()
|
|||
osPrint = &cout;
|
||||
verbosity = 3;
|
||||
stopOnCriticalError = true;
|
||||
pDataForUserPrintFunc = NULL;
|
||||
userPrintFunc = NULL;
|
||||
layerStats = NULL;
|
||||
plyInfos = NULL;
|
||||
pDataForUserPrintFunc = nullptr;
|
||||
userPrintFunc = nullptr;
|
||||
layerStats = nullptr;
|
||||
plyInfos = nullptr;
|
||||
fileDirectory.assign("");
|
||||
InitializeCriticalSection(&csDatabase);
|
||||
InitializeCriticalSection(&csOsPrint);
|
||||
|
@ -108,7 +108,7 @@ void *miniMax::getBestChoice(unsigned int tilLevel, unsigned int *choice, unsign
|
|||
knotStruct root;
|
||||
alphaBetaGlobalVars alphaBetaVars(this, getLayerNumber(0));
|
||||
runAlphaBetaVars tva(this, &alphaBetaVars, alphaBetaVars.layerNumber);
|
||||
srand((unsigned int)time(NULL));
|
||||
srand((unsigned int)time(nullptr));
|
||||
tva.curThreadNo = 0;
|
||||
|
||||
// prepare the situation
|
||||
|
@ -143,7 +143,7 @@ void miniMax::calculateDatabase(unsigned int maxDepthOfTree, bool onlyPrepareLay
|
|||
prepareDatabaseCalculation();
|
||||
|
||||
// when database not completed then do it
|
||||
if (hFileShortKnotValues != NULL && skvfHeader.completed == false) {
|
||||
if (hFileShortKnotValues != nullptr && skvfHeader.completed == false) {
|
||||
|
||||
// reserve memory
|
||||
lastCalculatedLayer.clear();
|
||||
|
|
|
@ -85,8 +85,8 @@ database: The database contains the arrays with the short knot values and the
|
|||
#define MM_ACTION_NONE 8
|
||||
|
||||
/*** Macros ***************************************************************************************************************************/
|
||||
#define SAFE_DELETE(p) { if(p) { delete (p); (p)=NULL; } }
|
||||
#define SAFE_DELETE_ARRAY(p) { if(p) { delete[] (p); (p)=NULL; } }
|
||||
#define SAFE_DELETE(p) { if(p) { delete (p); (p)=nullptr; } }
|
||||
#define SAFE_DELETE_ARRAY(p) { if(p) { delete[] (p); (p)=nullptr; } }
|
||||
|
||||
// here a macro is used instead of a function because the text 't' is passed like "blabla" << endl << aVariable
|
||||
#define PRINT(v, c, t) \
|
||||
|
@ -94,7 +94,7 @@ database: The database contains the arrays with the short knot values and the
|
|||
if (c->verbosity > v) { \
|
||||
EnterCriticalSection(&c->csOsPrint); \
|
||||
*c->osPrint << endl << t; \
|
||||
if (c->userPrintFunc != NULL) { \
|
||||
if (c->userPrintFunc != nullptr) { \
|
||||
c->userPrintFunc(c->pDataForUserPrintFunc); \
|
||||
} \
|
||||
LeaveCriticalSection(&c->csOsPrint); \
|
||||
|
@ -480,8 +480,8 @@ private:
|
|||
|
||||
struct runAlphaBetaVars : public threadManagerClass::threadVarsArrayItem, public alphaBetaDefaultThreadVars
|
||||
{
|
||||
knotStruct *branchArray = NULL; // array of size [(depthOfFullTree - tilLevel) * maxNumBranches] for storage of the branches at each search depth
|
||||
unsigned int *freqValuesSubMovesBranchWon = NULL; // ...
|
||||
knotStruct *branchArray = nullptr; // array of size [(depthOfFullTree - tilLevel) * maxNumBranches] for storage of the branches at each search depth
|
||||
unsigned int *freqValuesSubMovesBranchWon = nullptr; // ...
|
||||
unsigned int freqValuesSubMoves[4]; // ...
|
||||
|
||||
runAlphaBetaVars()
|
||||
|
@ -615,12 +615,12 @@ private:
|
|||
int verbosity = 2; // output detail level. default is 2
|
||||
unsigned char skvPerspectiveMatrix[4][2]; // [short knot value][current or opponent player] - A winning situation is a loosing situation for the opponent and so on ...
|
||||
bool calcDatabase = false; // true, if the database is currently beeing calculated
|
||||
HANDLE hFileShortKnotValues = NULL; // handle of the file for the short knot value
|
||||
HANDLE hFilePlyInfo = NULL; // handle of the file for the ply info
|
||||
HANDLE hFileShortKnotValues = nullptr; // handle of the file for the short knot value
|
||||
HANDLE hFilePlyInfo = nullptr; // handle of the file for the ply info
|
||||
skvFileHeaderStruct skvfHeader; // short knot value file header
|
||||
plyInfoFileHeaderStruct plyInfoHeader; // header of the ply info file
|
||||
string fileDirectory; // path of the folder where the database files are located
|
||||
ostream *osPrint = NULL; // stream for output. default is cout
|
||||
ostream *osPrint = nullptr; // stream for output. default is cout
|
||||
list<unsigned int> lastCalculatedLayer; //
|
||||
vector<unsigned int> layersToCalculate; // used in calcLayer() and getCurrentCalculatedLayers()
|
||||
bool onlyPrepareLayer = false; //
|
||||
|
@ -628,8 +628,8 @@ private:
|
|||
threadManagerClass threadManager; //
|
||||
CRITICAL_SECTION csDatabase; //
|
||||
CRITICAL_SECTION csOsPrint; // for thread safety when output is passed to osPrint
|
||||
void (*userPrintFunc)(void *) = NULL; // called every time output is passed to osPrint
|
||||
void *pDataForUserPrintFunc = NULL; // pointer passed when calling userPrintFunc
|
||||
void (*userPrintFunc)(void *) = nullptr; // called every time output is passed to osPrint
|
||||
void *pDataForUserPrintFunc = nullptr; // pointer passed when calling userPrintFunc
|
||||
arrayInfoContainer arrayInfos; // information about the arrays in memory
|
||||
|
||||
// thread specific or non-constant variables
|
||||
|
@ -640,12 +640,12 @@ private:
|
|||
unsigned int curCalculatedLayer = 0; // id of the currently calculated layer
|
||||
unsigned int curCalculationActionId = 0; // one of ...
|
||||
bool layerInDatabase = false; // true if the current considered layer has already been calculated and stored in the database
|
||||
void *pRootPossibilities = NULL; // pointer to the structure passed by getPossibilities() for the state at which getBestChoice() has been called
|
||||
layerStatsStruct *layerStats = NULL; // array of size [] containing general layer information and the skv of all layers
|
||||
plyInfoStruct *plyInfos = NULL; // array of size [] containing ply information
|
||||
void *pRootPossibilities = nullptr; // pointer to the structure passed by getPossibilities() for the state at which getBestChoice() has been called
|
||||
layerStatsStruct *layerStats = nullptr; // array of size [] containing general layer information and the skv of all layers
|
||||
plyInfoStruct *plyInfos = nullptr; // array of size [] containing ply information
|
||||
|
||||
// variables concerning the compression of the database
|
||||
// compressorClass * compressor = NULL;
|
||||
// compressorClass * compressor = nullptr;
|
||||
// unsigned int compressionAlgorithmnId = 0; // 0 or one of the COMPRESSOR_ALG_... constants
|
||||
|
||||
// database io operations per second
|
||||
|
|
|
@ -47,7 +47,7 @@ bool miniMax::calcKnotValuesByAlphaBeta(unsigned int layerNumber)
|
|||
void miniMax::alphaBetaSaveInDatabase(unsigned int threadNo, unsigned int layerNumber, unsigned int stateNumber, twoBit knotValue, plyInfoVarType plyValue, bool invertValue)
|
||||
{
|
||||
// locals
|
||||
unsigned int *symStateNumbers = NULL;
|
||||
unsigned int *symStateNumbers = nullptr;
|
||||
unsigned int numSymmetricStates;
|
||||
unsigned int sysStateNumber;
|
||||
unsigned int i;
|
||||
|
@ -98,7 +98,7 @@ bool miniMax::initAlphaBeta(alphaBetaGlobalVars &alphaBetaVars)
|
|||
ssInvArrayFilePath.str(""); ssInvArrayFilePath << fileDirectory << (fileDirectory.size() ? "\\" : "") << "invalidStates\\invalidStatesOfLayer" << alphaBetaVars.layerNumber << ".dat";
|
||||
|
||||
// does initialization file exist ?
|
||||
CreateDirectoryA(ssInvArrayDirectory.str().c_str(), NULL);
|
||||
CreateDirectoryA(ssInvArrayDirectory.str().c_str(), nullptr);
|
||||
invalidArray = new bufferedFileClass(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());
|
||||
|
@ -295,7 +295,7 @@ DWORD miniMax::runAlphaBetaThreadProc(void *pParameter, int index)
|
|||
|
||||
} else {
|
||||
// should not occur, because already tested by plyInfo == PLYINFO_VALUE_UNCALCULATED
|
||||
MessageBoxW(NULL, L"This event should never occur. if (!m->setSituation())", L"ERROR", MB_OK);
|
||||
MessageBoxW(nullptr, L"This event should never occur. if (!m->setSituation())", L"ERROR", MB_OK);
|
||||
}
|
||||
return TM_RETURN_VALUE_OK;
|
||||
}
|
||||
|
@ -396,7 +396,7 @@ bool miniMax::alphaBetaTryDataBase(knotStruct *knot, runAlphaBetaVars *rabVars,
|
|||
plyInfoVarType plyInfo = PLYINFO_VALUE_UNCALCULATED;
|
||||
|
||||
// use database ?
|
||||
if (hFilePlyInfo != NULL && hFileShortKnotValues != NULL && (calcDatabase || layerInDatabase)) {
|
||||
if (hFilePlyInfo != nullptr && hFileShortKnotValues != nullptr && (calcDatabase || layerInDatabase)) {
|
||||
|
||||
// situation already existend in database ?
|
||||
readKnotValueFromDatabase(rabVars->curThreadNo, layerNumber, stateNumber, shortKnotValue, invalidLayerOrStateNumber, subLayerInDatabaseAndCompleted);
|
||||
|
@ -469,7 +469,7 @@ void miniMax::alphaBetaTryPossibilites(knotStruct *knot, runAlphaBetaVars *rabVa
|
|||
if (rabVars->freqValuesSubMoves[SKV_VALUE_GAME_WON] > maxWonfreqValuesSubMoves && knot->branches[curPoss].shortValue == SKV_VALUE_GAME_DRAWN) {
|
||||
maxWonfreqValuesSubMoves = rabVars->freqValuesSubMoves[SKV_VALUE_GAME_WON];
|
||||
}
|
||||
if (hFileShortKnotValues != NULL && layerInDatabase) {
|
||||
if (hFileShortKnotValues != nullptr && layerInDatabase) {
|
||||
storeValueOfMove(rabVars->curThreadNo, idPossibility[curPoss], pPossibilities, knot->branches[curPoss].shortValue, rabVars->freqValuesSubMoves, knot->branches[curPoss].plyInfo);
|
||||
PRINT(0, this, "\t: " << ((knot->branches[curPoss].shortValue == SKV_VALUE_GAME_WON) ? "WON" : ((knot->branches[curPoss].shortValue == SKV_VALUE_GAME_LOST) ? "LOST" : ((knot->branches[curPoss].shortValue == SKV_VALUE_GAME_DRAWN) ? "DRAW" : "INVALID"))) << endl);
|
||||
} else {
|
||||
|
@ -480,8 +480,8 @@ void miniMax::alphaBetaTryPossibilites(knotStruct *knot, runAlphaBetaVars *rabVa
|
|||
}
|
||||
|
||||
// don't use alpha beta if using database
|
||||
if (hFileShortKnotValues != NULL && calcDatabase) continue;
|
||||
if (hFileShortKnotValues != NULL && tilLevel + 1 >= depthOfFullTree) continue;
|
||||
if (hFileShortKnotValues != nullptr && calcDatabase) continue;
|
||||
if (hFileShortKnotValues != nullptr && tilLevel + 1 >= depthOfFullTree) continue;
|
||||
|
||||
// alpha beta algorithmn
|
||||
if (!knot->isOpponentLevel) {
|
||||
|
@ -632,7 +632,7 @@ void miniMax::alphaBetaChooseBestMove(knotStruct *knot, runAlphaBetaVars *rabVar
|
|||
for (numBestChoices = 0, i = 0; i < knot->numPossibilities; i++) {
|
||||
|
||||
// use information in database
|
||||
if (layerInDatabase && hFileShortKnotValues != NULL) {
|
||||
if (layerInDatabase && hFileShortKnotValues != nullptr) {
|
||||
|
||||
// selected move with equal knot value
|
||||
if (knot->branches[i].shortValue == knot->shortValue) {
|
||||
|
|
|
@ -15,19 +15,19 @@
|
|||
void miniMax::closeDatabase()
|
||||
{
|
||||
// close database
|
||||
if (hFileShortKnotValues != NULL) {
|
||||
if (hFileShortKnotValues != nullptr) {
|
||||
unloadAllLayers();
|
||||
SAFE_DELETE_ARRAY(layerStats);
|
||||
CloseHandle(hFileShortKnotValues);
|
||||
hFileShortKnotValues = NULL;
|
||||
hFileShortKnotValues = nullptr;
|
||||
}
|
||||
|
||||
// close ply information file
|
||||
if (hFilePlyInfo != NULL) {
|
||||
if (hFilePlyInfo != nullptr) {
|
||||
unloadAllPlyInfos();
|
||||
SAFE_DELETE_ARRAY(plyInfos);
|
||||
CloseHandle(hFilePlyInfo);
|
||||
hFilePlyInfo = NULL;
|
||||
hFilePlyInfo = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -93,12 +93,12 @@ void miniMax::saveBytesToFile(HANDLE hFile, long long offset, unsigned int numBy
|
|||
|
||||
liDistanceToMove.QuadPart = offset;
|
||||
|
||||
while (errorPrint = !SetFilePointerEx(hFile, liDistanceToMove, NULL, FILE_BEGIN)) {
|
||||
while (errorPrint = !SetFilePointerEx(hFile, liDistanceToMove, nullptr, FILE_BEGIN)) {
|
||||
if (!errorPrint) PRINT(1, this, "ERROR: SetFilePointerEx failed!");
|
||||
}
|
||||
|
||||
while (restingBytes > 0) {
|
||||
if (WriteFile(hFile, myPointer, restingBytes, &dwBytesWritten, NULL) == TRUE) {
|
||||
if (WriteFile(hFile, myPointer, restingBytes, &dwBytesWritten, nullptr) == TRUE) {
|
||||
restingBytes -= dwBytesWritten;
|
||||
myPointer = (void *)(((unsigned char *)myPointer) + dwBytesWritten);
|
||||
if (restingBytes > 0) PRINT(2, this, "Still " << restingBytes << " to write!");
|
||||
|
@ -123,12 +123,12 @@ void miniMax::loadBytesFromFile(HANDLE hFile, long long offset, unsigned int num
|
|||
|
||||
liDistanceToMove.QuadPart = offset;
|
||||
|
||||
while (errorPrint = !SetFilePointerEx(hFile, liDistanceToMove, NULL, FILE_BEGIN)) {
|
||||
while (errorPrint = !SetFilePointerEx(hFile, liDistanceToMove, nullptr, FILE_BEGIN)) {
|
||||
if (!errorPrint) PRINT(0, this, "ERROR: SetFilePointerEx failed!");
|
||||
}
|
||||
|
||||
while (restingBytes > 0) {
|
||||
if (ReadFile(hFile, pBytes, restingBytes, &dwBytesRead, NULL) == TRUE) {
|
||||
if (ReadFile(hFile, pBytes, restingBytes, &dwBytesRead, nullptr) == TRUE) {
|
||||
restingBytes -= dwBytesRead;
|
||||
myPointer = (void *)(((unsigned char *)myPointer) + dwBytesRead);
|
||||
if (restingBytes > 0) {
|
||||
|
@ -149,7 +149,7 @@ bool miniMax::isCurrentStateInDatabase(unsigned int threadNo)
|
|||
{
|
||||
unsigned int layerNum, stateNumber;
|
||||
|
||||
if (hFileShortKnotValues == NULL) {
|
||||
if (hFileShortKnotValues == nullptr) {
|
||||
return false;
|
||||
} else {
|
||||
getLayerAndStateNumber(threadNo, layerNum, stateNumber);
|
||||
|
@ -164,9 +164,9 @@ bool miniMax::isCurrentStateInDatabase(unsigned int threadNo)
|
|||
void miniMax::saveHeader(skvFileHeaderStruct *dbH, layerStatsStruct *lStats)
|
||||
{
|
||||
DWORD dwBytesWritten;
|
||||
SetFilePointer(hFileShortKnotValues, 0, NULL, FILE_BEGIN);
|
||||
WriteFile(hFileShortKnotValues, dbH, sizeof(skvFileHeaderStruct), &dwBytesWritten, NULL);
|
||||
WriteFile(hFileShortKnotValues, lStats, sizeof(layerStatsStruct) * dbH->numLayers, &dwBytesWritten, NULL);
|
||||
SetFilePointer(hFileShortKnotValues, 0, nullptr, FILE_BEGIN);
|
||||
WriteFile(hFileShortKnotValues, dbH, sizeof(skvFileHeaderStruct), &dwBytesWritten, nullptr);
|
||||
WriteFile(hFileShortKnotValues, lStats, sizeof(layerStatsStruct) * dbH->numLayers, &dwBytesWritten, nullptr);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -176,9 +176,9 @@ void miniMax::saveHeader(skvFileHeaderStruct *dbH, layerStatsStruct *lStats)
|
|||
void miniMax::saveHeader(plyInfoFileHeaderStruct *piH, plyInfoStruct *pInfo)
|
||||
{
|
||||
DWORD dwBytesWritten;
|
||||
SetFilePointer(hFilePlyInfo, 0, NULL, FILE_BEGIN);
|
||||
WriteFile(hFilePlyInfo, piH, sizeof(plyInfoFileHeaderStruct), &dwBytesWritten, NULL);
|
||||
WriteFile(hFilePlyInfo, pInfo, sizeof(plyInfoStruct) * piH->numLayers, &dwBytesWritten, NULL);
|
||||
SetFilePointer(hFilePlyInfo, 0, nullptr, FILE_BEGIN);
|
||||
WriteFile(hFilePlyInfo, piH, sizeof(plyInfoFileHeaderStruct), &dwBytesWritten, nullptr);
|
||||
WriteFile(hFilePlyInfo, pInfo, sizeof(plyInfoStruct) * piH->numLayers, &dwBytesWritten, nullptr);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -208,7 +208,7 @@ void miniMax::openSkvFile(const char *directory, unsigned int maximumNumberOfBra
|
|||
unsigned int i;
|
||||
|
||||
// don't open file twice
|
||||
if (hFileShortKnotValues != NULL) return;
|
||||
if (hFileShortKnotValues != nullptr) return;
|
||||
|
||||
// remember directory name
|
||||
fileDirectory.assign(directory);
|
||||
|
@ -216,11 +216,11 @@ void miniMax::openSkvFile(const char *directory, unsigned int maximumNumberOfBra
|
|||
PRINT(2, this, "Open short knot value file: " << fileDirectory << (strlen(directory) ? "\\" : "") << "shortKnotValue.dat" << endl);
|
||||
|
||||
// Open Database-File (FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH | FILE_FLAG_RANDOM_ACCESS)
|
||||
hFileShortKnotValues = CreateFileA(ssDatabaseFile.str().c_str(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
hFileShortKnotValues = CreateFileA(ssDatabaseFile.str().c_str(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
|
||||
// opened file succesfully
|
||||
if (hFileShortKnotValues == INVALID_HANDLE_VALUE) {
|
||||
hFileShortKnotValues = NULL;
|
||||
hFileShortKnotValues = nullptr;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -229,7 +229,7 @@ void miniMax::openSkvFile(const char *directory, unsigned int maximumNumberOfBra
|
|||
maxNumBranches = maximumNumberOfBranches;
|
||||
|
||||
// database complete ?
|
||||
ReadFile(hFileShortKnotValues, &skvfHeader, sizeof(skvFileHeaderStruct), &dwBytesRead, NULL);
|
||||
ReadFile(hFileShortKnotValues, &skvfHeader, sizeof(skvFileHeaderStruct), &dwBytesRead, nullptr);
|
||||
|
||||
// invalid file ?
|
||||
if (dwBytesRead != sizeof(skvFileHeaderStruct) || skvfHeader.headerCode != SKV_FILE_HEADER_CODE) {
|
||||
|
@ -247,8 +247,8 @@ void miniMax::openSkvFile(const char *directory, unsigned int maximumNumberOfBra
|
|||
layerStats[i].partnerLayer = getPartnerLayer(i);
|
||||
layerStats[i].knotsInLayer = getNumberOfKnotsInLayer(i);
|
||||
layerStats[i].sizeInBytes = (layerStats[i].knotsInLayer + 3) / 4;
|
||||
layerStats[i].shortKnotValueByte = NULL;
|
||||
layerStats[i].skvCompressed = NULL;
|
||||
layerStats[i].shortKnotValueByte = nullptr;
|
||||
layerStats[i].skvCompressed = nullptr;
|
||||
layerStats[i].layerIsLoaded = false;
|
||||
layerStats[i].layerIsCompletedAndInFile = false;
|
||||
layerStats[i].numWonStates = 0;
|
||||
|
@ -267,10 +267,10 @@ void miniMax::openSkvFile(const char *directory, unsigned int maximumNumberOfBra
|
|||
// read layer stats
|
||||
} else {
|
||||
layerStats = new layerStatsStruct[skvfHeader.numLayers];
|
||||
ReadFile(hFileShortKnotValues, layerStats, sizeof(layerStatsStruct) * skvfHeader.numLayers, &dwBytesRead, NULL);
|
||||
ReadFile(hFileShortKnotValues, layerStats, sizeof(layerStatsStruct) * skvfHeader.numLayers, &dwBytesRead, nullptr);
|
||||
for (i = 0; i < skvfHeader.numLayers; i++) {
|
||||
layerStats[i].shortKnotValueByte = NULL;
|
||||
layerStats[i].skvCompressed = NULL;
|
||||
layerStats[i].shortKnotValueByte = nullptr;
|
||||
layerStats[i].skvCompressed = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -287,18 +287,18 @@ void miniMax::openPlyInfoFile(const char *directory)
|
|||
unsigned int i;
|
||||
|
||||
// don't open file twice
|
||||
if (hFilePlyInfo != NULL) return;
|
||||
if (hFilePlyInfo != nullptr) return;
|
||||
|
||||
// remember directory name
|
||||
ssFile << directory << (strlen(directory) ? "\\" : "") << "plyInfo.dat";
|
||||
PRINT(2, this, "Open ply info file: " << ssFile.str() << endl << endl);
|
||||
|
||||
// Open Database-File (FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH | FILE_FLAG_RANDOM_ACCESS)
|
||||
hFilePlyInfo = CreateFileA(ssFile.str().c_str(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
hFilePlyInfo = CreateFileA(ssFile.str().c_str(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
|
||||
// opened file succesfully
|
||||
if (hFilePlyInfo == INVALID_HANDLE_VALUE) {
|
||||
hFilePlyInfo = NULL;
|
||||
hFilePlyInfo = nullptr;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -306,7 +306,7 @@ void miniMax::openPlyInfoFile(const char *directory)
|
|||
plyInfoHeader.headerCode = 0;
|
||||
|
||||
// database complete ?
|
||||
ReadFile(hFilePlyInfo, &plyInfoHeader, sizeof(plyInfoHeader), &dwBytesRead, NULL);
|
||||
ReadFile(hFilePlyInfo, &plyInfoHeader, sizeof(plyInfoHeader), &dwBytesRead, nullptr);
|
||||
|
||||
// invalid file ?
|
||||
if (dwBytesRead != sizeof(plyInfoHeader) || plyInfoHeader.headerCode != PLYINFO_HEADER_CODE) {
|
||||
|
@ -321,8 +321,8 @@ void miniMax::openPlyInfoFile(const char *directory)
|
|||
|
||||
for (i = 0; i < plyInfoHeader.numLayers; i++) {
|
||||
plyInfos[i].knotsInLayer = getNumberOfKnotsInLayer(i);
|
||||
plyInfos[i].plyInfo = NULL;
|
||||
plyInfos[i].plyInfoCompressed = NULL;
|
||||
plyInfos[i].plyInfo = nullptr;
|
||||
plyInfos[i].plyInfoCompressed = nullptr;
|
||||
plyInfos[i].plyInfoIsLoaded = false;
|
||||
plyInfos[i].plyInfoIsCompletedAndInFile = false;
|
||||
plyInfos[i].sizeInBytes = plyInfos[i].knotsInLayer * sizeof(plyInfoVarType);
|
||||
|
@ -338,10 +338,10 @@ void miniMax::openPlyInfoFile(const char *directory)
|
|||
// read layer stats
|
||||
} else {
|
||||
plyInfos = new plyInfoStruct[plyInfoHeader.numLayers];
|
||||
ReadFile(hFilePlyInfo, plyInfos, sizeof(plyInfoStruct) * plyInfoHeader.numLayers, &dwBytesRead, NULL);
|
||||
ReadFile(hFilePlyInfo, plyInfos, sizeof(plyInfoStruct) * plyInfoHeader.numLayers, &dwBytesRead, nullptr);
|
||||
for (i = 0; i < plyInfoHeader.numLayers; i++) {
|
||||
plyInfos[i].plyInfo = NULL;
|
||||
plyInfos[i].plyInfoCompressed = NULL;
|
||||
plyInfos[i].plyInfo = nullptr;
|
||||
plyInfos[i].plyInfoCompressed = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,11 +31,11 @@ bool miniMax::calcKnotValuesByRetroAnalysis(vector<unsigned int> &layersToCalcul
|
|||
// init retro vars
|
||||
retroVars.thread.resize(threadManager.getNumThreads());
|
||||
for (threadNo = 0; threadNo < threadManager.getNumThreads(); threadNo++) {
|
||||
retroVars.thread[threadNo].statesToProcess.resize(PLYINFO_EXP_VALUE, NULL);
|
||||
retroVars.thread[threadNo].statesToProcess.resize(PLYINFO_EXP_VALUE, nullptr);
|
||||
retroVars.thread[threadNo].numStatesToProcess = 0;
|
||||
retroVars.thread[threadNo].threadNo = threadNo;
|
||||
}
|
||||
retroVars.countArrays.resize(layersToCalculate.size(), NULL);
|
||||
retroVars.countArrays.resize(layersToCalculate.size(), nullptr);
|
||||
retroVars.layerInitialized.resize(skvfHeader.numLayers, false);
|
||||
retroVars.layersToCalculate = layersToCalculate;
|
||||
retroVars.pMiniMax = this;
|
||||
|
@ -91,7 +91,7 @@ freeMem:
|
|||
}
|
||||
}
|
||||
for (curLayer = 0; curLayer < layersToCalculate.size(); curLayer++) {
|
||||
if (retroVars.countArrays[curLayer] != NULL) {
|
||||
if (retroVars.countArrays[curLayer] != nullptr) {
|
||||
memoryUsed2 -= layerStats[layersToCalculate[curLayer]].knotsInLayer * sizeof(countArrayVarType);
|
||||
arrayInfos.removeArray(layersToCalculate[curLayer], arrayInfoStruct::arrayType_countArray, layerStats[layersToCalculate[curLayer]].knotsInLayer * sizeof(countArrayVarType), 0);
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ bool miniMax::initRetroAnalysis(retroAnalysisGlobalVars &retroVars)
|
|||
ssInitArrayFilePath.str(""); ssInitArrayFilePath << fileDirectory << (fileDirectory.size() ? "\\" : "") << "initLayer\\initLayer" << layerNumber << ".dat";
|
||||
|
||||
// does initialization file exist ?
|
||||
CreateDirectoryA(ssInitArrayPath.str().c_str(), NULL);
|
||||
CreateDirectoryA(ssInitArrayPath.str().c_str(), nullptr);
|
||||
initArray = new bufferedFileClass(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());
|
||||
|
@ -266,7 +266,7 @@ bool miniMax::prepareCountArrays(retroAnalysisGlobalVars &retroVars)
|
|||
DWORD dwWritten;
|
||||
DWORD dwRead;
|
||||
LARGE_INTEGER fileSize;
|
||||
HANDLE hFileCountArray = NULL; // file handle for loading and saving the arrays in 'countArrays'
|
||||
HANDLE hFileCountArray = nullptr; // file handle for loading and saving the arrays in 'countArrays'
|
||||
stringstream ssCountArrayPath;
|
||||
stringstream ssCountArrayFilePath;
|
||||
stringstream ssLayers;
|
||||
|
@ -279,8 +279,8 @@ bool miniMax::prepareCountArrays(retroAnalysisGlobalVars &retroVars)
|
|||
curCalculationActionId = MM_ACTION_PREPARE_COUNT_ARRAY;
|
||||
|
||||
// prepare count arrays
|
||||
CreateDirectoryA(ssCountArrayPath.str().c_str(), NULL);
|
||||
if ((hFileCountArray = CreateFileA(ssCountArrayFilePath.str().c_str(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) {
|
||||
CreateDirectoryA(ssCountArrayPath.str().c_str(), nullptr);
|
||||
if ((hFileCountArray = CreateFileA(ssCountArrayFilePath.str().c_str(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr)) == INVALID_HANDLE_VALUE) {
|
||||
PRINT(0, this, "ERROR: Could not open File " << ssCountArrayFilePath.str() << "!");
|
||||
return falseOrStop();
|
||||
}
|
||||
|
@ -299,7 +299,7 @@ bool miniMax::prepareCountArrays(retroAnalysisGlobalVars &retroVars)
|
|||
|
||||
for (curLayer = 0; curLayer < retroVars.layersToCalculate.size(); curLayer++) {
|
||||
numKnotsInCurLayer = layerStats[retroVars.layersToCalculate[curLayer]].knotsInLayer;
|
||||
if (!ReadFile(hFileCountArray, retroVars.countArrays[curLayer], numKnotsInCurLayer * sizeof(countArrayVarType), &dwRead, NULL)) return falseOrStop();
|
||||
if (!ReadFile(hFileCountArray, retroVars.countArrays[curLayer], numKnotsInCurLayer * sizeof(countArrayVarType), &dwRead, nullptr)) return falseOrStop();
|
||||
if (dwRead != numKnotsInCurLayer * sizeof(countArrayVarType)) return falseOrStop();
|
||||
}
|
||||
|
||||
|
@ -323,7 +323,7 @@ bool miniMax::prepareCountArrays(retroAnalysisGlobalVars &retroVars)
|
|||
// save to file
|
||||
for (curLayer = 0, dwWritten = 0; curLayer < retroVars.layersToCalculate.size(); curLayer++) {
|
||||
numKnotsInCurLayer = layerStats[retroVars.layersToCalculate[curLayer]].knotsInLayer;
|
||||
if (!WriteFile(hFileCountArray, retroVars.countArrays[curLayer], numKnotsInCurLayer * sizeof(countArrayVarType), &dwWritten, NULL)) return falseOrStop();
|
||||
if (!WriteFile(hFileCountArray, retroVars.countArrays[curLayer], numKnotsInCurLayer * sizeof(countArrayVarType), &dwWritten, nullptr)) return falseOrStop();
|
||||
if (dwWritten != numKnotsInCurLayer * sizeof(countArrayVarType)) return falseOrStop();
|
||||
}
|
||||
PRINT(2, this, " Count array saved to file: " << ssCountArrayFilePath.str());
|
||||
|
@ -595,7 +595,7 @@ DWORD miniMax::performRetroAnalysisThreadProc(void *pParameter)
|
|||
for (numStatesProcessed = 0, curNumPlies = 0; curNumPlies < threadVars->statesToProcess.size(); curNumPlies++) {
|
||||
|
||||
// skip empty and uninitialized cyclic arrays
|
||||
if (threadVars->statesToProcess[curNumPlies] != NULL) {
|
||||
if (threadVars->statesToProcess[curNumPlies] != nullptr) {
|
||||
|
||||
if (threadNo == 0) {
|
||||
PRINT(0, m, " Current number of plies: " << (unsigned int)curNumPlies << "/" << threadVars->statesToProcess.size());
|
||||
|
@ -726,16 +726,16 @@ bool miniMax::addStateToProcessQueue(retroAnalysisGlobalVars &retroVars, retroAn
|
|||
{
|
||||
// resize vector if too small
|
||||
if (plyNumber >= threadVars.statesToProcess.size()) {
|
||||
threadVars.statesToProcess.resize(max(plyNumber + 1, 10 * threadVars.statesToProcess.size()), NULL);
|
||||
threadVars.statesToProcess.resize(max(plyNumber + 1, 10 * threadVars.statesToProcess.size()), nullptr);
|
||||
PRINT(4, this, " statesToProcess resized to " << threadVars.statesToProcess.size());
|
||||
}
|
||||
|
||||
// initialize cyclic array if necessary
|
||||
if (threadVars.statesToProcess[plyNumber] == NULL) {
|
||||
if (threadVars.statesToProcess[plyNumber] == nullptr) {
|
||||
stringstream ssStatesToProcessFilePath;
|
||||
stringstream ssStatesToProcessPath;
|
||||
ssStatesToProcessPath << fileDirectory << (fileDirectory.size() ? "\\" : "") << "statesToProcess";
|
||||
CreateDirectoryA(ssStatesToProcessPath.str().c_str(), NULL);
|
||||
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());
|
||||
|
|
|
@ -43,7 +43,7 @@ unsigned int miniMax::getLastCalculatedLayer()
|
|||
//-----------------------------------------------------------------------------
|
||||
bool miniMax::isLayerInDatabase(unsigned int layerNum)
|
||||
{
|
||||
if (layerStats == NULL) return false;
|
||||
if (layerStats == nullptr) return false;
|
||||
return layerStats[layerNum].layerIsCompletedAndInFile;
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ bool miniMax::isLayerInDatabase(unsigned int layerNum)
|
|||
//-----------------------------------------------------------------------------
|
||||
long long miniMax::getLayerSizeInBytes(unsigned int layerNum)
|
||||
{
|
||||
if (plyInfos == NULL || layerStats == NULL) return 0;
|
||||
if (plyInfos == nullptr || layerStats == nullptr) return 0;
|
||||
return (long long)layerStats[layerNum].sizeInBytes + (long long)plyInfos[layerNum].sizeInBytes;
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ long long miniMax::getLayerSizeInBytes(unsigned int layerNum)
|
|||
//-----------------------------------------------------------------------------
|
||||
miniMax::stateNumberVarType miniMax::getNumWonStates(unsigned int layerNum)
|
||||
{
|
||||
if (layerStats == NULL) return 0;
|
||||
if (layerStats == nullptr) return 0;
|
||||
return layerStats[layerNum].numWonStates;
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ miniMax::stateNumberVarType miniMax::getNumWonStates(unsigned int layerNum)
|
|||
//-----------------------------------------------------------------------------
|
||||
miniMax::stateNumberVarType miniMax::getNumLostStates(unsigned int layerNum)
|
||||
{
|
||||
if (layerStats == NULL) return 0;
|
||||
if (layerStats == nullptr) return 0;
|
||||
return layerStats[layerNum].numLostStates;
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ miniMax::stateNumberVarType miniMax::getNumLostStates(unsigned int layerNum)
|
|||
//-----------------------------------------------------------------------------
|
||||
miniMax::stateNumberVarType miniMax::getNumDrawnStates(unsigned int layerNum)
|
||||
{
|
||||
if (layerStats == NULL) return 0;
|
||||
if (layerStats == nullptr) return 0;
|
||||
return layerStats[layerNum].numDrawnStates;
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ miniMax::stateNumberVarType miniMax::getNumDrawnStates(unsigned int layerNum)
|
|||
//-----------------------------------------------------------------------------
|
||||
miniMax::stateNumberVarType miniMax::getNumInvalidStates(unsigned int layerNum)
|
||||
{
|
||||
if (layerStats == NULL) return 0;
|
||||
if (layerStats == nullptr) return 0;
|
||||
return layerStats[layerNum].numInvalidStates;
|
||||
}
|
||||
|
||||
|
@ -177,14 +177,14 @@ bool miniMax::calcLayerStatistics(char *statisticsFileName)
|
|||
string text("");
|
||||
|
||||
// database must be open
|
||||
if (hFileShortKnotValues == NULL) return false;
|
||||
if (hFileShortKnotValues == nullptr) return false;
|
||||
|
||||
// Open statistics file
|
||||
statFile = CreateFileA(statisticsFileName, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
statFile = CreateFileA(statisticsFileName, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
|
||||
// opened file succesfully?
|
||||
if (statFile == INVALID_HANDLE_VALUE) {
|
||||
statFile = NULL;
|
||||
statFile = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -250,7 +250,7 @@ bool miniMax::calcLayerStatistics(char *statisticsFileName)
|
|||
}
|
||||
|
||||
// write to file and close it
|
||||
WriteFile(statFile, text.c_str(), (DWORD)text.length(), &dwBytesWritten, NULL);
|
||||
WriteFile(statFile, text.c_str(), (DWORD)text.length(), &dwBytesWritten, nullptr);
|
||||
CloseHandle(statFile);
|
||||
SAFE_DELETE_ARRAY(statsValueCounter);
|
||||
return true;
|
||||
|
@ -339,7 +339,7 @@ void miniMax::arrayInfoContainer::addArray(unsigned int layerNumber, unsigned in
|
|||
vectorArrays[layerNumber * arrayInfoStruct::numArrayTypes + type] = (--listArrays.end());
|
||||
|
||||
// update GUI
|
||||
if (c->userPrintFunc != NULL) {
|
||||
if (c->userPrintFunc != nullptr) {
|
||||
c->userPrintFunc(c->pDataForUserPrintFunc);
|
||||
}
|
||||
LeaveCriticalSection(&c->csOsPrint);
|
||||
|
@ -365,7 +365,7 @@ void miniMax::arrayInfoContainer::removeArray(unsigned int layerNumber, unsigned
|
|||
|
||||
// notify cahnge
|
||||
arrayInfoChange aic;
|
||||
aic.arrayInfo = NULL;
|
||||
aic.arrayInfo = nullptr;
|
||||
aic.itemIndex = (unsigned int)std::distance(listArrays.begin(), itr);
|
||||
arrayInfosToBeUpdated.push_back(aic);
|
||||
|
||||
|
@ -375,7 +375,7 @@ void miniMax::arrayInfoContainer::removeArray(unsigned int layerNumber, unsigned
|
|||
}
|
||||
|
||||
// update GUI
|
||||
if (c->userPrintFunc != NULL) {
|
||||
if (c->userPrintFunc != nullptr) {
|
||||
c->userPrintFunc(c->pDataForUserPrintFunc);
|
||||
}
|
||||
LeaveCriticalSection(&c->csOsPrint);
|
||||
|
@ -401,7 +401,7 @@ void miniMax::arrayInfoContainer::updateArray(unsigned int layerNumber, unsigned
|
|||
arrayInfosToBeUpdated.push_back(aic);
|
||||
|
||||
// update GUI
|
||||
if (c->userPrintFunc != NULL) {
|
||||
if (c->userPrintFunc != nullptr) {
|
||||
c->userPrintFunc(c->pDataForUserPrintFunc);
|
||||
}
|
||||
itr->updateCounter = 0;
|
||||
|
|
|
@ -19,7 +19,7 @@ bool miniMax::testLayer(unsigned int layerNumber)
|
|||
unsigned int returnValue;
|
||||
|
||||
// database open?
|
||||
if (hFileShortKnotValues == NULL || hFilePlyInfo == NULL) {
|
||||
if (hFileShortKnotValues == nullptr || hFilePlyInfo == nullptr) {
|
||||
PRINT(0, this, "ERROR: Database file not open!");
|
||||
return falseOrStop();
|
||||
}
|
||||
|
@ -490,12 +490,12 @@ bool miniMax::testIfSymStatesHaveSameValue(unsigned int layerNumber)
|
|||
plyInfoVarType numPliesTillCurState;
|
||||
plyInfoVarType numPliesTillSymState;
|
||||
unsigned int stateNumber = 0;
|
||||
unsigned int *symStateNumbers = NULL;
|
||||
unsigned int *symStateNumbers = nullptr;
|
||||
unsigned int numSymmetricStates;
|
||||
unsigned int i;
|
||||
|
||||
// database open?
|
||||
if (hFileShortKnotValues == NULL || hFilePlyInfo == NULL) {
|
||||
if (hFileShortKnotValues == nullptr || hFilePlyInfo == nullptr) {
|
||||
PRINT(0, this, "ERROR: Database files not open!");
|
||||
layerNumber = 0;
|
||||
goto errorInDatabase;
|
||||
|
|
|
@ -14,12 +14,12 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
muehle::muehle()
|
||||
{
|
||||
srand((unsigned)time(NULL));
|
||||
srand((unsigned)time(nullptr));
|
||||
|
||||
moveLogFrom = NULL;
|
||||
moveLogTo = NULL;
|
||||
playerOneKI = NULL;
|
||||
playerTwoKI = NULL;
|
||||
moveLogFrom = nullptr;
|
||||
moveLogTo = nullptr;
|
||||
playerOneKI = nullptr;
|
||||
playerTwoKI = nullptr;
|
||||
movesDone = 0;
|
||||
|
||||
field.createField();
|
||||
|
@ -238,7 +238,7 @@ bool muehle::getField(int *pField)
|
|||
unsigned int index;
|
||||
|
||||
// if no log is available than no game is in progress and field is invalid
|
||||
if (moveLogFrom == NULL) return false;
|
||||
if (moveLogFrom == nullptr) return false;
|
||||
|
||||
for (index = 0; index < field.size; index++) {
|
||||
if (field.warnings[index] != field.noWarning) pField[index] = (int)field.warnings[index];
|
||||
|
@ -283,8 +283,8 @@ void muehle::setNextPlayer()
|
|||
//-----------------------------------------------------------------------------
|
||||
bool muehle::isCurrentPlayerHuman()
|
||||
{
|
||||
if (field.curPlayer->id == field.playerOne) return (playerOneKI == NULL) ? true : false;
|
||||
else return (playerTwoKI == NULL) ? true : false;
|
||||
if (field.curPlayer->id == field.playerOne) return (playerOneKI == nullptr) ? true : false;
|
||||
else return (playerTwoKI == nullptr) ? true : false;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -293,8 +293,8 @@ bool muehle::isCurrentPlayerHuman()
|
|||
//-----------------------------------------------------------------------------
|
||||
bool muehle::isOpponentPlayerHuman()
|
||||
{
|
||||
if (field.oppPlayer->id == field.playerOne) return (playerOneKI == NULL) ? true : false;
|
||||
else return (playerTwoKI == NULL) ? true : false;
|
||||
if (field.oppPlayer->id == field.playerOne) return (playerOneKI == nullptr) ? true : false;
|
||||
else return (playerTwoKI == nullptr) ? true : false;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -322,7 +322,7 @@ void muehle::getChoiceOfSpecialKI(muehleKI *KI, unsigned int *pushFrom, unsigned
|
|||
*pushTo = field.size;
|
||||
theField.createField();
|
||||
field.copyField(&theField);
|
||||
if (KI != NULL && (field.settingPhase || field.curPlayer->numPossibleMoves > 0) && winner == 0) KI->play(&theField, pushFrom, pushTo);
|
||||
if (KI != nullptr && (field.settingPhase || field.curPlayer->numPossibleMoves > 0) && winner == 0) KI->play(&theField, pushFrom, pushTo);
|
||||
theField.deleteField();
|
||||
}
|
||||
|
||||
|
@ -340,9 +340,9 @@ void muehle::getComputersChoice(unsigned int *pushFrom, unsigned int *pushTo)
|
|||
|
||||
if ((field.settingPhase || field.curPlayer->numPossibleMoves > 0) && winner == 0) {
|
||||
if (field.curPlayer->id == field.playerOne) {
|
||||
if (playerOneKI != NULL) playerOneKI->play(&theField, pushFrom, pushTo);
|
||||
if (playerOneKI != nullptr) playerOneKI->play(&theField, pushFrom, pushTo);
|
||||
} else {
|
||||
if (playerTwoKI != NULL) playerTwoKI->play(&theField, pushFrom, pushTo);
|
||||
if (playerTwoKI != nullptr) playerTwoKI->play(&theField, pushFrom, pushTo);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,8 +22,8 @@ using namespace std;
|
|||
#define MAX_NUM_MOVES 10000
|
||||
|
||||
/*** Makros ******************************************************/
|
||||
#define SAFE_DELETE(p) { if(p) { delete (p); (p)=NULL; } }
|
||||
#define SAFE_DELETE_ARRAY(p) { if(p) { delete[] (p); (p)=NULL; } }
|
||||
#define SAFE_DELETE(p) { if(p) { delete (p); (p)=nullptr; } }
|
||||
#define SAFE_DELETE_ARRAY(p) { if(p) { delete[] (p); (p)=nullptr; } }
|
||||
|
||||
/*** Klassen *********************************************************/
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
/*** Konstanten ******************************************************/
|
||||
#define MAX_NUM_POS_MOVES (3 * 18) // not (9 * 4) = 36 since the possibilities with 3 stones are more
|
||||
#define SAFE_DELETE(p) { if(p) { delete (p); (p)=NULL; } }
|
||||
#define SAFE_DELETE(p) { if(p) { delete (p); (p)=nullptr; } }
|
||||
|
||||
/*** Klassen *********************************************************/
|
||||
|
||||
|
|
|
@ -215,35 +215,35 @@ perfectKI::perfectKI(const char *directory)
|
|||
if (strlen(directory) && PathFileExistsA(directory)) {
|
||||
ssPreCalcVarsFilePath << directory << "\\";
|
||||
} ssPreCalcVarsFilePath << "preCalculatedVars.dat";
|
||||
hFilePreCalcVars = CreateFileA(ssPreCalcVarsFilePath.str().c_str(), GENERIC_READ /*| GENERIC_WRITE*/, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
ReadFile(hFilePreCalcVars, &preCalcVarsHeader, sizeof(preCalcedVarsFileHeaderStruct), &dwBytesRead, NULL);
|
||||
hFilePreCalcVars = CreateFileA(ssPreCalcVarsFilePath.str().c_str(), GENERIC_READ /*| GENERIC_WRITE*/, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
ReadFile(hFilePreCalcVars, &preCalcVarsHeader, sizeof(preCalcedVarsFileHeaderStruct), &dwBytesRead, nullptr);
|
||||
|
||||
// vars already stored in file?
|
||||
if (dwBytesRead) {
|
||||
|
||||
// Read from file
|
||||
ReadFile(hFilePreCalcVars, layer, sizeof(layerStruct) * NUM_LAYERS, &dwBytesRead, NULL);
|
||||
ReadFile(hFilePreCalcVars, layerIndex, sizeof(unsigned int) * 2 * NUM_STONES_PER_PLAYER_PLUS_ONE * NUM_STONES_PER_PLAYER_PLUS_ONE, &dwBytesRead, NULL);
|
||||
ReadFile(hFilePreCalcVars, anzahlStellungenAB, sizeof(unsigned int) * NUM_STONES_PER_PLAYER_PLUS_ONE * NUM_STONES_PER_PLAYER_PLUS_ONE, &dwBytesRead, NULL);
|
||||
ReadFile(hFilePreCalcVars, anzahlStellungenCD, sizeof(unsigned int) * NUM_STONES_PER_PLAYER_PLUS_ONE * NUM_STONES_PER_PLAYER_PLUS_ONE, &dwBytesRead, NULL);
|
||||
ReadFile(hFilePreCalcVars, indexAB, sizeof(unsigned int) * MAX_ANZ_STELLUNGEN_A * MAX_ANZ_STELLUNGEN_B, &dwBytesRead, NULL);
|
||||
ReadFile(hFilePreCalcVars, indexCD, sizeof(unsigned int) * MAX_ANZ_STELLUNGEN_C * MAX_ANZ_STELLUNGEN_D, &dwBytesRead, NULL);
|
||||
ReadFile(hFilePreCalcVars, symmetryOperationCD, sizeof(unsigned char) * MAX_ANZ_STELLUNGEN_C * MAX_ANZ_STELLUNGEN_D, &dwBytesRead, NULL);
|
||||
ReadFile(hFilePreCalcVars, powerOfThree, sizeof(unsigned int) * (numSquaresGroupC + numSquaresGroupD), &dwBytesRead, NULL);
|
||||
ReadFile(hFilePreCalcVars, symmetryOperationTable, sizeof(unsigned int) * fieldStruct::size * NUM_SYM_OPERATIONS, &dwBytesRead, NULL);
|
||||
ReadFile(hFilePreCalcVars, reverseSymOperation, sizeof(unsigned int) * NUM_SYM_OPERATIONS, &dwBytesRead, NULL);
|
||||
ReadFile(hFilePreCalcVars, concSymOperation, sizeof(unsigned int) * NUM_SYM_OPERATIONS * NUM_SYM_OPERATIONS, &dwBytesRead, NULL);
|
||||
ReadFile(hFilePreCalcVars, mOverN, sizeof(unsigned int) * (fieldStruct::size + 1) * (fieldStruct::size + 1), &dwBytesRead, NULL);
|
||||
ReadFile(hFilePreCalcVars, valueOfMove, sizeof(unsigned char) * fieldStruct::size * fieldStruct::size, &dwBytesRead, NULL);
|
||||
ReadFile(hFilePreCalcVars, plyInfoForOutput, sizeof(plyInfoVarType) * fieldStruct::size * fieldStruct::size, &dwBytesRead, NULL);
|
||||
ReadFile(hFilePreCalcVars, incidencesValuesSubMoves, sizeof(unsigned int) * 4 * fieldStruct::size * fieldStruct::size, &dwBytesRead, NULL);
|
||||
ReadFile(hFilePreCalcVars, layer, sizeof(layerStruct) * NUM_LAYERS, &dwBytesRead, nullptr);
|
||||
ReadFile(hFilePreCalcVars, layerIndex, sizeof(unsigned int) * 2 * NUM_STONES_PER_PLAYER_PLUS_ONE * NUM_STONES_PER_PLAYER_PLUS_ONE, &dwBytesRead, nullptr);
|
||||
ReadFile(hFilePreCalcVars, anzahlStellungenAB, sizeof(unsigned int) * NUM_STONES_PER_PLAYER_PLUS_ONE * NUM_STONES_PER_PLAYER_PLUS_ONE, &dwBytesRead, nullptr);
|
||||
ReadFile(hFilePreCalcVars, anzahlStellungenCD, sizeof(unsigned int) * NUM_STONES_PER_PLAYER_PLUS_ONE * NUM_STONES_PER_PLAYER_PLUS_ONE, &dwBytesRead, nullptr);
|
||||
ReadFile(hFilePreCalcVars, indexAB, sizeof(unsigned int) * MAX_ANZ_STELLUNGEN_A * MAX_ANZ_STELLUNGEN_B, &dwBytesRead, nullptr);
|
||||
ReadFile(hFilePreCalcVars, indexCD, sizeof(unsigned int) * MAX_ANZ_STELLUNGEN_C * MAX_ANZ_STELLUNGEN_D, &dwBytesRead, nullptr);
|
||||
ReadFile(hFilePreCalcVars, symmetryOperationCD, sizeof(unsigned char) * MAX_ANZ_STELLUNGEN_C * MAX_ANZ_STELLUNGEN_D, &dwBytesRead, nullptr);
|
||||
ReadFile(hFilePreCalcVars, powerOfThree, sizeof(unsigned int) * (numSquaresGroupC + numSquaresGroupD), &dwBytesRead, nullptr);
|
||||
ReadFile(hFilePreCalcVars, symmetryOperationTable, sizeof(unsigned int) * fieldStruct::size * NUM_SYM_OPERATIONS, &dwBytesRead, nullptr);
|
||||
ReadFile(hFilePreCalcVars, reverseSymOperation, sizeof(unsigned int) * NUM_SYM_OPERATIONS, &dwBytesRead, nullptr);
|
||||
ReadFile(hFilePreCalcVars, concSymOperation, sizeof(unsigned int) * NUM_SYM_OPERATIONS * NUM_SYM_OPERATIONS, &dwBytesRead, nullptr);
|
||||
ReadFile(hFilePreCalcVars, mOverN, sizeof(unsigned int) * (fieldStruct::size + 1) * (fieldStruct::size + 1), &dwBytesRead, nullptr);
|
||||
ReadFile(hFilePreCalcVars, valueOfMove, sizeof(unsigned char) * fieldStruct::size * fieldStruct::size, &dwBytesRead, nullptr);
|
||||
ReadFile(hFilePreCalcVars, plyInfoForOutput, sizeof(plyInfoVarType) * fieldStruct::size * fieldStruct::size, &dwBytesRead, nullptr);
|
||||
ReadFile(hFilePreCalcVars, incidencesValuesSubMoves, sizeof(unsigned int) * 4 * fieldStruct::size * fieldStruct::size, &dwBytesRead, nullptr);
|
||||
|
||||
// process originalStateAB[][]
|
||||
for (a = 0; a <= NUM_STONES_PER_PLAYER; a++) {
|
||||
for (b = 0; b <= NUM_STONES_PER_PLAYER; b++) {
|
||||
if (a + b > numSquaresGroupA + numSquaresGroupB) continue;
|
||||
originalStateAB[a][b] = new unsigned int[anzahlStellungenAB[a][b]];
|
||||
ReadFile(hFilePreCalcVars, originalStateAB[a][b], sizeof(unsigned int) * anzahlStellungenAB[a][b], &dwBytesRead, NULL);
|
||||
ReadFile(hFilePreCalcVars, originalStateAB[a][b], sizeof(unsigned int) * anzahlStellungenAB[a][b], &dwBytesRead, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -252,7 +252,7 @@ perfectKI::perfectKI(const char *directory)
|
|||
for (b = 0; b <= NUM_STONES_PER_PLAYER; b++) {
|
||||
if (a + b > numSquaresGroupC + numSquaresGroupD) continue;
|
||||
originalStateCD[a][b] = new unsigned int[anzahlStellungenCD[a][b]];
|
||||
ReadFile(hFilePreCalcVars, originalStateCD[a][b], sizeof(unsigned int) * anzahlStellungenCD[a][b], &dwBytesRead, NULL);
|
||||
ReadFile(hFilePreCalcVars, originalStateCD[a][b], sizeof(unsigned int) * anzahlStellungenCD[a][b], &dwBytesRead, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -587,28 +587,28 @@ perfectKI::perfectKI(const char *directory)
|
|||
// write vars into file
|
||||
preCalcVarsHeader.sizeInBytes = sizeof(preCalcedVarsFileHeaderStruct);
|
||||
|
||||
WriteFile(hFilePreCalcVars, &preCalcVarsHeader, preCalcVarsHeader.sizeInBytes, &dwBytesWritten, NULL);
|
||||
WriteFile(hFilePreCalcVars, layer, sizeof(layerStruct) * NUM_LAYERS, &dwBytesWritten, NULL);
|
||||
WriteFile(hFilePreCalcVars, layerIndex, sizeof(unsigned int) * 2 * NUM_STONES_PER_PLAYER_PLUS_ONE * NUM_STONES_PER_PLAYER_PLUS_ONE, &dwBytesWritten, NULL);
|
||||
WriteFile(hFilePreCalcVars, anzahlStellungenAB, sizeof(unsigned int) * NUM_STONES_PER_PLAYER_PLUS_ONE * NUM_STONES_PER_PLAYER_PLUS_ONE, &dwBytesWritten, NULL);
|
||||
WriteFile(hFilePreCalcVars, anzahlStellungenCD, sizeof(unsigned int) * NUM_STONES_PER_PLAYER_PLUS_ONE * NUM_STONES_PER_PLAYER_PLUS_ONE, &dwBytesWritten, NULL);
|
||||
WriteFile(hFilePreCalcVars, indexAB, sizeof(unsigned int) * MAX_ANZ_STELLUNGEN_A * MAX_ANZ_STELLUNGEN_B, &dwBytesWritten, NULL);
|
||||
WriteFile(hFilePreCalcVars, indexCD, sizeof(unsigned int) * MAX_ANZ_STELLUNGEN_C * MAX_ANZ_STELLUNGEN_D, &dwBytesWritten, NULL);
|
||||
WriteFile(hFilePreCalcVars, symmetryOperationCD, sizeof(unsigned char) * MAX_ANZ_STELLUNGEN_C * MAX_ANZ_STELLUNGEN_D, &dwBytesWritten, NULL);
|
||||
WriteFile(hFilePreCalcVars, powerOfThree, sizeof(unsigned int) * (numSquaresGroupC + numSquaresGroupD), &dwBytesWritten, NULL);
|
||||
WriteFile(hFilePreCalcVars, symmetryOperationTable, sizeof(unsigned int) * fieldStruct::size * NUM_SYM_OPERATIONS, &dwBytesWritten, NULL);
|
||||
WriteFile(hFilePreCalcVars, reverseSymOperation, sizeof(unsigned int) * NUM_SYM_OPERATIONS, &dwBytesWritten, NULL);
|
||||
WriteFile(hFilePreCalcVars, concSymOperation, sizeof(unsigned int) * NUM_SYM_OPERATIONS * NUM_SYM_OPERATIONS, &dwBytesWritten, NULL);
|
||||
WriteFile(hFilePreCalcVars, mOverN, sizeof(unsigned int) * (fieldStruct::size + 1) * (fieldStruct::size + 1), &dwBytesWritten, NULL);
|
||||
WriteFile(hFilePreCalcVars, valueOfMove, sizeof(unsigned char) * fieldStruct::size * fieldStruct::size, &dwBytesWritten, NULL);
|
||||
WriteFile(hFilePreCalcVars, plyInfoForOutput, sizeof(plyInfoVarType) * fieldStruct::size * fieldStruct::size, &dwBytesWritten, NULL);
|
||||
WriteFile(hFilePreCalcVars, incidencesValuesSubMoves, sizeof(unsigned int) * 4 * fieldStruct::size * fieldStruct::size, &dwBytesWritten, NULL);
|
||||
WriteFile(hFilePreCalcVars, &preCalcVarsHeader, preCalcVarsHeader.sizeInBytes, &dwBytesWritten, nullptr);
|
||||
WriteFile(hFilePreCalcVars, layer, sizeof(layerStruct) * NUM_LAYERS, &dwBytesWritten, nullptr);
|
||||
WriteFile(hFilePreCalcVars, layerIndex, sizeof(unsigned int) * 2 * NUM_STONES_PER_PLAYER_PLUS_ONE * NUM_STONES_PER_PLAYER_PLUS_ONE, &dwBytesWritten, nullptr);
|
||||
WriteFile(hFilePreCalcVars, anzahlStellungenAB, sizeof(unsigned int) * NUM_STONES_PER_PLAYER_PLUS_ONE * NUM_STONES_PER_PLAYER_PLUS_ONE, &dwBytesWritten, nullptr);
|
||||
WriteFile(hFilePreCalcVars, anzahlStellungenCD, sizeof(unsigned int) * NUM_STONES_PER_PLAYER_PLUS_ONE * NUM_STONES_PER_PLAYER_PLUS_ONE, &dwBytesWritten, nullptr);
|
||||
WriteFile(hFilePreCalcVars, indexAB, sizeof(unsigned int) * MAX_ANZ_STELLUNGEN_A * MAX_ANZ_STELLUNGEN_B, &dwBytesWritten, nullptr);
|
||||
WriteFile(hFilePreCalcVars, indexCD, sizeof(unsigned int) * MAX_ANZ_STELLUNGEN_C * MAX_ANZ_STELLUNGEN_D, &dwBytesWritten, nullptr);
|
||||
WriteFile(hFilePreCalcVars, symmetryOperationCD, sizeof(unsigned char) * MAX_ANZ_STELLUNGEN_C * MAX_ANZ_STELLUNGEN_D, &dwBytesWritten, nullptr);
|
||||
WriteFile(hFilePreCalcVars, powerOfThree, sizeof(unsigned int) * (numSquaresGroupC + numSquaresGroupD), &dwBytesWritten, nullptr);
|
||||
WriteFile(hFilePreCalcVars, symmetryOperationTable, sizeof(unsigned int) * fieldStruct::size * NUM_SYM_OPERATIONS, &dwBytesWritten, nullptr);
|
||||
WriteFile(hFilePreCalcVars, reverseSymOperation, sizeof(unsigned int) * NUM_SYM_OPERATIONS, &dwBytesWritten, nullptr);
|
||||
WriteFile(hFilePreCalcVars, concSymOperation, sizeof(unsigned int) * NUM_SYM_OPERATIONS * NUM_SYM_OPERATIONS, &dwBytesWritten, nullptr);
|
||||
WriteFile(hFilePreCalcVars, mOverN, sizeof(unsigned int) * (fieldStruct::size + 1) * (fieldStruct::size + 1), &dwBytesWritten, nullptr);
|
||||
WriteFile(hFilePreCalcVars, valueOfMove, sizeof(unsigned char) * fieldStruct::size * fieldStruct::size, &dwBytesWritten, nullptr);
|
||||
WriteFile(hFilePreCalcVars, plyInfoForOutput, sizeof(plyInfoVarType) * fieldStruct::size * fieldStruct::size, &dwBytesWritten, nullptr);
|
||||
WriteFile(hFilePreCalcVars, incidencesValuesSubMoves, sizeof(unsigned int) * 4 * fieldStruct::size * fieldStruct::size, &dwBytesWritten, nullptr);
|
||||
|
||||
// process originalStateAB[][]
|
||||
for (a = 0; a <= NUM_STONES_PER_PLAYER; a++) {
|
||||
for (b = 0; b <= NUM_STONES_PER_PLAYER; b++) {
|
||||
if (a + b > numSquaresGroupA + numSquaresGroupB) continue;
|
||||
WriteFile(hFilePreCalcVars, originalStateAB[a][b], sizeof(unsigned int) * anzahlStellungenAB[a][b], &dwBytesWritten, NULL);
|
||||
WriteFile(hFilePreCalcVars, originalStateAB[a][b], sizeof(unsigned int) * anzahlStellungenAB[a][b], &dwBytesWritten, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -616,7 +616,7 @@ perfectKI::perfectKI(const char *directory)
|
|||
for (a = 0; a <= NUM_STONES_PER_PLAYER; a++) {
|
||||
for (b = 0; b <= NUM_STONES_PER_PLAYER; b++) {
|
||||
if (a + b > numSquaresGroupC + numSquaresGroupD) continue;
|
||||
WriteFile(hFilePreCalcVars, originalStateCD[a][b], sizeof(unsigned int) * anzahlStellungenCD[a][b], &dwBytesWritten, NULL);
|
||||
WriteFile(hFilePreCalcVars, originalStateCD[a][b], sizeof(unsigned int) * anzahlStellungenCD[a][b], &dwBytesWritten, nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -764,7 +764,7 @@ bool perfectKI::testLayers(unsigned int startTestFromLayer, unsigned int endTest
|
|||
//-----------------------------------------------------------------------------
|
||||
bool perfectKI::setDatabasePath(const char *directory)
|
||||
{
|
||||
if (directory == NULL) {
|
||||
if (directory == nullptr) {
|
||||
return false;
|
||||
} else {
|
||||
cout << "Path to database set to: " << directory << endl;
|
||||
|
@ -793,17 +793,17 @@ void perfectKI::prepareBestChoiceCalculation()
|
|||
//-----------------------------------------------------------------------------
|
||||
perfectKI::threadVarsStruct::threadVarsStruct()
|
||||
{
|
||||
field = NULL;
|
||||
field = nullptr;
|
||||
floatValue = 0;
|
||||
shortValue = 0;
|
||||
gameHasFinished = false;
|
||||
ownId = 0;
|
||||
curSearchDepth = 0;
|
||||
depthOfFullTree = 0;
|
||||
idPossibilities = NULL;
|
||||
oldStates = NULL;
|
||||
possibilities = NULL;
|
||||
parent = NULL;
|
||||
idPossibilities = nullptr;
|
||||
oldStates = nullptr;
|
||||
possibilities = nullptr;
|
||||
parent = nullptr;
|
||||
|
||||
}
|
||||
|
||||
|
@ -849,7 +849,7 @@ unsigned int *perfectKI::threadVarsStruct::getPossSettingPhase(unsigned int *num
|
|||
}
|
||||
|
||||
// possibility code is simple
|
||||
if (pPossibilities != NULL) *pPossibilities = NULL;
|
||||
if (pPossibilities != nullptr) *pPossibilities = nullptr;
|
||||
|
||||
return idPossibility;
|
||||
}
|
||||
|
@ -908,7 +908,7 @@ unsigned int *perfectKI::threadVarsStruct::getPossNormalMove(unsigned int *numPo
|
|||
}
|
||||
|
||||
// pass possibilities
|
||||
if (pPossibilities != NULL) *pPossibilities = (void *)possibility;
|
||||
if (pPossibilities != nullptr) *pPossibilities = (void *)possibility;
|
||||
|
||||
return idPossibility;
|
||||
}
|
||||
|
@ -935,7 +935,7 @@ unsigned int *perfectKI::threadVarsStruct::getPossStoneRemove(unsigned int *numP
|
|||
}
|
||||
|
||||
// possibility code is simple
|
||||
if (pPossibilities != NULL) *pPossibilities = NULL;
|
||||
if (pPossibilities != nullptr) *pPossibilities = nullptr;
|
||||
|
||||
return idPossibility;
|
||||
}
|
||||
|
@ -1828,7 +1828,7 @@ void perfectKI::getField(unsigned int layerNum, unsigned int stateNumber, fieldS
|
|||
|
||||
// copy content of fieldStruct
|
||||
threadVars[0].field->copyField(field);
|
||||
if (gameHasFinished != NULL) *gameHasFinished = threadVars[0].gameHasFinished;
|
||||
if (gameHasFinished != nullptr) *gameHasFinished = threadVars[0].gameHasFinished;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
randomKI::randomKI()
|
||||
{
|
||||
// Init
|
||||
srand((unsigned)time(NULL));
|
||||
srand((unsigned)time(nullptr));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
|
@ -30,12 +30,12 @@ threadManagerClass::threadManagerClass()
|
|||
numThreadsPassedBarrier = 0;
|
||||
|
||||
InitializeCriticalSection(&csBarrier);
|
||||
hEventBarrierPassedByEveryBody = CreateEvent(NULL, true, false, NULL);
|
||||
hEventBarrierPassedByEveryBody = CreateEvent(nullptr, true, false, nullptr);
|
||||
|
||||
for (curThreadNo = 0; curThreadNo < numThreads; curThreadNo++) {
|
||||
hThread[curThreadNo] = NULL;
|
||||
hThread[curThreadNo] = nullptr;
|
||||
threadId[curThreadNo] = 0;
|
||||
hBarrier[curThreadNo] = CreateEvent(NULL, false, false, NULL);
|
||||
hBarrier[curThreadNo] = CreateEvent(nullptr, false, false, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,9 +55,9 @@ threadManagerClass::~threadManagerClass()
|
|||
DeleteCriticalSection(&csBarrier);
|
||||
CloseHandle(hEventBarrierPassedByEveryBody);
|
||||
|
||||
if (hBarrier != NULL) delete[] hBarrier; hBarrier = NULL;
|
||||
if (hThread != NULL) delete[] hThread; hThread = NULL;
|
||||
if (threadId != NULL) delete[] threadId; threadId = NULL;
|
||||
if (hBarrier != nullptr) delete[] hBarrier; hBarrier = nullptr;
|
||||
if (hThread != nullptr) delete[] hThread; hThread = nullptr;
|
||||
if (threadId != nullptr) delete[] threadId; threadId = nullptr;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -129,7 +129,7 @@ bool threadManagerClass::setNumThreads(unsigned int newNumThreads)
|
|||
}
|
||||
numThreads = newNumThreads;
|
||||
for (unsigned int curThreadNo = 0; curThreadNo < numThreads; curThreadNo++) {
|
||||
hBarrier[curThreadNo] = CreateEvent(NULL, false, false, NULL);
|
||||
hBarrier[curThreadNo] = CreateEvent(nullptr, false, false, nullptr);
|
||||
}
|
||||
LeaveCriticalSection(&csBarrier);
|
||||
return true;
|
||||
|
@ -215,7 +215,7 @@ unsigned int threadManagerClass::executeInParallel(DWORD threadProc(void *pPara
|
|||
SIZE_T dwStackSize = 0;
|
||||
|
||||
// parameters ok?
|
||||
if (pParameter == NULL) return TM_RETURN_VALUE_INVALID_PARAM;
|
||||
if (pParameter == nullptr) return TM_RETURN_VALUE_INVALID_PARAM;
|
||||
|
||||
// globals
|
||||
termineAllThreads = false;
|
||||
|
@ -223,13 +223,13 @@ unsigned int threadManagerClass::executeInParallel(DWORD threadProc(void *pPara
|
|||
// create threads
|
||||
for (curThreadNo = 0; curThreadNo < numThreads; curThreadNo++) {
|
||||
|
||||
hThread[curThreadNo] = CreateThread(NULL, dwStackSize, (LPTHREAD_START_ROUTINE)threadProc, (void *)(((char *)pParameter) + curThreadNo * parameterStructSize), CREATE_SUSPENDED, &threadId[curThreadNo]);
|
||||
hThread[curThreadNo] = CreateThread(nullptr, dwStackSize, (LPTHREAD_START_ROUTINE)threadProc, (void *)(((char *)pParameter) + curThreadNo * parameterStructSize), CREATE_SUSPENDED, &threadId[curThreadNo]);
|
||||
SetThreadPriority(hThread[curThreadNo], THREAD_PRIORITY_BELOW_NORMAL);
|
||||
|
||||
if (hThread[curThreadNo] == NULL) {
|
||||
if (hThread[curThreadNo] == nullptr) {
|
||||
for (curThreadNo; curThreadNo > 0; curThreadNo--) {
|
||||
CloseHandle(hThread[curThreadNo - 1]);
|
||||
hThread[curThreadNo - 1] = NULL;
|
||||
hThread[curThreadNo - 1] = nullptr;
|
||||
}
|
||||
return TM_RETURN_VALUE_UNEXPECTED_ERROR;
|
||||
}
|
||||
|
@ -246,7 +246,7 @@ unsigned int threadManagerClass::executeInParallel(DWORD threadProc(void *pPara
|
|||
// Close all thread handles upon completion.
|
||||
for (curThreadNo = 0; curThreadNo < numThreads; curThreadNo++) {
|
||||
CloseHandle(hThread[curThreadNo]);
|
||||
hThread[curThreadNo] = NULL;
|
||||
hThread[curThreadNo] = nullptr;
|
||||
threadId[curThreadNo] = 0;
|
||||
}
|
||||
|
||||
|
@ -274,7 +274,7 @@ unsigned int threadManagerClass::executeParallelLoop(DWORD threadProc(void *p
|
|||
{
|
||||
// parameters ok?
|
||||
if (executionCancelled == true) return TM_RETURN_VALUE_EXECUTION_CANCELLED;
|
||||
if (pParameter == NULL) return TM_RETURN_VALUE_INVALID_PARAM;
|
||||
if (pParameter == nullptr) return TM_RETURN_VALUE_INVALID_PARAM;
|
||||
if (scheduleType >= TM_SCHEDULE_NUM_TYPES) return TM_RETURN_VALUE_INVALID_PARAM;
|
||||
if (inkrement == 0) return TM_RETURN_VALUE_INVALID_PARAM;
|
||||
if (abs(finalValue - initialValue) == abs(inkrement)) return TM_RETURN_VALUE_INVALID_PARAM;
|
||||
|
@ -292,7 +292,7 @@ unsigned int threadManagerClass::executeParallelLoop(DWORD threadProc(void *p
|
|||
// create threads
|
||||
for (curThreadNo = 0; curThreadNo < numThreads; curThreadNo++) {
|
||||
|
||||
forLoopParameters[curThreadNo].pParameter = (pParameter != NULL ? (void *)(((char *)pParameter) + curThreadNo * parameterStructSize) : NULL);
|
||||
forLoopParameters[curThreadNo].pParameter = (pParameter != nullptr ? (void *)(((char *)pParameter) + curThreadNo * parameterStructSize) : nullptr);
|
||||
forLoopParameters[curThreadNo].threadManager = this;
|
||||
forLoopParameters[curThreadNo].threadProc = threadProc;
|
||||
forLoopParameters[curThreadNo].inkrement = inkrement;
|
||||
|
@ -320,12 +320,12 @@ unsigned int threadManagerClass::executeParallelLoop(DWORD threadProc(void *p
|
|||
}
|
||||
|
||||
// create suspended thread
|
||||
hThread[curThreadNo] = CreateThread(NULL, dwStackSize, threadForLoop, (LPVOID)(&forLoopParameters[curThreadNo]), CREATE_SUSPENDED, &threadId[curThreadNo]);
|
||||
hThread[curThreadNo] = CreateThread(nullptr, dwStackSize, threadForLoop, (LPVOID)(&forLoopParameters[curThreadNo]), CREATE_SUSPENDED, &threadId[curThreadNo]);
|
||||
SetThreadPriority(hThread[curThreadNo], THREAD_PRIORITY_BELOW_NORMAL);
|
||||
if (hThread[curThreadNo] == NULL) {
|
||||
if (hThread[curThreadNo] == nullptr) {
|
||||
for (curThreadNo; curThreadNo > 0; curThreadNo--) {
|
||||
CloseHandle(hThread[curThreadNo - 1]);
|
||||
hThread[curThreadNo - 1] = NULL;
|
||||
hThread[curThreadNo - 1] = nullptr;
|
||||
}
|
||||
return TM_RETURN_VALUE_UNEXPECTED_ERROR;
|
||||
}
|
||||
|
@ -344,7 +344,7 @@ unsigned int threadManagerClass::executeParallelLoop(DWORD threadProc(void *p
|
|||
// Close all thread handles upon completion.
|
||||
for (curThreadNo = 0; curThreadNo < numThreads; curThreadNo++) {
|
||||
CloseHandle(hThread[curThreadNo]);
|
||||
hThread[curThreadNo] = NULL;
|
||||
hThread[curThreadNo] = nullptr;
|
||||
threadId[curThreadNo] = 0;
|
||||
}
|
||||
delete[] forLoopParameters;
|
||||
|
|
Loading…
Reference in New Issue