perfect: Revert rename Knot to Node

This commit is contained in:
Calcitem 2021-01-20 01:45:22 +08:00
parent f74762d2c7
commit ba601557b2
4 changed files with 19 additions and 19 deletions

View File

@ -106,7 +106,7 @@ void *MiniMax::getBestChoice(unsigned int tilLevel, unsigned int *choice, unsign
calcDatabase = false;
// Locals
Node root;
Knot root;
AlphaBetaGlobalVars alphaBetaVars(this, getLayerNumber(0));
RunAlphaBetaVars tva(this, &alphaBetaVars, alphaBetaVars.layerNumber);
srand((unsigned int)time(nullptr));

View File

@ -186,7 +186,7 @@ public:
unsigned char layerNumber; // layer id
};
struct Node
struct Knot
{
bool isOpponentLevel; // the current considered knot belongs to an opponent game state
float floatValue; // Value of knot (for normal mode)
@ -195,7 +195,7 @@ public:
unsigned int bestBranch; // branch with highest value
unsigned int numPossibilities; // number of branches
PlyInfoVarType plyInfo; // number of moves till win/lost
Node *branches; // pointer to branches
Knot *branches; // pointer to branches
};
struct RetroAnalysisPredVars
@ -525,7 +525,7 @@ private:
struct RunAlphaBetaVars : public ThreadManager::ThreadVarsArrayItem, public AlphaBetaDefaultThreadVars
{
Node *branchArray = nullptr; // array of size [(depthOfFullTree - tilLevel) * maxNumBranches] for storage of the branches at each search depth
Knot *branchArray = nullptr; // array of size [(depthOfFullTree - tilLevel) * maxNumBranches] for storage of the branches at each search depth
unsigned int *freqValuesSubMovesBranchWon = nullptr; // ...
unsigned int freqValuesSubMoves[4]; // ...
@ -548,7 +548,7 @@ private:
void initializeElement(RunAlphaBetaVars &master)
{
*this = master;
branchArray = new Node[alphaBetaVars->pMiniMax->maxNumBranches * alphaBetaVars->pMiniMax->depthOfFullTree];
branchArray = new Knot[alphaBetaVars->pMiniMax->maxNumBranches * alphaBetaVars->pMiniMax->depthOfFullTree];
freqValuesSubMovesBranchWon = new unsigned int[alphaBetaVars->pMiniMax->maxNumBranches];
};
};
@ -732,12 +732,12 @@ private:
bool calcKnotValuesByAlphaBeta(unsigned int layerNumber);
bool initAlphaBeta(AlphaBetaGlobalVars &retroVars);
bool runAlphaBeta(AlphaBetaGlobalVars &retroVars);
void letTheTreeGrow(Node *knot, RunAlphaBetaVars *rabVars, unsigned int tilLevel, float alpha, float beta);
bool alphaBetaTryDataBase(Node *knot, RunAlphaBetaVars *rabVars, unsigned int tilLevel, unsigned int &layerNumber, unsigned int &stateNumber);
void alphaBetaTryPossibilites(Node *knot, RunAlphaBetaVars *rabVars, unsigned int tilLevel, unsigned int *idPossibility, void *pPossibilities, unsigned int &maxWonfreqValuesSubMoves, float &alpha, float &beta);
void alphaBetaCalcPlyInfo(Node *knot);
void alphaBetaCalcKnotValue(Node *knot);
void alphaBetaChooseBestMove(Node *knot, RunAlphaBetaVars *rabVars, unsigned int tilLevel, unsigned int *idPossibility, unsigned int maxWonfreqValuesSubMoves);
void letTheTreeGrow(Knot *knot, RunAlphaBetaVars *rabVars, unsigned int tilLevel, float alpha, float beta);
bool alphaBetaTryDataBase(Knot *knot, RunAlphaBetaVars *rabVars, unsigned int tilLevel, unsigned int &layerNumber, unsigned int &stateNumber);
void alphaBetaTryPossibilites(Knot *knot, RunAlphaBetaVars *rabVars, unsigned int tilLevel, unsigned int *idPossibility, void *pPossibilities, unsigned int &maxWonfreqValuesSubMoves, float &alpha, float &beta);
void alphaBetaCalcPlyInfo(Knot *knot);
void alphaBetaCalcKnotValue(Knot *knot);
void alphaBetaChooseBestMove(Knot *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);
static DWORD initAlphaBetaThreadProc(void *pParameter, int index);
static DWORD runAlphaBetaThreadProc(void *pParameter, int index);

View File

