perfect: Rename functions name

This commit is contained in:
Calcitem 2021-01-20 01:22:17 +08:00
parent 4761897750
commit cc80e84dbe
10 changed files with 74 additions and 74 deletions

View File

@ -36,8 +36,8 @@ CyclicArray::CyclicArray(unsigned int blockSizeInBytes, unsigned int numberOfBlo
}
//-----------------------------------------------------------------------------
// Name: ~randomAI()
// Desc: randomAI class destructor
// Name: ~RandomAI()
// Desc: RandomAI class destructor
//-----------------------------------------------------------------------------
CyclicArray::~CyclicArray()
{

View File

@ -455,7 +455,7 @@ private:
};
};
struct InitAlphaBetaVars : public threadManagerClass::threadVarsArrayItem, public AlphaBetaDefaultThreadVars
struct InitAlphaBetaVars : public ThreadManager::ThreadVarsArrayItem, public AlphaBetaDefaultThreadVars
{
BufferedFile *bufferedFile;
bool initAlreadyDone;
@ -478,7 +478,7 @@ private:
};
};
struct RunAlphaBetaVars : public threadManagerClass::threadVarsArrayItem, public AlphaBetaDefaultThreadVars
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
unsigned int *freqValuesSubMovesBranchWon = nullptr; // ...
@ -565,7 +565,7 @@ private:
};
};
struct InitRetroAnalysisVars : public threadManagerClass::threadVarsArrayItem, public RetroAnalysisDefaultThreadVars
struct InitRetroAnalysisVars : public ThreadManager::ThreadVarsArrayItem, public RetroAnalysisDefaultThreadVars
{
BufferedFile *bufferedFile;
bool initAlreadyDone;
@ -588,7 +588,7 @@ private:
};
};
struct AddNumSuccedorsVars : public threadManagerClass::threadVarsArrayItem, public RetroAnalysisDefaultThreadVars
struct AddNumSuccedorsVars : public ThreadManager::ThreadVarsArrayItem, public RetroAnalysisDefaultThreadVars
{
RetroAnalysisPredVars predVars[MAX_NUM_PREDECESSORS];
@ -625,7 +625,7 @@ private:
vector<unsigned int> layersToCalculate; // used in calcLayer() and getCurrentCalculatedLayers()
bool onlyPrepareLayer = false; //
bool stopOnCriticalError = true; // if true then process will stay in while loop
threadManagerClass threadManager; //
ThreadManager threadManager; //
CRITICAL_SECTION csDatabase; //
CRITICAL_SECTION csOsPrint; // for thread safety when output is passed to osPrint
void (*userPrintFunc)(void *) = nullptr; // called every time output is passed to osPrint

View File

@ -111,7 +111,7 @@ bool MiniMax::initAlphaBeta(AlphaBetaGlobalVars &alphaBetaVars)
alphaBetaVars.statsValueCounter[SKV_VALUE_GAME_LOST] = 0;
alphaBetaVars.statsValueCounter[SKV_VALUE_GAME_DRAWN] = 0;
alphaBetaVars.statsValueCounter[SKV_VALUE_INVALID] = 0;
threadManagerClass::threadVarsArray<InitAlphaBetaVars> tva(threadManager.getNumThreads(), InitAlphaBetaVars(this, &alphaBetaVars, alphaBetaVars.layerNumber, invalidArray, initAlreadyDone));
ThreadManager::ThreadVarsArray<InitAlphaBetaVars> tva(threadManager.getNumThreads(), InitAlphaBetaVars(this, &alphaBetaVars, alphaBetaVars.layerNumber, invalidArray, initAlreadyDone));
// process each state in the current layer
switch (threadManager.executeParallelLoop(initAlphaBetaThreadProc, tva.getPointerToArray(), tva.getSizeOfArray(), TM_SCHEDULE_STATIC, 0, layerStats[alphaBetaVars.layerNumber].knotsInLayer - 1, 1)) {
@ -228,7 +228,7 @@ bool MiniMax::runAlphaBeta(AlphaBetaGlobalVars &alphaBetaVars)
alphaBetaVars.statsValueCounter[SKV_VALUE_GAME_LOST] = 0;
alphaBetaVars.statsValueCounter[SKV_VALUE_GAME_DRAWN] = 0;
alphaBetaVars.statsValueCounter[SKV_VALUE_INVALID] = 0;
threadManagerClass::threadVarsArray<RunAlphaBetaVars> tva(threadManager.getNumThreads(), RunAlphaBetaVars(this, &alphaBetaVars, alphaBetaVars.layerNumber));
ThreadManager::ThreadVarsArray<RunAlphaBetaVars> tva(threadManager.getNumThreads(), RunAlphaBetaVars(this, &alphaBetaVars, alphaBetaVars.layerNumber));
// so far no multi-threadin implemented
threadManager.setNumThreads(1);

View File

@ -145,7 +145,7 @@ bool MiniMax::initRetroAnalysis(retroAnalysisGlobalVars &retroVars)
retroVars.statsValueCounter[SKV_VALUE_GAME_LOST] = 0;
retroVars.statsValueCounter[SKV_VALUE_GAME_DRAWN] = 0;
retroVars.statsValueCounter[SKV_VALUE_INVALID] = 0;
threadManagerClass::threadVarsArray<InitRetroAnalysisVars> tva(threadManager.getNumThreads(), InitRetroAnalysisVars(this, &retroVars, layerNumber, initArray, initAlreadyDone));
ThreadManager::ThreadVarsArray<InitRetroAnalysisVars> tva(threadManager.getNumThreads(), InitRetroAnalysisVars(this, &retroVars, layerNumber, initArray, initAlreadyDone));
// process each state in the current layer
switch (threadManager.executeParallelLoop(initRetroAnalysisThreadProc, tva.getPointerToArray(), tva.getSizeOfArray(), TM_SCHEDULE_STATIC, 0, layerStats[layerNumber].knotsInLayer - 1, 1)) {
@ -360,7 +360,7 @@ bool MiniMax::calcNumSuccedors(retroAnalysisGlobalVars &retroVars)
// prepare parameters for multithreading
succCalculated[layerNumber] = true;
numStatesProcessed = 0;
threadManagerClass::threadVarsArray<AddNumSuccedorsVars> tva(threadManager.getNumThreads(), AddNumSuccedorsVars(this, &retroVars, layerNumber));
ThreadManager::ThreadVarsArray<AddNumSuccedorsVars> tva(threadManager.getNumThreads(), AddNumSuccedorsVars(this, &retroVars, layerNumber));
// process each state in the current layer
switch (threadManager.executeParallelLoop(addNumSuccedorsThreadProc, tva.getPointerToArray(), tva.getSizeOfArray(), TM_SCHEDULE_STATIC, 0, layerStats[layerNumber].knotsInLayer - 1, 1)) {
@ -402,7 +402,7 @@ bool MiniMax::calcNumSuccedors(retroAnalysisGlobalVars &retroVars)
// prepare parameters for multithreading
numStatesProcessed = 0;
threadManagerClass::threadVarsArray<AddNumSuccedorsVars> tva(threadManager.getNumThreads(), AddNumSuccedorsVars(this, &retroVars, succState.layerNumber));
ThreadManager::ThreadVarsArray<AddNumSuccedorsVars> tva(threadManager.getNumThreads(), AddNumSuccedorsVars(this, &retroVars, succState.layerNumber));
// process each state in the current layer
switch (threadManager.executeParallelLoop(addNumSuccedorsThreadProc, tva.getPointerToArray(), tva.getSizeOfArray(), TM_SCHEDULE_STATIC, 0, layerStats[succState.layerNumber].knotsInLayer - 1, 1)) {

View File

@ -1,5 +1,5 @@
/*********************************************************************
randomAI.cpp
RandomAI.cpp
Copyright (c) Thomas Weber. All rights reserved.
Copyright (C) 2021 The Sanmill developers (see AUTHORS file)
Licensed under the MIT License.
@ -9,20 +9,20 @@
#include "randomAI.h"
//-----------------------------------------------------------------------------
// Name: randomAI()
// Desc: randomAI class constructor
// Name: RandomAI()
// Desc: RandomAI class constructor
//-----------------------------------------------------------------------------
randomAI::randomAI()
RandomAI::RandomAI()
{
// Init
srand((unsigned)time(nullptr));
}
//-----------------------------------------------------------------------------
// Name: ~randomAI()
// Desc: randomAI class destructor
// Name: ~RandomAI()
// Desc: RandomAI class destructor
//-----------------------------------------------------------------------------
randomAI::~randomAI()
RandomAI::~RandomAI()
{
// Locals
@ -32,7 +32,7 @@ randomAI::~randomAI()
// Name: play()
// Desc:
//-----------------------------------------------------------------------------
void randomAI::play(fieldStruct *theField, unsigned int *pushFrom, unsigned int *pushTo)
void RandomAI::play(fieldStruct *theField, unsigned int *pushFrom, unsigned int *pushTo)
{
// locals
unsigned int from, to, direction;

View File

@ -1,5 +1,5 @@
/*********************************************************************\
randomAI.h
RandomAI.h
Copyright (c) Thomas Weber. All rights reserved.
Copyright (C) 2021 The Sanmill developers (see AUTHORS file)
Licensed under the MIT License.
@ -15,12 +15,12 @@
/*** Klassen *********************************************************/
class randomAI : public MillAI
class RandomAI : public MillAI
{
public:
// Constructor / destructor
randomAI();
~randomAI();
RandomAI();
~RandomAI();
// Functions
void play(fieldStruct *theField, unsigned int *pushFrom, unsigned int *pushTo);

View File

@ -12,7 +12,7 @@
// Name: hibit()
// Desc:
//-----------------------------------------------------------------------------
int mystring::hibit(unsigned int n)
int MyString::hibit(unsigned int n)
{
n |= (n >> 1);
n |= (n >> 2);
@ -23,36 +23,36 @@ int mystring::hibit(unsigned int n)
}
//-----------------------------------------------------------------------------
// Name: mystring()
// Name: MyString()
// Desc:
//-----------------------------------------------------------------------------
mystring::mystring()
MyString::MyString()
{
}
//-----------------------------------------------------------------------------
// Name: mystring()
// Name: MyString()
// Desc:
//-----------------------------------------------------------------------------
mystring::mystring(const char *cStr)
MyString::MyString(const char *cStr)
{
assign(cStr);
}
//-----------------------------------------------------------------------------
// Name: mystring()
// Name: MyString()
// Desc:
//-----------------------------------------------------------------------------
mystring::mystring(const WCHAR *cStr)
MyString::MyString(const WCHAR *cStr)
{
assign(cStr);
}
//-----------------------------------------------------------------------------
// Name: mystring()
// Name: MyString()
// Desc:
//-----------------------------------------------------------------------------
mystring::~mystring()
MyString::~MyString()
{
if (strA != nullptr) {
delete[] strA; strA = nullptr;
@ -70,7 +70,7 @@ mystring::~mystring()
// Name: c_strA()
// Desc:
//-----------------------------------------------------------------------------
const char *mystring::c_strA()
const char *MyString::c_strA()
{
return strA;
}
@ -79,7 +79,7 @@ const char *mystring::c_strA()
// Name: c_strW()
// Desc:
//-----------------------------------------------------------------------------
const WCHAR *mystring::c_strW()
const WCHAR *MyString::c_strW()
{
return strW;
}
@ -88,14 +88,14 @@ const WCHAR *mystring::c_strW()
// Name: assign()
// Desc:
//-----------------------------------------------------------------------------
mystring &mystring::assign(const char *cStr)
MyString &MyString::assign(const char *cStr)
{
// locals
size_t convertedChars = 0;
size_t newLength = strlen(cStr);
size_t newReserved = (size_t)hibit((unsigned int)newLength) * 2;
if (reserved < newReserved) this->~mystring();
if (reserved < newReserved) this->~MyString();
if (strA == nullptr) strA = new char[newReserved];
if (strW == nullptr) strW = new WCHAR[newReserved];
@ -112,14 +112,14 @@ mystring &mystring::assign(const char *cStr)
// Name: assign()
// Desc:
//-----------------------------------------------------------------------------
mystring &mystring::assign(const WCHAR *cStr)
MyString &MyString::assign(const WCHAR *cStr)
{
// locals
size_t returnValue;
size_t newLength = wcslen(cStr);
size_t newReserved = (size_t)hibit((unsigned int)newLength) * 2;
if (reserved < newReserved) this->~mystring();
if (reserved < newReserved) this->~MyString();
if (strA == nullptr) strA = new char[newReserved];
if (strW == nullptr) strW = new WCHAR[newReserved];

View File

@ -21,7 +21,7 @@ using namespace std;
// general functions
bool readAsciiData(HANDLE hFile, double *pData, unsigned int numValues, unsigned char decimalSeperator, unsigned char columnSeparator);
class mystring
class MyString
{
private:
@ -36,15 +36,15 @@ private:
public:
// functions
mystring();
mystring(const char *cStr);
mystring(const WCHAR *cStr);
~mystring();
MyString();
MyString(const char *cStr);
MyString(const WCHAR *cStr);
~MyString();
const char *c_strA();
const WCHAR *c_strW();
mystring &assign(const char *cStr);
mystring &assign(const WCHAR *cStr);
MyString &assign(const char *cStr);
MyString &assign(const WCHAR *cStr);
static int hibit(unsigned int n);
};

View File

@ -9,10 +9,10 @@
#include "threadManager.h"
//-----------------------------------------------------------------------------
// Name: threadManagerClass()
// Desc: threadManagerClass class constructor
// Name: ThreadManager()
// Desc: ThreadManager class constructor
//-----------------------------------------------------------------------------
threadManagerClass::threadManagerClass()
ThreadManager::ThreadManager()
{
// locals
unsigned int curThreadNo;
@ -40,10 +40,10 @@ threadManagerClass::threadManagerClass()
}
//-----------------------------------------------------------------------------
// Name: ~threadManagerClass()
// Desc: threadManagerClass class destructor
// Name: ~ThreadManager()
// Desc: ThreadManager class destructor
//-----------------------------------------------------------------------------
threadManagerClass::~threadManagerClass()
ThreadManager::~ThreadManager()
{
// locals
unsigned int curThreadNo;
@ -64,7 +64,7 @@ threadManagerClass::~threadManagerClass()
// Name: waitForOtherThreads()
// Desc:
//-----------------------------------------------------------------------------
void threadManagerClass::waitForOtherThreads(unsigned int threadNo)
void ThreadManager::waitForOtherThreads(unsigned int threadNo)
{
// wait if other threads are still waiting at the barrier
//cout << endl << "thread=" << threadNo << ", numThreadsPassedBarrier= " << numThreadsPassedBarrier << ": " << "while (numThreadsPassedBarrier>0)";
@ -108,7 +108,7 @@ void threadManagerClass::waitForOtherThreads(unsigned int threadNo)
// Name: getNumThreads()
// Desc:
//-----------------------------------------------------------------------------
unsigned int threadManagerClass::getNumThreads()
unsigned int ThreadManager::getNumThreads()
{
return numThreads;
}
@ -117,7 +117,7 @@ unsigned int threadManagerClass::getNumThreads()
// Name: setNumThreads()
// Desc:
//-----------------------------------------------------------------------------
bool threadManagerClass::setNumThreads(unsigned int newNumThreads)
bool ThreadManager::setNumThreads(unsigned int newNumThreads)
{
// cancel if any thread running
EnterCriticalSection(&csBarrier);
@ -139,7 +139,7 @@ bool threadManagerClass::setNumThreads(unsigned int newNumThreads)
// Name: pauseExecution()
// Desc:
//-----------------------------------------------------------------------------
void threadManagerClass::pauseExecution()
void ThreadManager::pauseExecution()
{
for (unsigned int curThread = 0; curThread < numThreads; curThread++) {
@ -159,7 +159,7 @@ void threadManagerClass::pauseExecution()
// Desc: Stops executeParallelLoop() before the next iteration.
// When executeInParallel() was called, user has to handle cancellation by himself.
//-----------------------------------------------------------------------------
void threadManagerClass::cancelExecution()
void ThreadManager::cancelExecution()
{
termineAllThreads = true;
executionCancelled = true;
@ -172,7 +172,7 @@ void threadManagerClass::cancelExecution()
// Name: uncancelExecution()
// Desc:
//-----------------------------------------------------------------------------
void threadManagerClass::uncancelExecution()
void ThreadManager::uncancelExecution()
{
executionCancelled = false;
}
@ -181,7 +181,7 @@ void threadManagerClass::uncancelExecution()
// Name: wasExecutionCancelled()
// Desc:
//-----------------------------------------------------------------------------
bool threadManagerClass::wasExecutionCancelled()
bool ThreadManager::wasExecutionCancelled()
{
return executionCancelled;
}
@ -190,7 +190,7 @@ bool threadManagerClass::wasExecutionCancelled()
// Name: getThreadId()
// Desc: Returns a number from 0 to 'numThreads'-1. Returns 0 if the function fails.
//-----------------------------------------------------------------------------
unsigned int threadManagerClass::getThreadNumber()
unsigned int ThreadManager::getThreadNumber()
{
// locals
DWORD curThreadId = GetCurrentThreadId();
@ -208,7 +208,7 @@ unsigned int threadManagerClass::getThreadNumber()
// Name: executeInParallel()
// Desc: lpParameter is an array of size numThreads.
//-----------------------------------------------------------------------------
unsigned int threadManagerClass::executeInParallel(DWORD threadProc(void *pParameter), void *pParameter, unsigned int parameterStructSize)
unsigned int ThreadManager::executeInParallel(DWORD threadProc(void *pParameter), void *pParameter, unsigned int parameterStructSize)
{
// locals
unsigned int curThreadNo;
@ -264,7 +264,7 @@ unsigned int threadManagerClass::executeInParallel(DWORD threadProc(void *pPara
// lpParameter - an array of size numThreads
// finalValue - this value is part of the iteration, meaning that index ranges from initialValue to finalValue including both border values
//-----------------------------------------------------------------------------
unsigned int threadManagerClass::executeParallelLoop(DWORD threadProc(void *pParameter, int index),
unsigned int ThreadManager::executeParallelLoop(DWORD threadProc(void *pParameter, int index),
void *pParameter,
unsigned int parameterStructSize,
unsigned int scheduleType,
@ -284,7 +284,7 @@ unsigned int threadManagerClass::executeParallelLoop(DWORD threadProc(void *p
int numIterations = (finalValue - initialValue) / inkrement + 1; // total number of iterations
int chunkSize = 0; // number of iterations per chunk
SIZE_T dwStackSize = 0; // initital stack size of each thread. 0 means default size ~1MB
forLoopStruct *forLoopParameters = new forLoopStruct[numThreads]; //
ForLoop *forLoopParameters = new ForLoop[numThreads]; //
// globals
termineAllThreads = false;
@ -361,10 +361,10 @@ unsigned int threadManagerClass::executeParallelLoop(DWORD threadProc(void *p
// Name: threadForLoop()
// Desc:
//-----------------------------------------------------------------------------
DWORD WINAPI threadManagerClass::threadForLoop(LPVOID lpParameter)
DWORD WINAPI ThreadManager::threadForLoop(LPVOID lpParameter)
{
// locals
forLoopStruct *forLoopParameters = (forLoopStruct *)lpParameter;
ForLoop *forLoopParameters = (ForLoop *)lpParameter;
int index;
switch (forLoopParameters->scheduleType) {

View File

@ -36,12 +36,12 @@ using namespace std; // use standard library namespace
/*** Klassen *********************************************************/
class threadManagerClass
class ThreadManager
{
private:
// structures
struct forLoopStruct
struct ForLoop
{
unsigned int scheduleType;
int inkrement;
@ -49,7 +49,7 @@ private:
int finalValue;
void *pParameter;
DWORD(*threadProc)(void *pParameter, int index); // pointer to the user function to be executed by the threads
threadManagerClass *threadManager;
ThreadManager *threadManager;
};
// Variables
@ -71,7 +71,7 @@ private:
public:
class threadVarsArrayItem
class ThreadVarsArrayItem
{
public:
unsigned int curThreadNo;
@ -87,13 +87,13 @@ public:
};
};
template <class varType> class threadVarsArray
template <class varType> class ThreadVarsArray
{
public:
unsigned int numberOfThreads;
varType *item;
threadVarsArray(unsigned int numberOfThreads, varType &master)
ThreadVarsArray(unsigned int numberOfThreads, varType &master)
{
this->numberOfThreads = numberOfThreads;
this->item = new varType[numberOfThreads];
@ -105,7 +105,7 @@ public:
}
};
~threadVarsArray()
~ThreadVarsArray()
{
for (unsigned int threadCounter = 0; threadCounter < numberOfThreads; threadCounter++) {
item[threadCounter].destroyElement();
@ -132,8 +132,8 @@ public:
};
// Constructor / destructor
threadManagerClass();
~threadManagerClass();
ThreadManager();
~ThreadManager();
// Functions
unsigned int getThreadNumber();