perfect: Fix or avoid build warnings

This commit is contained in:
Calcitem 2021-01-22 21:48:01 +08:00
parent 230aad1118
commit 03aaf2c082
8 changed files with 76 additions and 62 deletions

View File

@ -103,7 +103,7 @@ bool BufferedFile::flushBuffers()
// Name: writeDataToFile() // Name: writeDataToFile()
// Desc: Writes 'sizeInBytes'-bytes to the position 'offset' to the file. // Desc: Writes 'sizeInBytes'-bytes to the position 'offset' to the file.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void BufferedFile::writeDataToFile(HANDLE hFile, long long offset, unsigned int sizeInBytes, void *pData) void BufferedFile::writeDataToFile(HANDLE fd, long long offset, unsigned int sizeInBytes, void *pData)
{ {
DWORD dwBytesWritten; DWORD dwBytesWritten;
LARGE_INTEGER liDistanceToMove; LARGE_INTEGER liDistanceToMove;
@ -113,12 +113,12 @@ void BufferedFile::writeDataToFile(HANDLE hFile, long long offset, unsigned int
EnterCriticalSection(&csIO); EnterCriticalSection(&csIO);
while (!SetFilePointerEx(hFile, liDistanceToMove, nullptr, FILE_BEGIN)) while (!SetFilePointerEx(fd, liDistanceToMove, nullptr, FILE_BEGIN))
cout << endl cout << endl
<< "SetFilePointerEx failed!"; << "SetFilePointerEx failed!";
while (restingBytes > 0) { while (restingBytes > 0) {
if (WriteFile(hFile, pData, sizeInBytes, &dwBytesWritten, nullptr) == TRUE) { if (WriteFile(fd, pData, sizeInBytes, &dwBytesWritten, nullptr) == TRUE) {
restingBytes -= dwBytesWritten; restingBytes -= dwBytesWritten;
pData = (void *)(((unsigned char *)pData) + dwBytesWritten); pData = (void *)(((unsigned char *)pData) + dwBytesWritten);
if (restingBytes > 0) if (restingBytes > 0)
@ -137,7 +137,7 @@ void BufferedFile::writeDataToFile(HANDLE hFile, long long offset, unsigned int
// Name: readDataFromFile() // Name: readDataFromFile()
// Desc: Reads 'sizeInBytes'-bytes from the position 'offset' of the file. // Desc: Reads 'sizeInBytes'-bytes from the position 'offset' of the file.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void BufferedFile::readDataFromFile(HANDLE hFile, long long offset, unsigned int sizeInBytes, void *pData) void BufferedFile::readDataFromFile(HANDLE fd, long long offset, unsigned int sizeInBytes, void *pData)
{ {
DWORD dwBytesRead; DWORD dwBytesRead;
LARGE_INTEGER liDistanceToMove; LARGE_INTEGER liDistanceToMove;
@ -147,12 +147,12 @@ void BufferedFile::readDataFromFile(HANDLE hFile, long long offset, unsigned int
EnterCriticalSection(&csIO); EnterCriticalSection(&csIO);
while (!SetFilePointerEx(hFile, liDistanceToMove, nullptr, FILE_BEGIN)) while (!SetFilePointerEx(fd, liDistanceToMove, nullptr, FILE_BEGIN))
cout << endl cout << endl
<< "SetFilePointerEx failed!"; << "SetFilePointerEx failed!";
while (restingBytes > 0) { while (restingBytes > 0) {
if (ReadFile(hFile, pData, sizeInBytes, &dwBytesRead, nullptr) == TRUE) { if (ReadFile(fd, pData, sizeInBytes, &dwBytesRead, nullptr) == TRUE) {
restingBytes -= dwBytesRead; restingBytes -= dwBytesRead;
pData = (void *)(((unsigned char *)pData) + dwBytesRead); pData = (void *)(((unsigned char *)pData) + dwBytesRead);
if (restingBytes > 0) if (restingBytes > 0)

View File

@ -54,7 +54,7 @@ CyclicArray::~CyclicArray()
// Name: writeDataToFile() // Name: writeDataToFile()
// Desc: Writes 'sizeInBytes'-bytes to the position 'offset' to the file. // 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 fd, long long offset, unsigned int sizeInBytes, void *pData)
{ {
DWORD dwBytesWritten; DWORD dwBytesWritten;
LARGE_INTEGER liDistanceToMove; LARGE_INTEGER liDistanceToMove;
@ -62,12 +62,12 @@ void CyclicArray::writeDataToFile(HANDLE hFile, long long offset, unsigned int s
liDistanceToMove.QuadPart = offset; liDistanceToMove.QuadPart = offset;
while (!SetFilePointerEx(hFile, liDistanceToMove, nullptr, FILE_BEGIN)) while (!SetFilePointerEx(fd, liDistanceToMove, nullptr, FILE_BEGIN))
cout << endl cout << endl
<< "SetFilePointerEx failed!"; << "SetFilePointerEx failed!";
while (restingBytes > 0) { while (restingBytes > 0) {
if (WriteFile(hFile, pData, sizeInBytes, &dwBytesWritten, nullptr) == TRUE) { if (WriteFile(fd, pData, sizeInBytes, &dwBytesWritten, nullptr) == TRUE) {
restingBytes -= dwBytesWritten; restingBytes -= dwBytesWritten;
pData = (void *)(((unsigned char *)pData) + dwBytesWritten); pData = (void *)(((unsigned char *)pData) + dwBytesWritten);
if (restingBytes > 0) if (restingBytes > 0)
@ -84,7 +84,7 @@ void CyclicArray::writeDataToFile(HANDLE hFile, long long offset, unsigned int s
// Name: readDataFromFile() // Name: readDataFromFile()
// Desc: Reads 'sizeInBytes'-bytes from the position 'offset' of the file. // 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 fd, long long offset, unsigned int sizeInBytes, void *pData)
{ {
DWORD dwBytesRead; DWORD dwBytesRead;
LARGE_INTEGER liDistanceToMove; LARGE_INTEGER liDistanceToMove;
@ -92,12 +92,12 @@ void CyclicArray::readDataFromFile(HANDLE hFile, long long offset, unsigned int
liDistanceToMove.QuadPart = offset; liDistanceToMove.QuadPart = offset;
while (!SetFilePointerEx(hFile, liDistanceToMove, nullptr, FILE_BEGIN)) while (!SetFilePointerEx(fd, liDistanceToMove, nullptr, FILE_BEGIN))
cout << endl cout << endl
<< "SetFilePointerEx failed!"; << "SetFilePointerEx failed!";
while (restingBytes > 0) { while (restingBytes > 0) {
if (ReadFile(hFile, pData, sizeInBytes, &dwBytesRead, nullptr) == TRUE) { if (ReadFile(fd, pData, sizeInBytes, &dwBytesRead, nullptr) == TRUE) {
restingBytes -= dwBytesRead; restingBytes -= dwBytesRead;
pData = (void *)(((unsigned char *)pData) + dwBytesRead); pData = (void *)(((unsigned char *)pData) + dwBytesRead);
if (restingBytes > 0) if (restingBytes > 0)

View File

@ -131,11 +131,11 @@ void *MiniMax::getBestChoice(unsigned int tilLevel, unsigned int *choice, unsign
// Name: calculateDatabase() // Name: calculateDatabase()
// Desc: Calculates the database, which must be already open. // Desc: Calculates the database, which must be already open.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void MiniMax::calculateDatabase(unsigned int maxDepthOfTree, bool onlyPrepareLayer) void MiniMax::calculateDatabase(unsigned int maxDepthOfTree, bool onlyPrepLayer)
{ {
// locals // locals
bool abortCalculation = false; bool abortCalculation = false;
this->onlyPrepareLayer = onlyPrepareLayer; this->onlyPrepareLayer = onlyPrepLayer;
lastCalculatedLayer.clear(); lastCalculatedLayer.clear();
PRINT(1, this, "*************************"); PRINT(1, this, "*************************");
@ -174,7 +174,7 @@ void MiniMax::calculateDatabase(unsigned int maxDepthOfTree, bool onlyPrepareLay
unloadAllPlyInfos(); unloadAllPlyInfos();
// don't save layer and header when only preparing layers // don't save layer and header when only preparing layers
if (onlyPrepareLayer) if (onlyPrepLayer)
return; return;
if (abortCalculation) if (abortCalculation)
break; break;
@ -185,7 +185,7 @@ void MiniMax::calculateDatabase(unsigned int maxDepthOfTree, bool onlyPrepareLay
} }
// don't save layer and header when only preparing layers or when // don't save layer and header when only preparing layers or when
if (onlyPrepareLayer) if (onlyPrepLayer)
return; return;
if (!abortCalculation) { if (!abortCalculation) {
@ -220,15 +220,15 @@ void MiniMax::calculateDatabase(unsigned int maxDepthOfTree, bool onlyPrepareLay
bool MiniMax::calcLayer(unsigned int layerNumber) bool MiniMax::calcLayer(unsigned int layerNumber)
{ {
// locals // locals
vector<unsigned int> layersToCalculate; vector<unsigned int> layersToCalc;
// moves can be done reverse, leading to too depth searching trees // moves can be done reverse, leading to too depth searching trees
if (shallRetroAnalysisBeUsed(layerNumber)) { if (shallRetroAnalysisBeUsed(layerNumber)) {
// calc values for all states of layer // calc values for all states of layer
layersToCalculate.push_back(layerNumber); layersToCalc.push_back(layerNumber);
if (layerNumber != layerStats[layerNumber].partnerLayer) if (layerNumber != layerStats[layerNumber].partnerLayer)
layersToCalculate.push_back(layerStats[layerNumber].partnerLayer); layersToCalc.push_back(layerStats[layerNumber].partnerLayer);
if (!calcKnotValuesByRetroAnalysis(layersToCalculate)) if (!calcKnotValuesByRetroAnalysis(layersToCalc))
return false; return false;
// save partner layer // save partner layer

View File

@ -24,6 +24,10 @@
#include "threadManager.h" #include "threadManager.h"
#include "bufferedFile.h" #include "bufferedFile.h"
#pragma warning(disable: 4100)
#pragma warning(disable: 4238)
#pragma warning(disable: 4244)
#pragma intrinsic(_rotl8, _rotr8) // for shifting bits #pragma intrinsic(_rotl8, _rotr8) // for shifting bits
using namespace std; // use standard library namespace using namespace std; // use standard library namespace
@ -93,6 +97,7 @@ database: The database contains the arrays with the short knot values and the
(p) = nullptr; \ (p) = nullptr; \
} \ } \
} }
#define SAFE_DELETE_ARRAY(p) \ #define SAFE_DELETE_ARRAY(p) \
{ \ { \
if (p) \ if (p) \
@ -415,6 +420,7 @@ public:
while (true) while (true)
; ;
}; };
virtual void printMoveInformation(unsigned int threadNo, unsigned int idPossibility, void *pPossibilities) virtual void printMoveInformation(unsigned int threadNo, unsigned int idPossibility, void *pPossibilities)
{ {
while (true) while (true)

View File

@ -8,6 +8,9 @@
#include "miniMax.h" #include "miniMax.h"
#pragma warning(disable: 4127)
#pragma warning(disable: 4706)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Name: ~MiniMax() // Name: ~MiniMax()
// Desc: MiniMax class destructor // Desc: MiniMax class destructor
@ -451,7 +454,7 @@ void MiniMax::readKnotValueFromDatabase(unsigned int layerNumber, unsigned int s
// locals // locals
TwoBit databaseByte; TwoBit databaseByte;
long long bytesAllocated; long long bytesAllocated;
TwoBit defValue = SKV_WHOLE_BYTE_IS_INVALID; //TwoBit defValue = SKV_WHOLE_BYTE_IS_INVALID;
LayerStats *myLss = &layerStats[layerNumber]; LayerStats *myLss = &layerStats[layerNumber];
// valid state and layer number ? // valid state and layer number ?
@ -579,7 +582,7 @@ void MiniMax::saveKnotValueInDatabase(unsigned int layerNumber, unsigned int sta
{ {
// locals // locals
long long bytesAllocated; long long bytesAllocated;
TwoBit defValue = SKV_WHOLE_BYTE_IS_INVALID; //TwoBit defValue = SKV_WHOLE_BYTE_IS_INVALID;
LayerStats *myLss = &layerStats[layerNumber]; LayerStats *myLss = &layerStats[layerNumber];
// valid state and layer number ? // valid state and layer number ?

View File

@ -17,7 +17,7 @@ s\*********************************************************************/
// Each time the short knot value of a game state has been determined, the state will be added to 'statesToProcess'. // Each time the short knot value of a game state has been determined, the state will be added to 'statesToProcess'.
// This list is like a queue of states, which still has to be processed. // This list is like a queue of states, which still has to be processed.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
bool MiniMax::calcKnotValuesByRetroAnalysis(vector<unsigned int> &layersToCalculate) bool MiniMax::calcKnotValuesByRetroAnalysis(vector<unsigned int> &layersToCalc)
{ {
// locals // locals
bool abortCalculation = false; bool abortCalculation = false;
@ -35,29 +35,29 @@ bool MiniMax::calcKnotValuesByRetroAnalysis(vector<unsigned int> &layersToCalcul
retroVars.thread[threadNo].numStatesToProcess = 0; retroVars.thread[threadNo].numStatesToProcess = 0;
retroVars.thread[threadNo].threadNo = threadNo; retroVars.thread[threadNo].threadNo = threadNo;
} }
retroVars.countArrays.resize(layersToCalculate.size(), nullptr); retroVars.countArrays.resize(layersToCalc.size(), nullptr);
retroVars.layerInitialized.resize(skvfHeader.numLayers, false); retroVars.layerInitialized.resize(skvfHeader.numLayers, false);
retroVars.layersToCalculate = layersToCalculate; retroVars.layersToCalculate = layersToCalc;
retroVars.pMiniMax = this; retroVars.pMiniMax = this;
for (retroVars.totalNumKnots = 0, retroVars.numKnotsToCalc = 0, curLayer = 0; curLayer < layersToCalculate.size(); curLayer++) { for (retroVars.totalNumKnots = 0, retroVars.numKnotsToCalc = 0, curLayer = 0; curLayer < layersToCalc.size(); curLayer++) {
retroVars.numKnotsToCalc += layerStats[layersToCalculate[curLayer]].knotsInLayer; retroVars.numKnotsToCalc += layerStats[layersToCalc[curLayer]].knotsInLayer;
retroVars.totalNumKnots += layerStats[layersToCalculate[curLayer]].knotsInLayer; retroVars.totalNumKnots += layerStats[layersToCalc[curLayer]].knotsInLayer;
retroVars.layerInitialized[layersToCalculate[curLayer]] = true; retroVars.layerInitialized[layersToCalc[curLayer]] = true;
for (curSubLayer = 0; curSubLayer < layerStats[layersToCalculate[curLayer]].numSuccLayers; curSubLayer++) { for (curSubLayer = 0; curSubLayer < layerStats[layersToCalc[curLayer]].numSuccLayers; curSubLayer++) {
if (retroVars.layerInitialized[layerStats[layersToCalculate[curLayer]].succLayers[curSubLayer]]) if (retroVars.layerInitialized[layerStats[layersToCalc[curLayer]].succLayers[curSubLayer]])
continue; continue;
else else
retroVars.layerInitialized[layerStats[layersToCalculate[curLayer]].succLayers[curSubLayer]] = true; retroVars.layerInitialized[layerStats[layersToCalc[curLayer]].succLayers[curSubLayer]] = true;
retroVars.totalNumKnots += layerStats[layerStats[layersToCalculate[curLayer]].succLayers[curSubLayer]].knotsInLayer; retroVars.totalNumKnots += layerStats[layerStats[layersToCalc[curLayer]].succLayers[curSubLayer]].knotsInLayer;
} }
} }
retroVars.layerInitialized.assign(skvfHeader.numLayers, false); retroVars.layerInitialized.assign(skvfHeader.numLayers, false);
// output & filenames // output & filenames
for (curLayer = 0; curLayer < layersToCalculate.size(); curLayer++) for (curLayer = 0; curLayer < layersToCalc.size(); curLayer++)
ssLayers << " " << layersToCalculate[curLayer]; ssLayers << " " << layersToCalc[curLayer];
PRINT(0, this, "*** Calculate layers" << ssLayers.str() << " by retro analysis ***"); PRINT(0, this, "*** Calculate layers" << ssLayers.str() << " by retro analysis ***");
// initialization // initialization
@ -87,8 +87,8 @@ bool MiniMax::calcKnotValuesByRetroAnalysis(vector<unsigned int> &layersToCalcul
// show output // show output
PRINT(2, this, " Bytes in memory: " << memoryUsed2); PRINT(2, this, " Bytes in memory: " << memoryUsed2);
for (curLayer = 0; curLayer < layersToCalculate.size(); curLayer++) { for (curLayer = 0; curLayer < layersToCalc.size(); curLayer++) {
showLayerStats(layersToCalculate[curLayer]); showLayerStats(layersToCalc[curLayer]);
} }
PRINT(2, this, ""); PRINT(2, this, "");
@ -100,10 +100,10 @@ freeMem:
} }
} }
for (curLayer = 0; curLayer < layersToCalculate.size(); curLayer++) { for (curLayer = 0; curLayer < layersToCalc.size(); curLayer++) {
if (retroVars.countArrays[curLayer] != nullptr) { if (retroVars.countArrays[curLayer] != nullptr) {
memoryUsed2 -= layerStats[layersToCalculate[curLayer]].knotsInLayer * sizeof(CountArrayVarType); memoryUsed2 -= layerStats[layersToCalc[curLayer]].knotsInLayer * sizeof(CountArrayVarType);
arrayInfos.removeArray(layersToCalculate[curLayer], ArrayInfo::arrayType_countArray, layerStats[layersToCalculate[curLayer]].knotsInLayer * sizeof(CountArrayVarType), 0); arrayInfos.removeArray(layersToCalc[curLayer], ArrayInfo::arrayType_countArray, layerStats[layersToCalc[curLayer]].knotsInLayer * sizeof(CountArrayVarType), 0);
} }
SAFE_DELETE_ARRAY(retroVars.countArrays[curLayer]); SAFE_DELETE_ARRAY(retroVars.countArrays[curLayer]);
} }

View File

@ -319,7 +319,7 @@ bool MiniMax::testState(unsigned int layerNumber, unsigned int stateNumber)
{ {
// locals // locals
TestLayersVars tlVars; TestLayersVars tlVars;
bool result; bool result = false;
// prepare parameters for multithreading // prepare parameters for multithreading
tlVars.curThreadNo = 0; tlVars.curThreadNo = 0;
@ -487,7 +487,7 @@ DWORD MiniMax::testSetSituationThreadProc(void *pParameter, int index)
//errorInDatabase: //errorInDatabase:
// terminate all threads // terminate all threads
return TM_RETURN_VALUE_TERMINATE_ALL_THREADS; //return TM_RETURN_VALUE_TERMINATE_ALL_THREADS;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View File

@ -220,26 +220,27 @@ PerfectAI::PerfectAI(const char *directory)
ssPreCalcVarsFilePath << "preCalculatedVars.dat"; ssPreCalcVarsFilePath << "preCalculatedVars.dat";
hFilePreCalcVars = CreateFileA(ssPreCalcVarsFilePath.str().c_str(), GENERIC_READ /*| GENERIC_WRITE*/, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); 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(PreCalcedVarsFileHeader), &dwBytesRead, nullptr); if (!ReadFile(hFilePreCalcVars, &preCalcVarsHeader, sizeof(PreCalcedVarsFileHeader), &dwBytesRead, nullptr))
return;
// vars already stored in file? // vars already stored in file?
if (dwBytesRead) { if (dwBytesRead) {
// Read from file // Read from file
ReadFile(hFilePreCalcVars, layer, sizeof(Layer) * NUM_LAYERS, &dwBytesRead, nullptr); if (!ReadFile(hFilePreCalcVars, layer, sizeof(Layer) * NUM_LAYERS, &dwBytesRead, nullptr)) return;
ReadFile(hFilePreCalcVars, layerIndex, sizeof(unsigned int) * 2 * NUM_STONES_PER_PLAYER_PLUS_ONE * NUM_STONES_PER_PLAYER_PLUS_ONE, &dwBytesRead, nullptr); if (!ReadFile(hFilePreCalcVars, layerIndex, sizeof(unsigned int) * 2 * NUM_STONES_PER_PLAYER_PLUS_ONE * NUM_STONES_PER_PLAYER_PLUS_ONE, &dwBytesRead, nullptr)) return;
ReadFile(hFilePreCalcVars, anzahlStellungenAB, sizeof(unsigned int) * NUM_STONES_PER_PLAYER_PLUS_ONE * NUM_STONES_PER_PLAYER_PLUS_ONE, &dwBytesRead, nullptr); if (!ReadFile(hFilePreCalcVars, anzahlStellungenAB, sizeof(unsigned int) * NUM_STONES_PER_PLAYER_PLUS_ONE * NUM_STONES_PER_PLAYER_PLUS_ONE, &dwBytesRead, nullptr)) return;
ReadFile(hFilePreCalcVars, anzahlStellungenCD, sizeof(unsigned int) * NUM_STONES_PER_PLAYER_PLUS_ONE * NUM_STONES_PER_PLAYER_PLUS_ONE, &dwBytesRead, nullptr); if (!ReadFile(hFilePreCalcVars, anzahlStellungenCD, sizeof(unsigned int) * NUM_STONES_PER_PLAYER_PLUS_ONE * NUM_STONES_PER_PLAYER_PLUS_ONE, &dwBytesRead, nullptr)) return;
ReadFile(hFilePreCalcVars, indexAB, sizeof(unsigned int) * MAX_ANZ_STELLUNGEN_A * MAX_ANZ_STELLUNGEN_B, &dwBytesRead, nullptr); if (!ReadFile(hFilePreCalcVars, indexAB, sizeof(unsigned int) * MAX_ANZ_STELLUNGEN_A * MAX_ANZ_STELLUNGEN_B, &dwBytesRead, nullptr)) return;
ReadFile(hFilePreCalcVars, indexCD, sizeof(unsigned int) * MAX_ANZ_STELLUNGEN_C * MAX_ANZ_STELLUNGEN_D, &dwBytesRead, nullptr); if (!ReadFile(hFilePreCalcVars, indexCD, sizeof(unsigned int) * MAX_ANZ_STELLUNGEN_C * MAX_ANZ_STELLUNGEN_D, &dwBytesRead, nullptr)) return;
ReadFile(hFilePreCalcVars, symmetryOperationCD, sizeof(unsigned char) * MAX_ANZ_STELLUNGEN_C * MAX_ANZ_STELLUNGEN_D, &dwBytesRead, nullptr); if (!ReadFile(hFilePreCalcVars, symmetryOperationCD, sizeof(unsigned char) * MAX_ANZ_STELLUNGEN_C * MAX_ANZ_STELLUNGEN_D, &dwBytesRead, nullptr)) return;
ReadFile(hFilePreCalcVars, powerOfThree, sizeof(unsigned int) * (numSquaresGroupC + numSquaresGroupD), &dwBytesRead, nullptr); if (!ReadFile(hFilePreCalcVars, powerOfThree, sizeof(unsigned int) * (numSquaresGroupC + numSquaresGroupD), &dwBytesRead, nullptr)) return;
ReadFile(hFilePreCalcVars, symmetryOperationTable, sizeof(unsigned int) * fieldStruct::size * NUM_SYM_OPERATIONS, &dwBytesRead, nullptr); if (!ReadFile(hFilePreCalcVars, symmetryOperationTable, sizeof(unsigned int) * fieldStruct::size * NUM_SYM_OPERATIONS, &dwBytesRead, nullptr)) return;
ReadFile(hFilePreCalcVars, reverseSymOperation, sizeof(unsigned int) * NUM_SYM_OPERATIONS, &dwBytesRead, nullptr); if (!ReadFile(hFilePreCalcVars, reverseSymOperation, sizeof(unsigned int) * NUM_SYM_OPERATIONS, &dwBytesRead, nullptr)) return;
ReadFile(hFilePreCalcVars, concSymOperation, sizeof(unsigned int) * NUM_SYM_OPERATIONS * NUM_SYM_OPERATIONS, &dwBytesRead, nullptr); if (!ReadFile(hFilePreCalcVars, concSymOperation, sizeof(unsigned int) * NUM_SYM_OPERATIONS * NUM_SYM_OPERATIONS, &dwBytesRead, nullptr)) return;
ReadFile(hFilePreCalcVars, mOverN, sizeof(unsigned int) * (fieldStruct::size + 1) * (fieldStruct::size + 1), &dwBytesRead, nullptr); if (!ReadFile(hFilePreCalcVars, mOverN, sizeof(unsigned int) * (fieldStruct::size + 1) * (fieldStruct::size + 1), &dwBytesRead, nullptr)) return;
ReadFile(hFilePreCalcVars, valueOfMove, sizeof(unsigned char) * fieldStruct::size * fieldStruct::size, &dwBytesRead, nullptr); if (!ReadFile(hFilePreCalcVars, valueOfMove, sizeof(unsigned char) * fieldStruct::size * fieldStruct::size, &dwBytesRead, nullptr)) return;
ReadFile(hFilePreCalcVars, plyInfoForOutput, sizeof(PlyInfoVarType) * fieldStruct::size * fieldStruct::size, &dwBytesRead, nullptr); if (!ReadFile(hFilePreCalcVars, plyInfoForOutput, sizeof(PlyInfoVarType) * fieldStruct::size * fieldStruct::size, &dwBytesRead, nullptr)) return;
ReadFile(hFilePreCalcVars, incidencesValuesSubMoves, sizeof(unsigned int) * 4 * fieldStruct::size * fieldStruct::size, &dwBytesRead, nullptr); if (!ReadFile(hFilePreCalcVars, incidencesValuesSubMoves, sizeof(unsigned int) * 4 * fieldStruct::size * fieldStruct::size, &dwBytesRead, nullptr)) return;
// process originalStateAB[][] // process originalStateAB[][]
for (a = 0; a <= NUM_STONES_PER_PLAYER; a++) { for (a = 0; a <= NUM_STONES_PER_PLAYER; a++) {
@ -247,7 +248,7 @@ PerfectAI::PerfectAI(const char *directory)
if (a + b > numSquaresGroupA + numSquaresGroupB) if (a + b > numSquaresGroupA + numSquaresGroupB)
continue; continue;
originalStateAB[a][b] = new unsigned int[anzahlStellungenAB[a][b]]; originalStateAB[a][b] = new unsigned int[anzahlStellungenAB[a][b]];
ReadFile(hFilePreCalcVars, originalStateAB[a][b], sizeof(unsigned int) * anzahlStellungenAB[a][b], &dwBytesRead, nullptr); if (!ReadFile(hFilePreCalcVars, originalStateAB[a][b], sizeof(unsigned int) * anzahlStellungenAB[a][b], &dwBytesRead, nullptr)) return;
} }
} }
@ -257,7 +258,7 @@ PerfectAI::PerfectAI(const char *directory)
if (a + b > numSquaresGroupC + numSquaresGroupD) if (a + b > numSquaresGroupC + numSquaresGroupD)
continue; continue;
originalStateCD[a][b] = new unsigned int[anzahlStellungenCD[a][b]]; originalStateCD[a][b] = new unsigned int[anzahlStellungenCD[a][b]];
ReadFile(hFilePreCalcVars, originalStateCD[a][b], sizeof(unsigned int) * anzahlStellungenCD[a][b], &dwBytesRead, nullptr); if (!ReadFile(hFilePreCalcVars, originalStateCD[a][b], sizeof(unsigned int) * anzahlStellungenCD[a][b], &dwBytesRead, nullptr)) return;
} }
} }
@ -1654,7 +1655,7 @@ bool PerfectAI::setSituation(unsigned int threadNo, unsigned int layerNum, unsig
unsigned int numBlackStones = layer[layerNum].numBlackStones; unsigned int numBlackStones = layer[layerNum].numBlackStones;
unsigned int numberOfMillsCurrentPlayer = 0; unsigned int numberOfMillsCurrentPlayer = 0;
unsigned int numberOfMillsOpponentPlayer = 0; unsigned int numberOfMillsOpponentPlayer = 0;
unsigned int wCD, bCD, wAB, bAB; unsigned int wCD = 0, bCD = 0, wAB = 0, bAB = 0;
unsigned int i; unsigned int i;
bool aStoneCanBeRemovedFromCurPlayer; bool aStoneCanBeRemovedFromCurPlayer;
@ -2526,7 +2527,7 @@ bool PerfectAI::checkGetPossThanGetPred()
void *pBackup; void *pBackup;
RetroAnalysisPredVars predVars[MAX_NUM_PREDECESSORS]; RetroAnalysisPredVars predVars[MAX_NUM_PREDECESSORS];
unsigned int threadNo = 0; unsigned int threadNo = 0;
ThreadVars *tv = &threadVars[threadNo]; //ThreadVars *tv = &threadVars[threadNo];
// test if each successor from getPossibilities() leads to the original state using getPredecessors() // test if each successor from getPossibilities() leads to the original state using getPredecessors()
for (layerNum = 0; layerNum < NUM_LAYERS; layerNum++) { for (layerNum = 0; layerNum < NUM_LAYERS; layerNum++) {
@ -2572,6 +2573,7 @@ bool PerfectAI::checkGetPossThanGetPred()
<< "ERROR: STATE " << stateNum << " NOT FOUND IN PREDECESSOR LIST"; << "ERROR: STATE " << stateNum << " NOT FOUND IN PREDECESSOR LIST";
return false; return false;
#if 0
// perform several commands to see in debug mode where the error occurs // perform several commands to see in debug mode where the error occurs
undo(threadNo, idPossibility[i], isOpponentLevel, pBackup, pPossibilities); undo(threadNo, idPossibility[i], isOpponentLevel, pBackup, pPossibilities);
setSituation(threadNo, layerNum, stateNum); setSituation(threadNo, layerNum, stateNum);
@ -2583,6 +2585,7 @@ bool PerfectAI::checkGetPossThanGetPred()
printBoard(threadNo, 0); printBoard(threadNo, 0);
getPredecessors(threadNo, &amountOfPred, predVars); getPredecessors(threadNo, &amountOfPred, predVars);
getPredecessors(threadNo, &amountOfPred, predVars); getPredecessors(threadNo, &amountOfPred, predVars);
#endif
} }
// undo move // undo move
@ -2649,6 +2652,7 @@ bool PerfectAI::checkGetPredThanGetPoss()
<< "ERROR SETTING SITUATION"; << "ERROR SETTING SITUATION";
return false; return false;
#if 0
// perform several commands to see in debug mode where the error occurs // perform several commands to see in debug mode where the error occurs
for (k = 0; k < tv->field->size; k++) for (k = 0; k < tv->field->size; k++)
symField[k] = tv->field->board[k]; symField[k] = tv->field->board[k];
@ -2677,6 +2681,7 @@ bool PerfectAI::checkGetPredThanGetPoss()
cout << " layerNum: " << layerNum << "\tstateNum: " << stateNum << endl; cout << " layerNum: " << layerNum << "\tstateNum: " << stateNum << endl;
printBoard(threadNo, 0); printBoard(threadNo, 0);
getPredecessors(threadNo, &amountOfPred, predVars); getPredecessors(threadNo, &amountOfPred, predVars);
#endif
} }
// regard used symmetry operation // regard used symmetry operation