perfect: Rename minMax functions (2)

This commit is contained in:
Calcitem 2021-01-20 01:16:18 +08:00
parent d9efb9ce67
commit de58c91578
12 changed files with 208 additions and 208 deletions

View File

@ -1,5 +1,5 @@
/*********************************************************************
miniMaxAI.cpp
MiniMaxAI.cpp
Copyright (c) Thomas Weber. All rights reserved.
Copyright (C) 2021 The Sanmill developers (see AUTHORS file)
Licensed under the MIT License.
@ -9,19 +9,19 @@
#include "miniMaxAI.h"
//-----------------------------------------------------------------------------
// Name: miniMaxAI()
// Desc: miniMaxAI class constructor
// Name: MiniMaxAI()
// Desc: MiniMaxAI class constructor
//-----------------------------------------------------------------------------
miniMaxAI::miniMaxAI()
MiniMaxAI::MiniMaxAI()
{
depthOfFullTree = 0;
}
//-----------------------------------------------------------------------------
// Name: ~miniMaxAI()
// Desc: miniMaxAI class destructor
// Name: ~MiniMaxAI()
// Desc: MiniMaxAI class destructor
//-----------------------------------------------------------------------------
miniMaxAI::~miniMaxAI()
MiniMaxAI::~MiniMaxAI()
{
}
@ -29,7 +29,7 @@ miniMaxAI::~miniMaxAI()
// Name: play()
// Desc:
//-----------------------------------------------------------------------------
void miniMaxAI::play(fieldStruct *theField, unsigned int *pushFrom, unsigned int *pushTo)
void MiniMaxAI::play(fieldStruct *theField, unsigned int *pushFrom, unsigned int *pushTo)
{
// globals
field = theField;
@ -49,15 +49,15 @@ void miniMaxAI::play(fieldStruct *theField, unsigned int *pushFrom, unsigned int
}
// Inform user about progress
cout << "miniMaxAI is thinking with a depth of " << searchDepth << " steps!\n\n\n";
cout << "MiniMaxAI is thinking with a depth of " << searchDepth << " steps!\n\n\n";
// reserve memory
possibilities = new possibilityStruct[searchDepth + 1];
oldStates = new backupStruct[searchDepth + 1];
possibilities = new Possibility[searchDepth + 1];
oldStates = new Backup[searchDepth + 1];
idPossibilities = new unsigned int[(searchDepth + 1) * MAX_NUM_POS_MOVES];
// start the miniMax-algorithmn
possibilityStruct *rootPossibilities = (possibilityStruct *)getBestChoice(searchDepth, &bestChoice, MAX_NUM_POS_MOVES);
Possibility *rootPossibilities = (Possibility *)getBestChoice(searchDepth, &bestChoice, MAX_NUM_POS_MOVES);
// decode the best choice
if (field->stoneMustBeRemoved) {
@ -82,7 +82,7 @@ void miniMaxAI::play(fieldStruct *theField, unsigned int *pushFrom, unsigned int
// Name: setSearchDepth()
// Desc:
//-----------------------------------------------------------------------------
void miniMaxAI::setSearchDepth(unsigned int depth)
void MiniMaxAI::setSearchDepth(unsigned int depth)
{
depthOfFullTree = depth;
}
@ -91,7 +91,7 @@ void miniMaxAI::setSearchDepth(unsigned int depth)
// Name: prepareBestChoiceCalculation()
// Desc:
//-----------------------------------------------------------------------------
void miniMaxAI::prepareBestChoiceCalculation()
void MiniMaxAI::prepareBestChoiceCalculation()
{
// calculate current value
currentValue = 0;
@ -102,7 +102,7 @@ void miniMaxAI::prepareBestChoiceCalculation()
// Name: getPossSettingPhase()
// Desc:
//-----------------------------------------------------------------------------
unsigned int *miniMaxAI::getPossSettingPhase(unsigned int *numPossibilities, void **pPossibilities)
unsigned int *MiniMaxAI::getPossSettingPhase(unsigned int *numPossibilities, void **pPossibilities)
{
// locals
unsigned int i;
@ -129,12 +129,12 @@ unsigned int *miniMaxAI::getPossSettingPhase(unsigned int *numPossibilities, voi
// Name: getPossNormalMove()
// Desc:
//-----------------------------------------------------------------------------
unsigned int *miniMaxAI::getPossNormalMove(unsigned int *numPossibilities, void **pPossibilities)
unsigned int *MiniMaxAI::getPossNormalMove(unsigned int *numPossibilities, void **pPossibilities)
{
// locals
unsigned int from, to, dir;
unsigned int *idPossibility = &idPossibilities[curSearchDepth * MAX_NUM_POS_MOVES];
possibilityStruct *possibility = &possibilities[curSearchDepth];
Possibility *possibility = &possibilities[curSearchDepth];
// if he is not allowed to spring
if (field->curPlayer->numStones > 3) {
@ -186,7 +186,7 @@ unsigned int *miniMaxAI::getPossNormalMove(unsigned int *numPossibilities, void
// Name: getPossStoneRemove()
// Desc:
//-----------------------------------------------------------------------------
unsigned int *miniMaxAI::getPossStoneRemove(unsigned int *numPossibilities, void **pPossibilities)
unsigned int *MiniMaxAI::getPossStoneRemove(unsigned int *numPossibilities, void **pPossibilities)
{
// locals
unsigned int i;
@ -213,7 +213,7 @@ unsigned int *miniMaxAI::getPossStoneRemove(unsigned int *numPossibilities, void
// Name: getPossibilities()
// Desc:
//-----------------------------------------------------------------------------
unsigned int *miniMaxAI::getPossibilities(unsigned int threadNo, unsigned int *numPossibilities, bool *opponentsMove, void **pPossibilities)
unsigned int *MiniMaxAI::getPossibilities(unsigned int threadNo, unsigned int *numPossibilities, bool *opponentsMove, void **pPossibilities)
{
// set opponentsMove
*opponentsMove = (field->curPlayer->id == ownId) ? false : true;
@ -234,7 +234,7 @@ unsigned int *miniMaxAI::getPossibilities(unsigned int threadNo, unsigned int *n
// Name: getValueOfSituation()
// Desc:
//-----------------------------------------------------------------------------
void miniMaxAI::getValueOfSituation(unsigned int threadNo, float &floatValue, twoBit &shortValue)
void MiniMaxAI::getValueOfSituation(unsigned int threadNo, float &floatValue, TwoBit &shortValue)
{
floatValue = currentValue;
shortValue = 0;
@ -244,7 +244,7 @@ void miniMaxAI::getValueOfSituation(unsigned int threadNo, float &floatValue, tw
// Name: deletePossibilities()
// Desc:
//-----------------------------------------------------------------------------
void miniMaxAI::deletePossibilities(unsigned int threadNo, void *pPossibilities)
void MiniMaxAI::deletePossibilities(unsigned int threadNo, void *pPossibilities)
{
}
@ -252,10 +252,10 @@ void miniMaxAI::deletePossibilities(unsigned int threadNo, void *pPossibilities)
// Name: undo()
// Desc:
//-----------------------------------------------------------------------------
void miniMaxAI::undo(unsigned int threadNo, unsigned int idPossibility, bool opponentsMove, void *pBackup, void *pPossibilities)
void MiniMaxAI::undo(unsigned int threadNo, unsigned int idPossibility, bool opponentsMove, void *pBackup, void *pPossibilities)
{
// locals
backupStruct *oldState = (backupStruct *)pBackup;
Backup *oldState = (Backup *)pBackup;
// reset old value
currentValue = oldState->value;
@ -287,7 +287,7 @@ void miniMaxAI::undo(unsigned int threadNo, unsigned int idPossibility, bool opp
// Name: setWarning()
// Desc:
//-----------------------------------------------------------------------------
inline void miniMaxAI::setWarning(unsigned int stoneOne, unsigned int stoneTwo, unsigned int stoneThree)
inline void MiniMaxAI::setWarning(unsigned int stoneOne, unsigned int stoneTwo, unsigned int stoneThree)
{
// if all 3 fields are occupied by current player than he closed a mill
if (field->board[stoneOne] == field->curPlayer->id && field->board[stoneTwo] == field->curPlayer->id && field->board[stoneThree] == field->curPlayer->id) {
@ -349,7 +349,7 @@ inline void miniMaxAI::setWarning(unsigned int stoneOne, unsigned int stoneTwo,
// Name: updateWarning()
// Desc:
//-----------------------------------------------------------------------------
inline void miniMaxAI::updateWarning(unsigned int firstStone, unsigned int secondStone)
inline void MiniMaxAI::updateWarning(unsigned int firstStone, unsigned int secondStone)
{
// set warnings
if (firstStone < field->size) setWarning(firstStone, field->neighbour[firstStone][0][0], field->neighbour[firstStone][0][1]);
@ -371,7 +371,7 @@ inline void miniMaxAI::updateWarning(unsigned int firstStone, unsigned int secon
// Name: updatePossibleMoves()
// Desc:
//-----------------------------------------------------------------------------
inline void miniMaxAI::updatePossibleMoves(unsigned int stone, Player *stoneOwner, bool stoneRemoved, unsigned int ignoreStone)
inline void MiniMaxAI::updatePossibleMoves(unsigned int stone, Player *stoneOwner, bool stoneRemoved, unsigned int ignoreStone)
{
// locals
unsigned int neighbor, direction;
@ -416,7 +416,7 @@ inline void miniMaxAI::updatePossibleMoves(unsigned int stone, Player *stoneOwne
// Name: setStone()
// Desc:
//-----------------------------------------------------------------------------
inline void miniMaxAI::setStone(unsigned int to, backupStruct *backup)
inline void MiniMaxAI::setStone(unsigned int to, Backup *backup)
{
// backup
backup->from = field->size;
@ -443,7 +443,7 @@ inline void miniMaxAI::setStone(unsigned int to, backupStruct *backup)
// Name: normalMove()
// Desc:
//-----------------------------------------------------------------------------
inline void miniMaxAI::normalMove(unsigned int from, unsigned int to, backupStruct *backup)
inline void MiniMaxAI::normalMove(unsigned int from, unsigned int to, Backup *backup)
{
// backup
backup->from = from;
@ -467,7 +467,7 @@ inline void miniMaxAI::normalMove(unsigned int from, unsigned int to, backupStru
// Name: removeStone()
// Desc:
//-----------------------------------------------------------------------------
inline void miniMaxAI::removeStone(unsigned int from, backupStruct *backup)
inline void MiniMaxAI::removeStone(unsigned int from, Backup *backup)
{
// backup
backup->from = from;
@ -495,11 +495,11 @@ inline void miniMaxAI::removeStone(unsigned int from, backupStruct *backup)
// Name: move()
// Desc:
//-----------------------------------------------------------------------------
void miniMaxAI::move(unsigned int threadNo, unsigned int idPossibility, bool opponentsMove, void **pBackup, void *pPossibilities)
void MiniMaxAI::move(unsigned int threadNo, unsigned int idPossibility, bool opponentsMove, void **pBackup, void *pPossibilities)
{
// locals
backupStruct *oldState = &oldStates[curSearchDepth];
possibilityStruct *tmpPossibility = (possibilityStruct *)pPossibilities;
Backup *oldState = &oldStates[curSearchDepth];
Possibility *tmpPossibility = (Possibility *)pPossibilities;
Player *tmpPlayer;
unsigned int i;
@ -558,10 +558,10 @@ void miniMaxAI::move(unsigned int threadNo, unsigned int idPossibility, bool opp
// Name: printMoveInformation()
// Desc:
//-----------------------------------------------------------------------------
void miniMaxAI::printMoveInformation(unsigned int threadNo, unsigned int idPossibility, void *pPossibilities)
void MiniMaxAI::printMoveInformation(unsigned int threadNo, unsigned int idPossibility, void *pPossibilities)
{
// locals
possibilityStruct *tmpPossibility = (possibilityStruct *)pPossibilities;
Possibility *tmpPossibility = (Possibility *)pPossibilities;
// move
if (field->stoneMustBeRemoved) cout << "remove stone from " << (char)(idPossibility + 97);

View File

@ -110,10 +110,10 @@ class MiniMax
public:
/*** typedefines ***************************************************************************************************************************/
typedef unsigned char twoBit; // 2-Bit variable ranging from 0 to 3
typedef unsigned short plyInfoVarType; // 2 Bytes for saving the ply info
typedef unsigned char countArrayVarType; // 1 Byte for counting predesseccors
typedef unsigned int stateNumberVarType; // 4 Bytes for addressing states within a layer
typedef unsigned char TwoBit; // 2-Bit variable ranging from 0 to 3
typedef unsigned short PlyInfoVarType; // 2 Bytes for saving the ply info
typedef unsigned char CountArrayVarType; // 1 Byte for counting predesseccors
typedef unsigned int StateNumberVarType; // 4 Bytes for addressing states within a layer
/*** protected structures ********************************************************************************************************************/
@ -139,8 +139,8 @@ public:
bool plyInfoIsCompletedAndInFile; // the array plyInfo[] contains only fully calculated valid values
long long layerOffset; // position of this struct in the ply info file
unsigned int sizeInBytes; // size of this struct plus the array plyInfo[]
stateNumberVarType knotsInLayer; // number of knots of the corresponding layer
plyInfoVarType *plyInfo; // array of size [knotsInLayer] containing the ply info for each knot in this layer
StateNumberVarType knotsInLayer; // number of knots of the corresponding layer
PlyInfoVarType *plyInfo; // array of size [knotsInLayer] containing the ply info for each knot in this layer
// compressorClass::compressedArrayClass * plyInfoCompressed; // compressed array containing the ply info for each knot in this layer
void *plyInfoCompressed; // dummy pointer for padding
};
@ -153,20 +153,20 @@ public:
unsigned int numSuccLayers; // number of succeding layers. states of other layers are connected by a move of a player
unsigned int succLayers[MAX_NUM_PRED_LAYERS];// array containg the layer ids of the succeding layers
unsigned int partnerLayer; // layer id relevant when switching current and opponent player
stateNumberVarType knotsInLayer; // number of knots of the corresponding layer
stateNumberVarType numWonStates; // number of won states in this layer
stateNumberVarType numLostStates; // number of lost states in this layer
stateNumberVarType numDrawnStates; // number of drawn states in this layer
stateNumberVarType numInvalidStates; // number of invalid states in this layer
StateNumberVarType knotsInLayer; // number of knots of the corresponding layer
StateNumberVarType numWonStates; // number of won states in this layer
StateNumberVarType numLostStates; // number of lost states in this layer
StateNumberVarType numDrawnStates; // number of drawn states in this layer
StateNumberVarType numInvalidStates; // number of invalid states in this layer
unsigned int sizeInBytes; // (knotsInLayer + 3) / 4
twoBit *shortKnotValueByte; // array of size [sizeInBytes] containg the short knot values
TwoBit *shortKnotValueByte; // array of size [sizeInBytes] containg the short knot values
//compressorClass::compressedArrayClass * skvCompressed; // compressed array containing the short knot values
void *skvCompressed; // dummy pointer for padding
};
struct StateAdress
{
stateNumberVarType stateNumber; // state id within the corresponding layer
StateNumberVarType stateNumber; // state id within the corresponding layer
unsigned char layerNumber; // layer id
};
@ -174,15 +174,15 @@ public:
{
bool isOpponentLevel; // the current considered knot belongs to an opponent game state
float floatValue; // Value of knot (for normal mode)
twoBit shortValue; // Value of knot (for database)
TwoBit shortValue; // Value of knot (for database)
unsigned int bestMoveId; // for calling class
unsigned int bestBranch; // branch with highest value
unsigned int numPossibilities; // number of branches
plyInfoVarType plyInfo; // number of moves till win/lost
PlyInfoVarType plyInfo; // number of moves till win/lost
Node *branches; // pointer to branches
};
struct retroAnalysisPredVars
struct RetroAnalysisPredVars
{
unsigned int predStateNumbers; //
unsigned int predLayerNumbers; //
@ -245,10 +245,10 @@ public:
unsigned int getNumThreads();
bool anyFreshlyCalculatedLayer();
unsigned int getLastCalculatedLayer();
stateNumberVarType getNumWonStates(unsigned int layerNum);
stateNumberVarType getNumLostStates(unsigned int layerNum);
stateNumberVarType getNumDrawnStates(unsigned int layerNum);
stateNumberVarType getNumInvalidStates(unsigned int layerNum);
StateNumberVarType getNumWonStates(unsigned int layerNum);
StateNumberVarType getNumLostStates(unsigned int layerNum);
StateNumberVarType getNumDrawnStates(unsigned int layerNum);
StateNumberVarType getNumInvalidStates(unsigned int layerNum);
bool isLayerInDatabase(unsigned int layerNum);
long long getLayerSizeInBytes(unsigned int layerNum);
void setOutputStream(ostream *theStream, void(*printFunc)(void *pUserData), void *pUserData);
@ -284,7 +284,7 @@ public:
{
while (true);
};
virtual void storeValueOfMove(unsigned int threadNo, unsigned int idPossibility, void *pPossibilities, twoBit value, unsigned int *freqValuesSubMoves, plyInfoVarType plyInfo)
virtual void storeValueOfMove(unsigned int threadNo, unsigned int idPossibility, void *pPossibilities, TwoBit value, unsigned int *freqValuesSubMoves, PlyInfoVarType plyInfo)
{
};
virtual void move(unsigned int threadNo, unsigned int idPossibility, bool opponentsMove, void **pBackup, void *pPossibilities)
@ -330,7 +330,7 @@ public:
while (true); return false;
};
virtual void getValueOfSituation(unsigned int threadNo, float &floatValue, twoBit &shortValue)
virtual void getValueOfSituation(unsigned int threadNo, float &floatValue, TwoBit &shortValue)
{
while (true);
}; // value of situation for the initial current player
@ -350,7 +350,7 @@ public:
{
while (true);
};
virtual void getPredecessors(unsigned int threadNo, unsigned int *amountOfPred, retroAnalysisPredVars *predVars)
virtual void getPredecessors(unsigned int threadNo, unsigned int *amountOfPred, RetroAnalysisPredVars *predVars)
{
while (true);
};
@ -383,8 +383,8 @@ private:
unsigned int curThreadNo;
unsigned int layerNumber;
LONGLONG statesProcessed;
twoBit *subValueInDatabase;
plyInfoVarType *subPlyInfos;
TwoBit *subValueInDatabase;
PlyInfoVarType *subPlyInfos;
bool *hasCurPlayerChanged;
};
@ -511,8 +511,8 @@ private:
struct RetroAnalysisQueueState
{
stateNumberVarType stateNumber; // state stored in the retro analysis queue. the queue is a buffer containing states to be passed to 'RetroAnalysisThreadVars::statesToProcess'
plyInfoVarType numPliesTillCurState; // ply number for the stored state
StateNumberVarType stateNumber; // state stored in the retro analysis queue. the queue is a buffer containing states to be passed to 'RetroAnalysisThreadVars::statesToProcess'
PlyInfoVarType numPliesTillCurState; // ply number for the stored state
};
struct RetroAnalysisThreadVars // thread specific variables for each thread in the retro analysis
@ -525,7 +525,7 @@ private:
struct retroAnalysisGlobalVars // constant during calculation
{
vector<countArrayVarType *> countArrays; // One count array for each layer in 'layersToCalculate'. (For the nine men's morris game two layers have to considered at once.)
vector<CountArrayVarType *> countArrays; // One count array for each layer in 'layersToCalculate'. (For the nine men's morris game two layers have to considered at once.)
vector<bool> layerInitialized; //
vector<unsigned int> layersToCalculate; // layers which shall be calculated
long long totalNumKnots; // total numbers of knots which have to be stored in memory
@ -590,7 +590,7 @@ private:
struct AddNumSuccedorsVars : public threadManagerClass::threadVarsArrayItem, public RetroAnalysisDefaultThreadVars
{
retroAnalysisPredVars predVars[MAX_NUM_PREDECESSORS];
RetroAnalysisPredVars predVars[MAX_NUM_PREDECESSORS];
AddNumSuccedorsVars()
{
@ -669,11 +669,11 @@ private:
void unloadLayer(unsigned int layerNumber);
void saveHeader(SkvFileHeader *dbH, LayerStats *lStats);
void saveHeader(PlyInfoFileHeader *piH, PlyInfo *pInfo);
void readKnotValueFromDatabase(unsigned int threadNo, unsigned int &layerNumber, unsigned int &stateNumber, twoBit &knotValue, bool &invalidLayerOrStateNumber, bool &layerInDatabaseAndCompleted);
void readKnotValueFromDatabase(unsigned int layerNumber, unsigned int stateNumber, twoBit &knotValue);
void readPlyInfoFromDatabase(unsigned int layerNumber, unsigned int stateNumber, plyInfoVarType &value);
void saveKnotValueInDatabase(unsigned int layerNumber, unsigned int stateNumber, twoBit knotValue);
void savePlyInfoInDatabase(unsigned int layerNumber, unsigned int stateNumber, plyInfoVarType value);
void readKnotValueFromDatabase(unsigned int threadNo, unsigned int &layerNumber, unsigned int &stateNumber, TwoBit &knotValue, bool &invalidLayerOrStateNumber, bool &layerInDatabaseAndCompleted);
void readKnotValueFromDatabase(unsigned int layerNumber, unsigned int stateNumber, TwoBit &knotValue);
void readPlyInfoFromDatabase(unsigned int layerNumber, unsigned int stateNumber, PlyInfoVarType &value);
void saveKnotValueInDatabase(unsigned int layerNumber, unsigned int stateNumber, TwoBit knotValue);
void savePlyInfoInDatabase(unsigned int layerNumber, unsigned int stateNumber, PlyInfoVarType value);
void loadBytesFromFile(HANDLE hFile, long long offset, unsigned int numBytes, void *pBytes);
void saveBytesToFile(HANDLE hFile, long long offset, unsigned int numBytes, void *pBytes);
void saveLayerToFile(unsigned int layerNumber);
@ -693,7 +693,7 @@ private:
void alphaBetaCalcPlyInfo(Node *knot);
void alphaBetaCalcKnotValue(Node *knot);
void alphaBetaChooseBestMove(Node *knot, RunAlphaBetaVars *rabVars, unsigned int tilLevel, unsigned int *idPossibility, unsigned int maxWonfreqValuesSubMoves);
void alphaBetaSaveInDatabase(unsigned int threadNo, unsigned int layerNumber, unsigned int stateNumber, twoBit knotValue, plyInfoVarType plyValue, bool invertValue);
void alphaBetaSaveInDatabase(unsigned int threadNo, unsigned int layerNumber, unsigned int stateNumber, TwoBit knotValue, PlyInfoVarType plyValue, bool invertValue);
static DWORD initAlphaBetaThreadProc(void *pParameter, int index);
static DWORD runAlphaBetaThreadProc(void *pParameter, int index);

View File

@ -1,5 +1,5 @@
/*********************************************************************\
miniMaxAI.h
MiniMaxAI.h
Copyright (c) Thomas Weber. All rights reserved.
Copyright (C) 2021 The Sanmill developers (see AUTHORS file)
Licensed under the MIT License.
@ -21,18 +21,18 @@
#define VALUE_GAME_WON 1000.0f
/*** Klassen *********************************************************/
class miniMaxAI : public MillAI, MiniMax
class MiniMaxAI : public MillAI, MiniMax
{
protected:
// structs
struct possibilityStruct
struct Possibility
{
unsigned int from[MAX_NUM_POS_MOVES];
unsigned int to[MAX_NUM_POS_MOVES];
};
struct backupStruct
struct Backup
{
float value;
bool gameHasFinished;
@ -58,8 +58,8 @@ protected:
unsigned int curSearchDepth; // current level
unsigned int depthOfFullTree; // search depth where the whole tree is explored
unsigned int *idPossibilities; // returned pointer of getPossibilities()-function
backupStruct *oldStates; // for undo()-function
possibilityStruct *possibilities; // for getPossNormalMove()-function
Backup *oldStates; // for undo()-function
Possibility *possibilities; // for getPossNormalMove()-function
// Functions
unsigned int *getPossSettingPhase(unsigned int *numPossibilities, void **pPossibilities);
@ -70,9 +70,9 @@ protected:
inline void updatePossibleMoves(unsigned int stone, Player *stoneOwner, bool stoneRemoved, unsigned int ignoreStone);
inline void updateWarning(unsigned int firstStone, unsigned int secondStone);
inline void setWarning(unsigned int stoneOne, unsigned int stoneTwo, unsigned int stoneThree);
inline void removeStone(unsigned int from, backupStruct *backup);
inline void setStone(unsigned int to, backupStruct *backup);
inline void normalMove(unsigned int from, unsigned int to, backupStruct *backup);
inline void removeStone(unsigned int from, Backup *backup);
inline void setStone(unsigned int to, Backup *backup);
inline void normalMove(unsigned int from, unsigned int to, Backup *backup);
// Virtual Functions
void prepareBestChoiceCalculation();
@ -80,7 +80,7 @@ protected:
void deletePossibilities(unsigned int threadNo, void *pPossibilities);
void move(unsigned int threadNo, unsigned int idPossibility, bool opponentsMove, void **pBackup, void *pPossibilities);
void undo(unsigned int threadNo, unsigned int idPossibility, bool opponentsMove, void *pBackup, void *pPossibilities);
void getValueOfSituation(unsigned int threadNo, float &floatValue, twoBit &shortValue);
void getValueOfSituation(unsigned int threadNo, float &floatValue, TwoBit &shortValue);
void printMoveInformation(unsigned int threadNo, unsigned int idPossibility, void *pPossibilities);
unsigned int getNumberOfLayers()
@ -124,7 +124,7 @@ protected:
void getSymStateNumWithDoubles(unsigned int threadNo, unsigned int *numSymmetricStates, unsigned int **symStateNumbers)
{
};
void getPredecessors(unsigned int threadNo, unsigned int *amountOfPred, retroAnalysisPredVars *predVars)
void getPredecessors(unsigned int threadNo, unsigned int *amountOfPred, RetroAnalysisPredVars *predVars)
{
};
void printField(unsigned int threadNo, unsigned char value)
@ -139,8 +139,8 @@ protected:
public:
// Constructor / destructor
miniMaxAI();
~miniMaxAI();
MiniMaxAI();
~MiniMaxAI();
// Functions
void play(fieldStruct *theField, unsigned int *pushFrom, unsigned int *pushTo);

View File

@ -25,7 +25,7 @@ public:
virtual void setVisibility(bool visible)
{
};
virtual void setState(unsigned int curShowedLayer, MiniMax::stateNumberVarType curShowedState)
virtual void setState(unsigned int curShowedLayer, MiniMax::StateNumberVarType curShowedState)
{
};
};
@ -64,7 +64,7 @@ protected:
miniMaxGuiField *pGuiField = nullptr;
bool showingInspectionControls = false;
unsigned int curShowedLayer = 0; // current showed layer
MiniMax::stateNumberVarType curShowedState = 0; // current showed state
MiniMax::StateNumberVarType curShowedState = 0; // current showed state
const unsigned int scrollBarWidth = 20;
public:

View File

@ -44,7 +44,7 @@ bool MiniMax::calcKnotValuesByAlphaBeta(unsigned int layerNumber)
// Name: saveKnotValueInDatabase()
// Desc:
//-----------------------------------------------------------------------------
void MiniMax::alphaBetaSaveInDatabase(unsigned int threadNo, unsigned int layerNumber, unsigned int stateNumber, twoBit knotValue, plyInfoVarType plyValue, bool invertValue)
void MiniMax::alphaBetaSaveInDatabase(unsigned int threadNo, unsigned int layerNumber, unsigned int stateNumber, TwoBit knotValue, PlyInfoVarType plyValue, bool invertValue)
{
// locals
unsigned int *symStateNumbers = nullptr;
@ -160,8 +160,8 @@ DWORD MiniMax::initAlphaBetaThreadProc(void *pParameter, int index)
MiniMax *m = iabVars->pMiniMax;
float floatValue; // dummy variable for calls of getValueOfSituation()
StateAdress curState; // current state counter for loops
twoBit curStateValue = 0; // for calls of getValueOfSituation()
plyInfoVarType plyInfo; // depends on the curStateValue
TwoBit curStateValue = 0; // for calls of getValueOfSituation()
PlyInfoVarType plyInfo; // depends on the curStateValue
curState.layerNumber = iabVars->layerNumber;
curState.stateNumber = index;
@ -175,7 +175,7 @@ DWORD MiniMax::initAlphaBetaThreadProc(void *pParameter, int index)
// layer initialization already done ? if so, then read from file
if (iabVars->initAlreadyDone) {
if (!iabVars->bufferedFile->readBytes(iabVars->curThreadNo, index * sizeof(twoBit), sizeof(twoBit), (unsigned char *)&curStateValue)) {
if (!iabVars->bufferedFile->readBytes(iabVars->curThreadNo, index * sizeof(TwoBit), sizeof(TwoBit), (unsigned char *)&curStateValue)) {
PRINT(0, m, "ERROR: initArray->takeBytes() failed");
return m->falseOrStop();
}
@ -205,7 +205,7 @@ DWORD MiniMax::initAlphaBetaThreadProc(void *pParameter, int index)
// write data to file
if (!iabVars->initAlreadyDone) {
if (!iabVars->bufferedFile->writeBytes(iabVars->curThreadNo, index * sizeof(twoBit), sizeof(twoBit), (unsigned char *)&curStateValue)) {
if (!iabVars->bufferedFile->writeBytes(iabVars->curThreadNo, index * sizeof(TwoBit), sizeof(TwoBit), (unsigned char *)&curStateValue)) {
PRINT(0, m, "ERROR: bufferedFile->writeBytes failed!");
return m->falseOrStop();
}
@ -271,7 +271,7 @@ DWORD MiniMax::runAlphaBetaThreadProc(void *pParameter, int index)
MiniMax *m = rabVars->pMiniMax;
StateAdress curState; // current state counter for loops
Node root; //
plyInfoVarType plyInfo; // depends on the curStateValue
PlyInfoVarType plyInfo; // depends on the curStateValue
curState.layerNumber = rabVars->layerNumber;
curState.stateNumber = index;
@ -392,8 +392,8 @@ bool MiniMax::alphaBetaTryDataBase(Node *knot, RunAlphaBetaVars *rabVars, unsign
// locals
bool invalidLayerOrStateNumber;
bool subLayerInDatabaseAndCompleted;
twoBit shortKnotValue = SKV_VALUE_INVALID;
plyInfoVarType plyInfo = PLYINFO_VALUE_UNCALCULATED;
TwoBit shortKnotValue = SKV_VALUE_INVALID;
PlyInfoVarType plyInfo = PLYINFO_VALUE_UNCALCULATED;
// use database ?
if (hFilePlyInfo != nullptr && hFileShortKnotValues != nullptr && (calcDatabase || layerInDatabase)) {
@ -553,8 +553,8 @@ void MiniMax::alphaBetaCalcPlyInfo(Node *knot)
// locals
unsigned int i;
unsigned int maxBranch;
plyInfoVarType maxPlyInfo;
twoBit shortKnotValue;
PlyInfoVarType maxPlyInfo;
TwoBit shortKnotValue;
//
if (knot->shortValue == SKV_VALUE_GAME_DRAWN) {

View File

@ -325,7 +325,7 @@ void MiniMax::openPlyInfoFile(const char *directory)
plyInfos[i].plyInfoCompressed = nullptr;
plyInfos[i].plyInfoIsLoaded = false;
plyInfos[i].plyInfoIsCompletedAndInFile = false;
plyInfos[i].sizeInBytes = plyInfos[i].knotsInLayer * sizeof(plyInfoVarType);
plyInfos[i].sizeInBytes = plyInfos[i].knotsInLayer * sizeof(PlyInfoVarType);
}
for (i = 1; i < plyInfoHeader.numLayers; i++) {
@ -407,7 +407,7 @@ inline void MiniMax::measureIops(long long &numOperations, LARGE_INTEGER &interv
// Name: readKnotValueFromDatabase()
// Desc:
//-----------------------------------------------------------------------------
void MiniMax::readKnotValueFromDatabase(unsigned int threadNo, unsigned int &layerNumber, unsigned int &stateNumber, twoBit &knotValue, bool &invalidLayerOrStateNumber, bool &layerInDatabaseAndCompleted)
void MiniMax::readKnotValueFromDatabase(unsigned int threadNo, unsigned int &layerNumber, unsigned int &stateNumber, TwoBit &knotValue, bool &invalidLayerOrStateNumber, bool &layerInDatabaseAndCompleted)
{
// get state number, since this is the address, where the value is saved
getLayerAndStateNumber(threadNo, layerNumber, stateNumber);
@ -436,12 +436,12 @@ void MiniMax::readKnotValueFromDatabase(unsigned int threadNo, unsigned int &lay
// Name: readKnotValueFromDatabase()
// Desc:
//-----------------------------------------------------------------------------
void MiniMax::readKnotValueFromDatabase(unsigned int layerNumber, unsigned int stateNumber, twoBit &knotValue)
void MiniMax::readKnotValueFromDatabase(unsigned int layerNumber, unsigned int stateNumber, TwoBit &knotValue)
{
// locals
twoBit databaseByte;
TwoBit databaseByte;
long long bytesAllocated;
twoBit defValue = SKV_WHOLE_BYTE_IS_INVALID;
TwoBit defValue = SKV_WHOLE_BYTE_IS_INVALID;
LayerStats *myLss = &layerStats[layerNumber];
// valid state and layer number ?
@ -502,11 +502,11 @@ void MiniMax::readKnotValueFromDatabase(unsigned int layerNumber, unsigned int s
// Name: readPlyInfoFromDatabase()
// Desc:
//-----------------------------------------------------------------------------
void MiniMax::readPlyInfoFromDatabase(unsigned int layerNumber, unsigned int stateNumber, plyInfoVarType &value)
void MiniMax::readPlyInfoFromDatabase(unsigned int layerNumber, unsigned int stateNumber, PlyInfoVarType &value)
{
// locals
unsigned int curKnot;
plyInfoVarType defValue = PLYINFO_VALUE_UNCALCULATED;
PlyInfoVarType defValue = PLYINFO_VALUE_UNCALCULATED;
long long bytesAllocated;
PlyInfo *myPis = &plyInfos[layerNumber];
@ -520,7 +520,7 @@ void MiniMax::readPlyInfoFromDatabase(unsigned int layerNumber, unsigned int sta
// if database is complete get whole byte from file
if (plyInfoHeader.plyInfoCompleted || layerInDatabase || myPis->plyInfoIsCompletedAndInFile) {
EnterCriticalSection(&csDatabase);
loadBytesFromFile(hFilePlyInfo, plyInfoHeader.headerAndPlyInfosSize + myPis->layerOffset + sizeof(plyInfoVarType) * stateNumber, sizeof(plyInfoVarType), &value);
loadBytesFromFile(hFilePlyInfo, plyInfoHeader.headerAndPlyInfosSize + myPis->layerOffset + sizeof(PlyInfoVarType) * stateNumber, sizeof(PlyInfoVarType), &value);
LeaveCriticalSection(&csDatabase);
} else {
@ -529,7 +529,7 @@ void MiniMax::readPlyInfoFromDatabase(unsigned int layerNumber, unsigned int sta
EnterCriticalSection(&csDatabase);
if (!myPis->plyInfoIsLoaded) {
// if layer is in database and completed, then load layer from file into memory; set default value otherwise
myPis->plyInfo = new plyInfoVarType[myPis->knotsInLayer];
myPis->plyInfo = new PlyInfoVarType[myPis->knotsInLayer];
if (myPis->plyInfoIsCompletedAndInFile) {
loadBytesFromFile(hFilePlyInfo, plyInfoHeader.headerAndPlyInfosSize + myPis->layerOffset, myPis->sizeInBytes, myPis->plyInfo);
} else {
@ -564,11 +564,11 @@ void MiniMax::readPlyInfoFromDatabase(unsigned int layerNumber, unsigned int sta
// Name: saveKnotValueInDatabase()
// Desc:
//-----------------------------------------------------------------------------
void MiniMax::saveKnotValueInDatabase(unsigned int layerNumber, unsigned int stateNumber, twoBit knotValue)
void MiniMax::saveKnotValueInDatabase(unsigned int layerNumber, unsigned int stateNumber, TwoBit knotValue)
{
// locals
long long bytesAllocated;
twoBit defValue = SKV_WHOLE_BYTE_IS_INVALID;
TwoBit defValue = SKV_WHOLE_BYTE_IS_INVALID;
LayerStats *myLss = &layerStats[layerNumber];
// valid state and layer number ?
@ -589,7 +589,7 @@ void MiniMax::saveKnotValueInDatabase(unsigned int layerNumber, unsigned int sta
EnterCriticalSection(&csDatabase);
if (!myLss->layerIsLoaded) {
// reserve memory for this layer & create array for ply info with default value
myLss->shortKnotValueByte = new twoBit[myLss->sizeInBytes];
myLss->shortKnotValueByte = new TwoBit[myLss->sizeInBytes];
memset(myLss->shortKnotValueByte, SKV_WHOLE_BYTE_IS_INVALID, myLss->sizeInBytes);
bytesAllocated = myLss->sizeInBytes;
arrayInfos.addArray(layerNumber, ArrayInfo::arrayType_layerStats, myLss->sizeInBytes, 0);
@ -627,11 +627,11 @@ void MiniMax::saveKnotValueInDatabase(unsigned int layerNumber, unsigned int sta
// Name: savePlyInfoInDatabase()
// Desc:
//-----------------------------------------------------------------------------
void MiniMax::savePlyInfoInDatabase(unsigned int layerNumber, unsigned int stateNumber, plyInfoVarType value)
void MiniMax::savePlyInfoInDatabase(unsigned int layerNumber, unsigned int stateNumber, PlyInfoVarType value)
{
// locals
unsigned int curKnot;
plyInfoVarType defValue = PLYINFO_VALUE_UNCALCULATED;
PlyInfoVarType defValue = PLYINFO_VALUE_UNCALCULATED;
long long bytesAllocated;
PlyInfo *myPis = &plyInfos[layerNumber];
@ -653,7 +653,7 @@ void MiniMax::savePlyInfoInDatabase(unsigned int layerNumber, unsigned int state
EnterCriticalSection(&csDatabase);
if (!myPis->plyInfoIsLoaded) {
// reserve memory for this layer & create array for ply info with default value
myPis->plyInfo = new plyInfoVarType[myPis->knotsInLayer];
myPis->plyInfo = new PlyInfoVarType[myPis->knotsInLayer];
for (curKnot = 0; curKnot < myPis->knotsInLayer; curKnot++) {
myPis->plyInfo[curKnot] = defValue;
}

View File

@ -92,8 +92,8 @@ freeMem:
}
for (curLayer = 0; curLayer < layersToCalculate.size(); curLayer++) {
if (retroVars.countArrays[curLayer] != nullptr) {
memoryUsed2 -= layerStats[layersToCalculate[curLayer]].knotsInLayer * sizeof(countArrayVarType);
arrayInfos.removeArray(layersToCalculate[curLayer], ArrayInfo::arrayType_countArray, layerStats[layersToCalculate[curLayer]].knotsInLayer * sizeof(countArrayVarType), 0);
memoryUsed2 -= layerStats[layersToCalculate[curLayer]].knotsInLayer * sizeof(CountArrayVarType);
arrayInfos.removeArray(layersToCalculate[curLayer], ArrayInfo::arrayType_countArray, layerStats[layersToCalculate[curLayer]].knotsInLayer * sizeof(CountArrayVarType), 0);
}
SAFE_DELETE_ARRAY(retroVars.countArrays[curLayer]);
}
@ -191,7 +191,7 @@ DWORD MiniMax::initRetroAnalysisThreadProc(void *pParameter, int index)
MiniMax *m = iraVars->pMiniMax;
float floatValue; // dummy variable for calls of getValueOfSituation()
StateAdress curState; // current state counter for loops
twoBit curStateValue; // for calls of getValueOfSituation()
TwoBit curStateValue; // for calls of getValueOfSituation()
curState.layerNumber = iraVars->layerNumber;
curState.stateNumber = index;
@ -205,7 +205,7 @@ DWORD MiniMax::initRetroAnalysisThreadProc(void *pParameter, int index)
// layer initialization already done ? if so, then read from file
if (iraVars->initAlreadyDone) {
if (!iraVars->bufferedFile->readBytes(iraVars->curThreadNo, index * sizeof(twoBit), sizeof(twoBit), (unsigned char *)&curStateValue)) {
if (!iraVars->bufferedFile->readBytes(iraVars->curThreadNo, index * sizeof(TwoBit), sizeof(TwoBit), (unsigned char *)&curStateValue)) {
PRINT(0, m, "ERROR: initArray->takeBytes() failed");
return m->falseOrStop();
}
@ -242,7 +242,7 @@ DWORD MiniMax::initRetroAnalysisThreadProc(void *pParameter, int index)
// write data to file
if (!iraVars->initAlreadyDone) {
// curStateValue sollte 2 sein bei index == 1329322
if (!iraVars->bufferedFile->writeBytes(iraVars->curThreadNo, index * sizeof(twoBit), sizeof(twoBit), (unsigned char *)&curStateValue)) {
if (!iraVars->bufferedFile->writeBytes(iraVars->curThreadNo, index * sizeof(TwoBit), sizeof(TwoBit), (unsigned char *)&curStateValue)) {
PRINT(0, m, "ERROR: bufferedFile->writeBytes failed!");
return m->falseOrStop();
}
@ -262,7 +262,7 @@ bool MiniMax::prepareCountArrays(retroAnalysisGlobalVars &retroVars)
unsigned int numKnotsInCurLayer;
StateAdress curState; // current state counter for loops
unsigned int curLayer = 0; // Counter variable
countArrayVarType defValue = 0; // default counter array value
CountArrayVarType defValue = 0; // default counter array value
DWORD dwWritten;
DWORD dwRead;
LARGE_INTEGER fileSize;
@ -288,9 +288,9 @@ bool MiniMax::prepareCountArrays(retroAnalysisGlobalVars &retroVars)
// allocate memory for count arrays
for (curLayer = 0; curLayer < retroVars.layersToCalculate.size(); curLayer++) {
numKnotsInCurLayer = layerStats[retroVars.layersToCalculate[curLayer]].knotsInLayer;
retroVars.countArrays[curLayer] = new countArrayVarType[numKnotsInCurLayer];
memoryUsed2 += numKnotsInCurLayer * sizeof(countArrayVarType);
arrayInfos.addArray(retroVars.layersToCalculate[curLayer], ArrayInfo::arrayType_countArray, numKnotsInCurLayer * sizeof(countArrayVarType), 0);
retroVars.countArrays[curLayer] = new CountArrayVarType[numKnotsInCurLayer];
memoryUsed2 += numKnotsInCurLayer * sizeof(CountArrayVarType);
arrayInfos.addArray(retroVars.layersToCalculate[curLayer], ArrayInfo::arrayType_countArray, numKnotsInCurLayer * sizeof(CountArrayVarType), 0);
}
// load file if already existend
@ -299,8 +299,8 @@ 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, nullptr)) return falseOrStop();
if (dwRead != numKnotsInCurLayer * sizeof(countArrayVarType)) return falseOrStop();
if (!ReadFile(hFileCountArray, retroVars.countArrays[curLayer], numKnotsInCurLayer * sizeof(CountArrayVarType), &dwRead, nullptr)) return falseOrStop();
if (dwRead != numKnotsInCurLayer * sizeof(CountArrayVarType)) return falseOrStop();
}
// else calculate number of succedding states
@ -323,8 +323,8 @@ 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, nullptr)) return falseOrStop();
if (dwWritten != numKnotsInCurLayer * sizeof(countArrayVarType)) 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());
}
@ -440,15 +440,15 @@ DWORD MiniMax::addNumSuccedorsThreadProc(void *pParameter, int index)
unsigned int curLayerId; // current processed layer within 'layersToCalculate'
unsigned int amountOfPred;
unsigned int curPred;
countArrayVarType countValue;
CountArrayVarType countValue;
StateAdress predState;
StateAdress curState;
twoBit curStateValue;
plyInfoVarType numPlies; // number of plies of the current considered succeding state
TwoBit curStateValue;
PlyInfoVarType numPlies; // number of plies of the current considered succeding state
bool cuStateAddedToProcessQueue = false;
curState.layerNumber = ansVars->layerNumber;
curState.stateNumber = (stateNumberVarType)index;
curState.stateNumber = (StateNumberVarType)index;
// print status
ansVars->statesProcessed++;
@ -491,14 +491,14 @@ DWORD MiniMax::addNumSuccedorsThreadProc(void *pParameter, int index)
}
// add this state as possible move
long *pCountValue = ((long *)ansVars->retroVars->countArrays[curLayerId]) + predState.stateNumber / (sizeof(long) / sizeof(countArrayVarType));
long numBitsToShift = sizeof(countArrayVarType) * 8 * (predState.stateNumber % (sizeof(long) / sizeof(countArrayVarType))); // little-endian byte-order
long *pCountValue = ((long *)ansVars->retroVars->countArrays[curLayerId]) + predState.stateNumber / (sizeof(long) / sizeof(CountArrayVarType));
long numBitsToShift = sizeof(CountArrayVarType) * 8 * (predState.stateNumber % (sizeof(long) / sizeof(CountArrayVarType))); // little-endian byte-order
long mask = 0x000000ff << numBitsToShift;
long curCountLong, newCountLong;
do {
curCountLong = *pCountValue;
countValue = (countArrayVarType)((curCountLong & mask) >> numBitsToShift);
countValue = (CountArrayVarType)((curCountLong & mask) >> numBitsToShift);
if (countValue == 255) {
PRINT(0, m, "ERROR: maximum value for Count[] reached!");
return TM_RETURN_VALUE_TERMINATE_ALL_THREADS;
@ -521,7 +521,7 @@ bool MiniMax::performRetroAnalysis(retroAnalysisGlobalVars &retroVars)
{
// locals
StateAdress curState; // current state counter for loops
twoBit curStateValue; // current state value
TwoBit curStateValue; // current state value
unsigned int curLayerId; // current processed layer within 'layersToCalculate'
PRINT(2, this, " *** Begin Iteration ***");
@ -576,21 +576,21 @@ DWORD MiniMax::performRetroAnalysisThreadProc(void *pParameter)
unsigned int threadNo = m->threadManager.getThreadNumber();
RetroAnalysisThreadVars *threadVars = &retroVars->thread[threadNo];
twoBit predStateValue;
TwoBit predStateValue;
unsigned int curLayerId; // current processed layer within 'layersToCalculate'
unsigned int amountOfPred; // total numbers of predecessors and current considered one
unsigned int curPred;
unsigned int threadCounter;
long long numStatesProcessed;
long long totalNumStatesToProcess;
plyInfoVarType curNumPlies;
plyInfoVarType numPliesTillCurState;
plyInfoVarType numPliesTillPredState;
countArrayVarType countValue;
PlyInfoVarType curNumPlies;
PlyInfoVarType numPliesTillCurState;
PlyInfoVarType numPliesTillPredState;
CountArrayVarType countValue;
StateAdress predState;
StateAdress curState; // current state counter for while-loop
twoBit curStateValue; // current state value
retroAnalysisPredVars predVars[MAX_NUM_PREDECESSORS];
TwoBit curStateValue; // current state value
RetroAnalysisPredVars predVars[MAX_NUM_PREDECESSORS];
for (numStatesProcessed = 0, curNumPlies = 0; curNumPlies < threadVars->statesToProcess.size(); curNumPlies++) {
@ -672,14 +672,14 @@ DWORD MiniMax::performRetroAnalysisThreadProc(void *pParameter)
// if current state is a won game, then this state is not an option any more for all predecessors
} else {
// reduce count value by one
long *pCountValue = ((long *)retroVars->countArrays[curLayerId]) + predState.stateNumber / (sizeof(long) / sizeof(countArrayVarType));
long numBitsToShift = sizeof(countArrayVarType) * 8 * (predState.stateNumber % (sizeof(long) / sizeof(countArrayVarType))); // little-endian byte-order
long *pCountValue = ((long *)retroVars->countArrays[curLayerId]) + predState.stateNumber / (sizeof(long) / sizeof(CountArrayVarType));
long numBitsToShift = sizeof(CountArrayVarType) * 8 * (predState.stateNumber % (sizeof(long) / sizeof(CountArrayVarType))); // little-endian byte-order
long mask = 0x000000ff << numBitsToShift;
long curCountLong, newCountLong;
do {
curCountLong = *pCountValue;
countValue = (countArrayVarType)((curCountLong & mask) >> numBitsToShift);
countValue = (CountArrayVarType)((curCountLong & mask) >> numBitsToShift);
if (countValue > 0) {
countValue--;
newCountLong = (curCountLong & (~mask)) + (countValue << numBitsToShift);

View File

@ -8,8 +8,8 @@
struct RetroAnalysisQueueState
{
stateNumberVarType stateNumber; // state stored in the retro analysis queue. the queue is a buffer containing states to be passed to 'RetroAnalysisThreadVars::statesToProcess'
plyInfoVarType numPliesTillCurState; // ply number for the stored state
StateNumberVarType stateNumber; // state stored in the retro analysis queue. the queue is a buffer containing states to be passed to 'RetroAnalysisThreadVars::statesToProcess'
PlyInfoVarType numPliesTillCurState; // ply number for the stored state
};
struct RetroAnalysisThreadVars // thread specific variables for each thread in the retro analysis
@ -20,9 +20,9 @@ struct RetroAnalysisThreadVars // thread specific variables for each t
unsigned int threadNo;
};
struct retroAnalysisVars // constant during calculation
struct RetroAnalysisVars // constant during calculation
{
vector<countArrayVarType *> countArrays; // One count array for each layer in 'layersToCalculate'. (For the nine men's morris game two layers have to considered at once.)
vector<CountArrayVarType *> countArrays; // One count array for each layer in 'layersToCalculate'. (For the nine men's morris game two layers have to considered at once.)
vector<compressorClass::compressedArrayClass *> countArraysCompr; // '' but compressed
vector<bool> layerInitialized; //
vector<unsigned int> layersToCalculate; // layers which shall be calculated
@ -39,7 +39,7 @@ struct InitRetroAnalysisVars
LONGLONG statesProcessed;
unsigned int statsValueCounter[SKV_NUM_VALUES];
BufferedFile *bufferedFile;
retroAnalysisVars *retroVars;
RetroAnalysisVars *retroVars;
bool initAlreadyDone; // true if the initialization information is already available in a file
};
@ -49,10 +49,10 @@ struct addSuccLayersVars
unsigned int curThreadNo;
unsigned int statsValueCounter[SKV_NUM_VALUES];
unsigned int layerNumber;
retroAnalysisVars *retroVars;
RetroAnalysisVars *retroVars;
};
struct retroAnalysisPredVars
struct RetroAnalysisPredVars
{
unsigned int predStateNumbers;
unsigned int predLayerNumbers;
@ -66,6 +66,6 @@ struct AddNumSuccedorsVars
unsigned int curThreadNo;
unsigned int layerNumber;
LONGLONG statesProcessed;
retroAnalysisVars *retroVars;
retroAnalysisPredVars *predVars;
RetroAnalysisVars *retroVars;
RetroAnalysisPredVars *predVars;
};

View File

@ -61,7 +61,7 @@ long long MiniMax::getLayerSizeInBytes(unsigned int layerNum)
// Name: getNumWonStates()
// Desc:
//-----------------------------------------------------------------------------
MiniMax::stateNumberVarType MiniMax::getNumWonStates(unsigned int layerNum)
MiniMax::StateNumberVarType MiniMax::getNumWonStates(unsigned int layerNum)
{
if (layerStats == nullptr) return 0;
return layerStats[layerNum].numWonStates;
@ -71,7 +71,7 @@ MiniMax::stateNumberVarType MiniMax::getNumWonStates(unsigned int layerNum)
// Name: getNumLostStates()
// Desc:
//-----------------------------------------------------------------------------
MiniMax::stateNumberVarType MiniMax::getNumLostStates(unsigned int layerNum)
MiniMax::StateNumberVarType MiniMax::getNumLostStates(unsigned int layerNum)
{
if (layerStats == nullptr) return 0;
return layerStats[layerNum].numLostStates;
@ -81,7 +81,7 @@ MiniMax::stateNumberVarType MiniMax::getNumLostStates(unsigned int layerNum)
// Name: getNumDrawnStates()
// Desc:
//-----------------------------------------------------------------------------
MiniMax::stateNumberVarType MiniMax::getNumDrawnStates(unsigned int layerNum)
MiniMax::StateNumberVarType MiniMax::getNumDrawnStates(unsigned int layerNum)
{
if (layerStats == nullptr) return 0;
return layerStats[layerNum].numDrawnStates;
@ -91,7 +91,7 @@ MiniMax::stateNumberVarType MiniMax::getNumDrawnStates(unsigned int layerNum)
// Name: getNumInvalidStates()
// Desc:
//-----------------------------------------------------------------------------
MiniMax::stateNumberVarType MiniMax::getNumInvalidStates(unsigned int layerNum)
MiniMax::StateNumberVarType MiniMax::getNumInvalidStates(unsigned int layerNum)
{
if (layerStats == nullptr) return 0;
return layerStats[layerNum].numInvalidStates;
@ -137,7 +137,7 @@ void MiniMax::showLayerStats(unsigned int layerNumber)
// locals
StateAdress curState;
unsigned int statsValueCounter[] = { 0,0,0,0 };
twoBit curStateValue;
TwoBit curStateValue;
// calc and show statistics
for (curState.layerNumber = layerNumber, curState.stateNumber = 0; curState.stateNumber < layerStats[curState.layerNumber].knotsInLayer; curState.stateNumber++) {
@ -172,7 +172,7 @@ bool MiniMax::calcLayerStatistics(char *statisticsFileName)
DWORD dwBytesWritten;
StateAdress curState;
unsigned int *statsValueCounter;
twoBit curStateValue;
TwoBit curStateValue;
char line[10000];
string text("");

View File

@ -40,8 +40,8 @@ bool MiniMax::testLayer(unsigned int layerNumber)
tlVars[curThreadNo].pMiniMax = this;
tlVars[curThreadNo].layerNumber = layerNumber;
tlVars[curThreadNo].statesProcessed = 0;
tlVars[curThreadNo].subValueInDatabase = new twoBit[maxNumBranches];
tlVars[curThreadNo].subPlyInfos = new plyInfoVarType[maxNumBranches];
tlVars[curThreadNo].subValueInDatabase = new TwoBit[maxNumBranches];
tlVars[curThreadNo].subPlyInfos = new PlyInfoVarType[maxNumBranches];
tlVars[curThreadNo].hasCurPlayerChanged = new bool[maxNumBranches];
}
@ -93,14 +93,14 @@ DWORD MiniMax::testLayerThreadProc(void *pParameter, int index)
unsigned int layerNumber = tlVars->layerNumber;
unsigned int stateNumber = index;
unsigned int threadNo = tlVars->curThreadNo;
twoBit *subValueInDatabase = tlVars->subValueInDatabase;
plyInfoVarType *subPlyInfos = tlVars->subPlyInfos;
TwoBit *subValueInDatabase = tlVars->subValueInDatabase;
PlyInfoVarType *subPlyInfos = tlVars->subPlyInfos;
bool *hasCurPlayerChanged = tlVars->hasCurPlayerChanged;
twoBit shortValueInDatabase;
plyInfoVarType numPliesTillCurState;
twoBit shortValueInGame;
TwoBit shortValueInDatabase;
PlyInfoVarType numPliesTillCurState;
TwoBit shortValueInGame;
float floatValueInGame;
plyInfoVarType min, max;
PlyInfoVarType min, max;
unsigned int numPossibilities;
unsigned int i, j;
unsigned int tmpStateNumber, tmpLayerNumber;
@ -319,8 +319,8 @@ bool MiniMax::testState(unsigned int layerNumber, unsigned int stateNumber)
tlVars.pMiniMax = this;
tlVars.layerNumber = layerNumber;
tlVars.statesProcessed = 0;
tlVars.subValueInDatabase = new twoBit[maxNumBranches];
tlVars.subPlyInfos = new plyInfoVarType[maxNumBranches];
tlVars.subValueInDatabase = new TwoBit[maxNumBranches];
tlVars.subPlyInfos = new PlyInfoVarType[maxNumBranches];
tlVars.hasCurPlayerChanged = new bool[maxNumBranches];
if (testLayerThreadProc(&tlVars, stateNumber) != TM_RETURN_VALUE_OK) result = false;
@ -355,8 +355,8 @@ bool MiniMax::testSetSituationAndGetPoss(unsigned int layerNumber)
tlVars[curThreadNo].pMiniMax = this;
tlVars[curThreadNo].layerNumber = layerNumber;
tlVars[curThreadNo].statesProcessed = 0;
tlVars[curThreadNo].subValueInDatabase = new twoBit[maxNumBranches];
tlVars[curThreadNo].subPlyInfos = new plyInfoVarType[maxNumBranches];
tlVars[curThreadNo].subValueInDatabase = new TwoBit[maxNumBranches];
tlVars[curThreadNo].subPlyInfos = new PlyInfoVarType[maxNumBranches];
tlVars[curThreadNo].hasCurPlayerChanged = new bool[maxNumBranches];
}
@ -413,7 +413,7 @@ DWORD MiniMax::testSetSituationThreadProc(void *pParameter, int index)
StateAdress curState;
StateAdress subState;
Node knot;
twoBit shortKnotValue = SKV_VALUE_GAME_DRAWN;
TwoBit shortKnotValue = SKV_VALUE_GAME_DRAWN;
curState.layerNumber = tlVars->layerNumber;
curState.stateNumber = index;
@ -485,10 +485,10 @@ bool MiniMax::testIfSymStatesHaveSameValue(unsigned int layerNumber)
{
// Locals
unsigned int threadNo = 0;
twoBit shortValueInDatabase;
twoBit shortValueOfSymState;
plyInfoVarType numPliesTillCurState;
plyInfoVarType numPliesTillSymState;
TwoBit shortValueInDatabase;
TwoBit shortValueOfSymState;
PlyInfoVarType numPliesTillCurState;
PlyInfoVarType numPliesTillSymState;
unsigned int stateNumber = 0;
unsigned int *symStateNumbers = nullptr;
unsigned int numSymmetricStates;

View File

@ -206,8 +206,8 @@ perfectAI::perfectAI(const char *directory)
for (unsigned int curThread = 0; curThread < getNumThreads(); curThread++) {
threadVars[curThread].parent = this;
threadVars[curThread].field = &dummyField;
threadVars[curThread].possibilities = new possibilityStruct[MAX_DEPTH_OF_TREE + 1];
threadVars[curThread].oldStates = new backupStruct[MAX_DEPTH_OF_TREE + 1];
threadVars[curThread].possibilities = new Possibility[MAX_DEPTH_OF_TREE + 1];
threadVars[curThread].oldStates = new Backup[MAX_DEPTH_OF_TREE + 1];
threadVars[curThread].idPossibilities = new unsigned int[(MAX_DEPTH_OF_TREE + 1) * MAX_NUM_POS_MOVES];
}
@ -235,7 +235,7 @@ perfectAI::perfectAI(const char *directory)
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, plyInfoForOutput, sizeof(PlyInfoVarType) * fieldStruct::size * fieldStruct::size, &dwBytesRead, nullptr);
ReadFile(hFilePreCalcVars, incidencesValuesSubMoves, sizeof(unsigned int) * 4 * fieldStruct::size * fieldStruct::size, &dwBytesRead, nullptr);
// process originalStateAB[][]
@ -601,7 +601,7 @@ perfectAI::perfectAI(const char *directory)
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, plyInfoForOutput, sizeof(PlyInfoVarType) * fieldStruct::size * fieldStruct::size, &dwBytesWritten, nullptr);
WriteFile(hFilePreCalcVars, incidencesValuesSubMoves, sizeof(unsigned int) * 4 * fieldStruct::size * fieldStruct::size, &dwBytesWritten, nullptr);
// process originalStateAB[][]
@ -683,7 +683,7 @@ void perfectAI::play(fieldStruct *theField, unsigned int *pushFrom, unsigned int
}
// start the miniMax-algorithmn
possibilityStruct *rootPossibilities = (possibilityStruct *)getBestChoice(threadVars[0].depthOfFullTree, &bestChoice, MAX_NUM_POS_MOVES);
Possibility *rootPossibilities = (Possibility *)getBestChoice(threadVars[0].depthOfFullTree, &bestChoice, MAX_NUM_POS_MOVES);
// decode the best choice
if (threadVars[0].field->stoneMustBeRemoved) {
@ -863,7 +863,7 @@ unsigned int *perfectAI::threadVarsStruct::getPossNormalMove(unsigned int *numPo
// locals
unsigned int from, to, dir;
unsigned int *idPossibility = &idPossibilities[curSearchDepth * MAX_NUM_POS_MOVES];
possibilityStruct *possibility = &possibilities[curSearchDepth];
Possibility *possibility = &possibilities[curSearchDepth];
// if he is not allowed to spring
if (field->curPlayer->numStones > 3) {
@ -981,7 +981,7 @@ unsigned int *perfectAI::getPossibilities(unsigned int threadNo, unsigned int *n
// Name: getValueOfSituation()
// Desc:
//-----------------------------------------------------------------------------
void perfectAI::getValueOfSituation(unsigned int threadNo, float &floatValue, twoBit &shortValue)
void perfectAI::getValueOfSituation(unsigned int threadNo, float &floatValue, TwoBit &shortValue)
{
threadVarsStruct *tv = &threadVars[threadNo];
floatValue = tv->floatValue;
@ -1004,7 +1004,7 @@ void perfectAI::undo(unsigned int threadNo, unsigned int idPossibility, bool opp
{
// locals
threadVarsStruct *tv = &threadVars[threadNo];
backupStruct *oldState = (backupStruct *)pBackup;
Backup *oldState = (Backup *)pBackup;
// reset old value
tv->floatValue = oldState->floatValue;
@ -1125,7 +1125,7 @@ inline void perfectAI::threadVarsStruct::updatePossibleMoves(unsigned int stone,
// Name: setStone()
// Desc:
//-----------------------------------------------------------------------------
inline void perfectAI::threadVarsStruct::setStone(unsigned int to, backupStruct *backup)
inline void perfectAI::threadVarsStruct::setStone(unsigned int to, Backup *backup)
{
// backup
backup->from = field->size;
@ -1152,7 +1152,7 @@ inline void perfectAI::threadVarsStruct::setStone(unsigned int to, backupStruct
// Name: normalMove()
// Desc:
//-----------------------------------------------------------------------------
inline void perfectAI::threadVarsStruct::normalMove(unsigned int from, unsigned int to, backupStruct *backup)
inline void perfectAI::threadVarsStruct::normalMove(unsigned int from, unsigned int to, Backup *backup)
{
// backup
backup->from = from;
@ -1176,7 +1176,7 @@ inline void perfectAI::threadVarsStruct::normalMove(unsigned int from, unsigned
// Name: removeStone()
// Desc:
//-----------------------------------------------------------------------------
inline void perfectAI::threadVarsStruct::removeStone(unsigned int from, backupStruct *backup)
inline void perfectAI::threadVarsStruct::removeStone(unsigned int from, Backup *backup)
{
// backup
backup->from = from;
@ -1208,8 +1208,8 @@ void perfectAI::move(unsigned int threadNo, unsigned int idPossibility, bool opp
{
// locals
threadVarsStruct *tv = &threadVars[threadNo];
backupStruct *oldState = &tv->oldStates[tv->curSearchDepth];
possibilityStruct *tmpPossibility = (possibilityStruct *)pPossibilities;
Backup *oldState = &tv->oldStates[tv->curSearchDepth];
Possibility *tmpPossibility = (Possibility *)pPossibilities;
Player *tmpPlayer;
unsigned int i;
@ -1274,12 +1274,12 @@ void perfectAI::move(unsigned int threadNo, unsigned int idPossibility, bool opp
// Name: storeValueOfMove()
// Desc:
//-----------------------------------------------------------------------------
void perfectAI::storeValueOfMove(unsigned int threadNo, unsigned int idPossibility, void *pPossibilities, unsigned char value, unsigned int *freqValuesSubMoves, plyInfoVarType plyInfo)
void perfectAI::storeValueOfMove(unsigned int threadNo, unsigned int idPossibility, void *pPossibilities, unsigned char value, unsigned int *freqValuesSubMoves, PlyInfoVarType plyInfo)
{
// locals
threadVarsStruct *tv = &threadVars[threadNo];
unsigned int index;
possibilityStruct *tmpPossibility = (possibilityStruct *)pPossibilities;
Possibility *tmpPossibility = (Possibility *)pPossibilities;
if (tv->field->stoneMustBeRemoved) index = idPossibility;
else if (tv->field->settingPhase) index = idPossibility;
@ -1297,7 +1297,7 @@ void perfectAI::storeValueOfMove(unsigned int threadNo, unsigned int idPossibili
// Name: getValueOfMoves()
// Desc:
//-----------------------------------------------------------------------------
void perfectAI::getValueOfMoves(unsigned char *moveValue, unsigned int *freqValuesSubMoves, plyInfoVarType *plyInfo, unsigned int *moveQuality, unsigned char &knotValue, plyInfoVarType &bestAmountOfPlies)
void perfectAI::getValueOfMoves(unsigned char *moveValue, unsigned int *freqValuesSubMoves, PlyInfoVarType *plyInfo, unsigned int *moveQuality, unsigned char &knotValue, PlyInfoVarType &bestAmountOfPlies)
{
// locals
unsigned int moveQualities[fieldStruct::size * fieldStruct::size]; // 0 is bad, 1 is good
@ -1375,7 +1375,7 @@ void perfectAI::getValueOfMoves(unsigned char *moveValue, unsigned int *freqValu
// copy
memcpy(moveQuality, moveQualities, sizeof(unsigned int) * fieldStruct::size * fieldStruct::size);
memcpy(plyInfo, plyInfoForOutput, sizeof(plyInfoVarType) * fieldStruct::size * fieldStruct::size);
memcpy(plyInfo, plyInfoForOutput, sizeof(PlyInfoVarType) * fieldStruct::size * fieldStruct::size);
memcpy(moveValue, valueOfMove, sizeof(unsigned char) * fieldStruct::size * fieldStruct::size);
memcpy(freqValuesSubMoves, incidencesValuesSubMoves, sizeof(unsigned int) * fieldStruct::size * fieldStruct::size * 4);
}
@ -1388,7 +1388,7 @@ void perfectAI::printMoveInformation(unsigned int threadNo, unsigned int idPossi
{
// locals
threadVarsStruct *tv = &threadVars[threadNo];
possibilityStruct *tmpPossibility = (possibilityStruct *)pPossibilities;
Possibility *tmpPossibility = (Possibility *)pPossibilities;
// move
if (tv->field->stoneMustBeRemoved) cout << "remove stone from " << (char)(idPossibility + 97);
@ -2028,7 +2028,7 @@ bool perfectAI::isSymOperationInvariantOnGroupCD(unsigned int symmetryOperation,
// Name: storePredecessor()
// Desc:
//-----------------------------------------------------------------------------
void perfectAI::threadVarsStruct::storePredecessor(unsigned int numberOfMillsCurrentPlayer, unsigned int numberOfMillsOpponentPlayer, unsigned int *amountOfPred, retroAnalysisPredVars *predVars)
void perfectAI::threadVarsStruct::storePredecessor(unsigned int numberOfMillsCurrentPlayer, unsigned int numberOfMillsOpponentPlayer, unsigned int *amountOfPred, RetroAnalysisPredVars *predVars)
{
// locals
int originalField[fieldStruct::size];
@ -2072,7 +2072,7 @@ void perfectAI::threadVarsStruct::storePredecessor(unsigned int numberOfMillsCur
// Name: getPredecessors()
// Desc: CAUTION: States musn't be returned twice.
//-----------------------------------------------------------------------------
void perfectAI::getPredecessors(unsigned int threadNo, unsigned int *amountOfPred, retroAnalysisPredVars *predVars)
void perfectAI::getPredecessors(unsigned int threadNo, unsigned int *amountOfPred, RetroAnalysisPredVars *predVars)
{
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// the important variables, which much be updated for the getLayerAndStateNumber function are the following ones:
@ -2397,7 +2397,7 @@ bool perfectAI::checkGetPossThanGetPred()
bool isOpponentLevel;
void *pPossibilities;
void *pBackup;
retroAnalysisPredVars predVars[MAX_NUM_PREDECESSORS];
RetroAnalysisPredVars predVars[MAX_NUM_PREDECESSORS];
unsigned int threadNo = 0;
threadVarsStruct *tv = &threadVars[threadNo];
@ -2480,7 +2480,7 @@ bool perfectAI::checkGetPredThanGetPoss()
void *pPossibilities;
void *pBackup;
int symField[fieldStruct::size];
retroAnalysisPredVars predVars[MAX_NUM_PREDECESSORS];
RetroAnalysisPredVars predVars[MAX_NUM_PREDECESSORS];
// test if each predecessor from getPredecessors() leads to the original state using getPossibilities()
for (layerNum = 0; layerNum < NUM_LAYERS; layerNum++) {

View File

@ -98,16 +98,16 @@ protected:
subLayerStruct subLayer[MAX_NUM_SUB_LAYERS];
};
struct possibilityStruct
struct Possibility
{
unsigned int from[MAX_NUM_POS_MOVES];
unsigned int to[MAX_NUM_POS_MOVES];
};
struct backupStruct
struct Backup
{
float floatValue;
twoBit shortValue;
TwoBit shortValue;
bool gameHasFinished;
bool settingPhase;
int fieldFrom, fieldTo; // value of board
@ -154,14 +154,14 @@ protected:
public:
fieldStruct *field; // pointer of the current board [changed by move()]
float floatValue; // value of current situation for board->currentPlayer
twoBit shortValue; // ''
TwoBit shortValue; // ''
bool gameHasFinished; // someone has won or current board is full
int ownId; // id of the player who called the play()-function
unsigned int curSearchDepth; // current level
unsigned int depthOfFullTree; // search depth where the whole tree is explored
unsigned int *idPossibilities; // returned pointer of getPossibilities()-function
backupStruct *oldStates; // for undo()-function
possibilityStruct *possibilities; // for getPossNormalMove()-function
Backup *oldStates; // for undo()-function
Possibility *possibilities; // for getPossNormalMove()-function
perfectAI *parent; //
// constructor
@ -176,16 +176,16 @@ protected:
inline void updatePossibleMoves(unsigned int stone, Player *stoneOwner, bool stoneRemoved, unsigned int ignoreStone);
inline void updateWarning(unsigned int firstStone, unsigned int secondStone);
inline void setWarning(unsigned int stoneOne, unsigned int stoneTwo, unsigned int stoneThree);
inline void removeStone(unsigned int from, backupStruct *backup);
inline void setStone(unsigned int to, backupStruct *backup);
inline void normalMove(unsigned int from, unsigned int to, backupStruct *backup);
inline void removeStone(unsigned int from, Backup *backup);
inline void setStone(unsigned int to, Backup *backup);
inline void normalMove(unsigned int from, unsigned int to, Backup *backup);
// database functions
unsigned int getLayerAndStateNumber(unsigned int &layerNum, unsigned int &stateNumber);
void setWarningAndMill(unsigned int stone, unsigned int firstNeighbour, unsigned int secondNeighbour);
bool fieldIntegrityOK(unsigned int numberOfMillsCurrentPlayer, unsigned int numberOfMillsOpponentPlayer, bool aStoneCanBeRemovedFromCurPlayer);
void calcPossibleMoves(Player *player);
void storePredecessor(unsigned int numberOfMillsCurrentPlayer, unsigned int numberOfMillsOpponentPlayer, unsigned int *amountOfPred, retroAnalysisPredVars *predVars);
void storePredecessor(unsigned int numberOfMillsCurrentPlayer, unsigned int numberOfMillsOpponentPlayer, unsigned int *amountOfPred, RetroAnalysisPredVars *predVars);
};
threadVarsStruct *threadVars;
@ -197,7 +197,7 @@ protected:
bool isSymOperationInvariantOnGroupCD(unsigned int symmetryOperation, int *theField);
bool shallRetroAnalysisBeUsed(unsigned int layerNum);
void getSuccLayers(unsigned int layerNum, unsigned int *amountOfSuccLayers, unsigned int *succLayers);
void getPredecessors(unsigned int threadNo, unsigned int *amountOfPred, retroAnalysisPredVars *predVars);
void getPredecessors(unsigned int threadNo, unsigned int *amountOfPred, RetroAnalysisPredVars *predVars);
bool setSituation(unsigned int threadNo, unsigned int layerNum, unsigned int stateNumber);
unsigned int getLayerNumber(unsigned int threadNo);
unsigned int getLayerAndStateNumber(unsigned int threadNo, unsigned int &layerNum, unsigned int &stateNumber);
@ -209,7 +209,7 @@ protected:
// Virtual Functions
void prepareBestChoiceCalculation();
void getValueOfSituation(unsigned int threadNo, float &floatValue, twoBit &shortValue);
void getValueOfSituation(unsigned int threadNo, float &floatValue, TwoBit &shortValue);
void setOpponentLevel(unsigned int threadNo, bool isOpponentLevel);
bool getOpponentLevel(unsigned int threadNo);
void deletePossibilities(unsigned int threadNo, void *pPossibilities);
@ -217,7 +217,7 @@ protected:
void undo(unsigned int threadNo, unsigned int idPossibility, bool opponentsMove, void *pBackup, void *pPossibilities);
void move(unsigned int threadNo, unsigned int idPossibility, bool opponentsMove, void **pBackup, void *pPossibilities);
void printMoveInformation(unsigned int threadNo, unsigned int idPossibility, void *pPossibilities);
void storeValueOfMove(unsigned int threadNo, unsigned int idPossibility, void *pPossibilities, unsigned char value, unsigned int *freqValuesSubMoves, plyInfoVarType plyInfo);
void storeValueOfMove(unsigned int threadNo, unsigned int idPossibility, void *pPossibilities, unsigned char value, unsigned int *freqValuesSubMoves, PlyInfoVarType plyInfo);
void getSymStateNumWithDoubles(unsigned int threadNo, unsigned int *numSymmetricStates, unsigned int **symStateNumbers);
void printField(unsigned int threadNo, unsigned char value);
string getOutputInformation(unsigned int layerNum);
@ -233,7 +233,7 @@ public:
// Functions
bool setDatabasePath(const char *directory);
void play(fieldStruct *theField, unsigned int *pushFrom, unsigned int *pushTo);
void getValueOfMoves(unsigned char *moveValue, unsigned int *freqValuesSubMoves, plyInfoVarType *plyInfo, unsigned int *moveQuality, unsigned char &knotValue, plyInfoVarType &bestAmountOfPlies);
void getValueOfMoves(unsigned char *moveValue, unsigned int *freqValuesSubMoves, PlyInfoVarType *plyInfo, unsigned int *moveQuality, unsigned char &knotValue, PlyInfoVarType &bestAmountOfPlies);
void getField(unsigned int layerNum, unsigned int stateNumber, fieldStruct *field, bool *gameHasFinished);
void getLayerAndStateNumber(unsigned int &layerNum, unsigned int &stateNumber);