@ -277,7 +277,7 @@ DWORD MiniMax::runAlphaBetaThreadProc(void *pParameter, int index)
RunAlphaBetaVars *rabVars = (RunAlphaBetaVars *)pParameter;
MiniMax *m = rabVars->pMiniMax;
StateAdress curState; // current state counter for loops
Node root; //
Knot root; //
PlyInfoVarType plyInfo; // depends on the curStateValue
curState.layerNumber = rabVars->layerNumber;
@ -311,7 +311,7 @@ DWORD MiniMax::runAlphaBetaThreadProc(void *pParameter, int index)
// Name: letTheTreeGrow()
// Desc:
//-----------------------------------------------------------------------------
void MiniMax::letTheTreeGrow(Node *knot, RunAlphaBetaVars *rabVars, unsigned int tilLevel, float alpha, float beta)
void MiniMax::letTheTreeGrow(Knot *knot, RunAlphaBetaVars *rabVars, unsigned int tilLevel, float alpha, float beta)
{
// Locals
void *pPossibilities;
@ -397,7 +397,7 @@ void MiniMax::letTheTreeGrow(Node *knot, RunAlphaBetaVars *rabVars, unsigned int
// 2 - Look into database if knot value and ply info are already calculated. If so sets knot->shortValue, knot->floatValue and knot->plyInfo.
// CAUTION: knot->isOpponentLevel must be set and valid.
//-----------------------------------------------------------------------------
bool MiniMax::alphaBetaTryDataBase(Node *knot, RunAlphaBetaVars *rabVars, unsigned int tilLevel, unsigned int &layerNumber, unsigned int &stateNumber)
bool MiniMax::alphaBetaTryDataBase(Knot *knot, RunAlphaBetaVars *rabVars, unsigned int tilLevel, unsigned int &layerNumber, unsigned int &stateNumber)
{
// locals
bool invalidLayerOrStateNumber;
@ -446,7 +446,7 @@ bool MiniMax::alphaBetaTryDataBase(Node *knot, RunAlphaBetaVars *rabVars, unsign
// Name: alphaBetaTryPossibilites()
// Desc:
//-----------------------------------------------------------------------------
void MiniMax::alphaBetaTryPossibilites(Node *knot, RunAlphaBetaVars *rabVars, unsigned int tilLevel, unsigned int *idPossibility, void *pPossibilities, unsigned int &maxWonfreqValuesSubMoves, float &alpha, float &beta)
void MiniMax::alphaBetaTryPossibilites(Knot *knot, RunAlphaBetaVars *rabVars, unsigned int tilLevel, unsigned int *idPossibility, void *pPossibilities, unsigned int &maxWonfreqValuesSubMoves, float &alpha, float &beta)
{
// locals
void *pBackup;
@ -524,7 +524,7 @@ void MiniMax::alphaBetaTryPossibilites(Node *knot, RunAlphaBetaVars *rabVars, un
// Name: alphaBetaCalcKnotValue()
// Desc:
//-----------------------------------------------------------------------------
void MiniMax::alphaBetaCalcKnotValue(Node *knot)
void MiniMax::alphaBetaCalcKnotValue(Knot *knot)
{
// locals
float maxValue = knot->branches[0].floatValue;
@ -559,7 +559,7 @@ void MiniMax::alphaBetaCalcKnotValue(Node *knot)
// Name: alphaBetaCalcPlyInfo()
// Desc:
//-----------------------------------------------------------------------------
void MiniMax::alphaBetaCalcPlyInfo(Node *knot)
void MiniMax::alphaBetaCalcPlyInfo(Knot *knot)
{
// locals
unsigned int i;
@ -627,7 +627,7 @@ void MiniMax::alphaBetaCalcPlyInfo(Node *knot)
// Name: alphaBetaChooseBestMove()
// Desc: select randomly one of the best moves, if they are equivalent
//-----------------------------------------------------------------------------
void MiniMax::alphaBetaChooseBestMove(Node *knot, RunAlphaBetaVars *rabVars, unsigned int tilLevel, unsigned int *idPossibility, unsigned int maxWonfreqValuesSubMoves)
void MiniMax::alphaBetaChooseBestMove(Knot *knot, RunAlphaBetaVars *rabVars, unsigned int tilLevel, unsigned int *idPossibility, unsigned int maxWonfreqValuesSubMoves)
{
// locals
float dif;

View File

@ -423,7 +423,7 @@ DWORD MiniMax::testSetSituationThreadProc(void *pParameter, int index)
float floatValue;
StateAdress curState;
StateAdress subState;
Node knot;
Knot knot;
TwoBit shortKnotValue = SKV_VALUE_GAME_DRAWN;
curState.layerNumber = tlVars->layerNumber;
curState.stateNumber = index;