noexception

This commit is contained in:
Calcitem 2021-11-06 22:51:57 +08:00
parent f979986701
commit d65b3ea523
No known key found for this signature in database
GPG Key ID: F67E4F8CB7B5EED2
12 changed files with 55 additions and 55 deletions

View File

@ -45,7 +45,7 @@ const std::string Bitboards::pretty(Bitboard b)
/// Bitboards::init() initializes various bitboard tables. It is called at
/// startup and relies on global objects to be already zero-initialized.
void Bitboards::init()
void Bitboards::init() noexcept
{
for (unsigned i = 0; i < (1 << 16); ++i)
PopCnt16[i] = (uint8_t)std::bitset<16>(i).count();

View File

@ -33,7 +33,7 @@
namespace Bitboards {
void init();
void init() noexcept;
const std::string pretty(Bitboard b);
}

View File

@ -148,7 +148,7 @@ public:
}
// Function to clean up the hasp map, i.e., remove all entries from it
void clear()
void clear() noexcept
{
#ifdef DISABLE_HASHBUCKET
memset(hashTable, 0, sizeof(HashNode<K, V>) * hashSize);

View File

@ -608,7 +608,7 @@ void MiniMaxAI::move(unsigned int threadNo, unsigned int idPossibility, bool opp
// printMoveInformation()
//
//-----------------------------------------------------------------------------
void MiniMaxAI::printMoveInformation(unsigned int threadNo, unsigned int idPossibility, void* pPossibilities) noexcept
void MiniMaxAI::printMoveInformation(unsigned int threadNo, unsigned int idPossibility, void* pPossibilities)
{
// locals
Possibility* tmpPossibility = (Possibility*)pPossibilities;

View File

@ -249,20 +249,20 @@ public:
// Statistics
bool calcLayerStatistics(char* statisticsFileName);
void showMemoryStatus();
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);
bool isLayerInDatabase(unsigned int layerNum);
long long getLayerSizeInBytes(unsigned int layerNum);
void setOutputStream(ostream* theStream, void (*printFunc)(void* pUserData), void* pUserData);
bool anyArrayInfoToUpdate();
ArrayInfoChange getArrayInfoForUpdate();
unsigned int getNumThreads() noexcept;
bool anyFreshlyCalculatedLayer() noexcept;
unsigned int getLastCalculatedLayer() noexcept;
StateNumberVarType getNumWonStates(unsigned int layerNum) noexcept;
StateNumberVarType getNumLostStates(unsigned int layerNum) noexcept;
StateNumberVarType getNumDrawnStates(unsigned int layerNum) noexcept;
StateNumberVarType getNumInvalidStates(unsigned int layerNum) noexcept;
bool isLayerInDatabase(unsigned int layerNum) noexcept;
long long getLayerSizeInBytes(unsigned int layerNum) noexcept;
void setOutputStream(ostream* theStream, void (*printFunc)(void* pUserData), void* pUserData) noexcept;
bool anyArrayInfoToUpdate() noexcept;
ArrayInfoChange getArrayInfoForUpdate() noexcept;
void getCurrentCalculatedLayer(vector<unsigned int>& layers);
LPWSTR getCurrentActionStr();
LPWSTR getCurrentActionStr() noexcept;
// Main function for getting the best choice
void* getBestChoice(unsigned int tilLevel, unsigned int* choice, unsigned int maximumNumberOfBranches);
@ -288,7 +288,7 @@ public:
virtual unsigned int* getPossibilities(unsigned int threadNo,
unsigned int* numPossibilities,
bool* opponentsMove,
void** pPossibilities) noexcept
void** pPossibilities)
{
while (true)
;
@ -422,13 +422,13 @@ public:
;
};
virtual void printBoard(unsigned int threadNo, unsigned char value) noexcept
virtual void printBoard(unsigned int threadNo, unsigned char value)
{
while (true)
;
};
virtual void printMoveInformation(unsigned int threadNo, unsigned int idPossibility, void* pPossibilities) noexcept
virtual void printMoveInformation(unsigned int threadNo, unsigned int idPossibility, void* pPossibilities)
{
while (true)
;

View File

@ -76,7 +76,7 @@ protected:
void move(unsigned int threadNo, unsigned int idPossibility, bool opponentsMove, void** pBackup, void* pPossibilities) noexcept;
void undo(unsigned int threadNo, unsigned int idPossibility, bool opponentsMove, void* pBackup, void* pPossibilities) noexcept;
void getValueOfSituation(unsigned int threadNo, float& floatValue, TwoBit& shortValue) noexcept;
void printMoveInformation(unsigned int threadNo, unsigned int idPossibility, void* pPossibilities) noexcept;
void printMoveInformation(unsigned int threadNo, unsigned int idPossibility, void* pPossibilities);
unsigned int getNumberOfLayers() noexcept
{
@ -126,7 +126,7 @@ protected:
void getPredecessors(unsigned int threadNo, unsigned int* amountOfPred, RetroAnalysisPredVars* predVars) noexcept {};
void printBoard(unsigned int threadNo, unsigned char value) noexcept {};
void printBoard(unsigned int threadNo, unsigned char value) {};
void prepareDatabaseCalculation() noexcept {};

View File

@ -12,7 +12,7 @@
// showMemoryStatus()
//
//-----------------------------------------------------------------------------
unsigned int MiniMax::getNumThreads()
unsigned int MiniMax::getNumThreads() noexcept
{
return threadManager.getNumThreads();
}
@ -21,7 +21,7 @@ unsigned int MiniMax::getNumThreads()
// anyFreshlyCalculatedLayer()
// called by MAIN-thread in pMiniMax->csOsPrint critical-section
//-----------------------------------------------------------------------------
bool MiniMax::anyFreshlyCalculatedLayer()
bool MiniMax::anyFreshlyCalculatedLayer() noexcept
{
return (lastCalculatedLayer.size() > 0);
}
@ -30,7 +30,7 @@ bool MiniMax::anyFreshlyCalculatedLayer()
// getLastCalculatedLayer()
// called by MAIN-thread in pMiniMax->csOsPrint critical-section
//-----------------------------------------------------------------------------
unsigned int MiniMax::getLastCalculatedLayer()
unsigned int MiniMax::getLastCalculatedLayer() noexcept
{
unsigned int tmp = lastCalculatedLayer.front();
lastCalculatedLayer.pop_front();
@ -41,7 +41,7 @@ unsigned int MiniMax::getLastCalculatedLayer()
// isLayerInDatabase()
//
//-----------------------------------------------------------------------------
bool MiniMax::isLayerInDatabase(unsigned int layerNum)
bool MiniMax::isLayerInDatabase(unsigned int layerNum) noexcept
{
if (layerStats == nullptr)
return false;
@ -52,7 +52,7 @@ bool MiniMax::isLayerInDatabase(unsigned int layerNum)
// getLayerSizeInBytes()
//
//-----------------------------------------------------------------------------
long long MiniMax::getLayerSizeInBytes(unsigned int layerNum)
long long MiniMax::getLayerSizeInBytes(unsigned int layerNum) noexcept
{
if (plyInfos == nullptr || layerStats == nullptr)
return 0;
@ -63,7 +63,7 @@ long long MiniMax::getLayerSizeInBytes(unsigned int layerNum)
// getNumWonStates()
//
//-----------------------------------------------------------------------------
MiniMax::StateNumberVarType MiniMax::getNumWonStates(unsigned int layerNum)
MiniMax::StateNumberVarType MiniMax::getNumWonStates(unsigned int layerNum) noexcept
{
if (layerStats == nullptr)
return 0;
@ -74,7 +74,7 @@ MiniMax::StateNumberVarType MiniMax::getNumWonStates(unsigned int layerNum)
// getNumLostStates()
//
//-----------------------------------------------------------------------------
MiniMax::StateNumberVarType MiniMax::getNumLostStates(unsigned int layerNum)
MiniMax::StateNumberVarType MiniMax::getNumLostStates(unsigned int layerNum) noexcept
{
if (layerStats == nullptr)
return 0;
@ -85,7 +85,7 @@ MiniMax::StateNumberVarType MiniMax::getNumLostStates(unsigned int layerNum)
// getNumDrawnStates()
//
//-----------------------------------------------------------------------------
MiniMax::StateNumberVarType MiniMax::getNumDrawnStates(unsigned int layerNum)
MiniMax::StateNumberVarType MiniMax::getNumDrawnStates(unsigned int layerNum) noexcept
{
if (layerStats == nullptr)
return 0;
@ -96,7 +96,7 @@ MiniMax::StateNumberVarType MiniMax::getNumDrawnStates(unsigned int layerNum)
// getNumInvalidStates()
//
//-----------------------------------------------------------------------------
MiniMax::StateNumberVarType MiniMax::getNumInvalidStates(unsigned int layerNum)
MiniMax::StateNumberVarType MiniMax::getNumInvalidStates(unsigned int layerNum) noexcept
{
if (layerStats == nullptr)
return 0;
@ -135,7 +135,7 @@ void MiniMax::showMemoryStatus()
// setOutputStream()
//
//-----------------------------------------------------------------------------
void MiniMax::setOutputStream(ostream* theStream, void (*printFunc)(void* pUserData), void* pUserData)
void MiniMax::setOutputStream(ostream* theStream, void (*printFunc)(void* pUserData), void* pUserData) noexcept
{
osPrint = theStream;
pDataForUserPrintFunc = pUserData;
@ -274,7 +274,7 @@ bool MiniMax::calcLayerStatistics(char* statisticsFileName)
// anyArraryInfoToUpdate()
// called by MAIN-thread in pMiniMax->csOsPrint critical-section
//-----------------------------------------------------------------------------
bool MiniMax::anyArrayInfoToUpdate()
bool MiniMax::anyArrayInfoToUpdate() noexcept
{
return (arrayInfos.arrayInfosToBeUpdated.size() > 0);
}
@ -283,7 +283,7 @@ bool MiniMax::anyArrayInfoToUpdate()
// getArrayInfoForUpdate()
// called by MAIN-thread in pMiniMax->csOsPrint critical-section
//-----------------------------------------------------------------------------
MiniMax::ArrayInfoChange MiniMax::getArrayInfoForUpdate()
MiniMax::ArrayInfoChange MiniMax::getArrayInfoForUpdate() noexcept
{
MiniMax::ArrayInfoChange tmp = arrayInfos.arrayInfosToBeUpdated.front();
arrayInfos.arrayInfosToBeUpdated.pop_front();
@ -294,7 +294,7 @@ MiniMax::ArrayInfoChange MiniMax::getArrayInfoForUpdate()
// getCurrentActionStr()
// called by MAIN-thread in pMiniMax->csOsPrint critical-section
//-----------------------------------------------------------------------------
LPWSTR MiniMax::getCurrentActionStr()
LPWSTR MiniMax::getCurrentActionStr() noexcept
{
switch (curCalculationActionId) {
case MM_ACTION_INIT_RETRO_ANAL:

View File

@ -858,7 +858,7 @@ void PerfectAI::prepareBestChoiceCalculation() noexcept
// ThreadVars()
//
//-----------------------------------------------------------------------------
PerfectAI::ThreadVars::ThreadVars()
PerfectAI::ThreadVars::ThreadVars() noexcept
{
field = nullptr;
floatValue = 0;
@ -1014,7 +1014,7 @@ unsigned int* PerfectAI::ThreadVars::getPossStoneRemove(unsigned int* numPossibi
// getPossibilities()
//
//-----------------------------------------------------------------------------
unsigned int* PerfectAI::getPossibilities(unsigned int threadNo, unsigned int* numPossibilities, bool* opponentsMove, void** pPossibilities) noexcept
unsigned int* PerfectAI::getPossibilities(unsigned int threadNo, unsigned int* numPossibilities, bool* opponentsMove, void** pPossibilities)
{
// locals
bool aStoneCanBeRemovedFromCurPlayer = 0;
@ -1486,7 +1486,7 @@ void PerfectAI::getValueOfMoves(unsigned char* moveValue, unsigned int* freqValu
// printMoveInformation()
//
//-----------------------------------------------------------------------------
void PerfectAI::printMoveInformation(unsigned int threadNo, unsigned int idPossibility, void* pPossibilities) noexcept
void PerfectAI::printMoveInformation(unsigned int threadNo, unsigned int idPossibility, void* pPossibilities)
{
// locals
ThreadVars* tv = &threadVars[threadNo];
@ -1905,7 +1905,7 @@ string PerfectAI::getOutputInformation(unsigned int layerNum)
// printBoard()
//
//-----------------------------------------------------------------------------
void PerfectAI::printBoard(unsigned int threadNo, unsigned char value) noexcept
void PerfectAI::printBoard(unsigned int threadNo, unsigned char value)
{
ThreadVars* tv = &threadVars[threadNo];
char wonStr[] = "WON";
@ -2053,7 +2053,7 @@ void PerfectAI::getSymStateNumWithDoubles(unsigned int threadNo, unsigned int* n
// fieldIntegrityOK()
//
//-----------------------------------------------------------------------------
bool PerfectAI::ThreadVars::fieldIntegrityOK(unsigned int numberOfMillsCurrentPlayer, unsigned int numberOfMillsOpponentPlayer, bool aStoneCanBeRemovedFromCurPlayer)
bool PerfectAI::ThreadVars::fieldIntegrityOK(unsigned int numberOfMillsCurrentPlayer, unsigned int numberOfMillsOpponentPlayer, bool aStoneCanBeRemovedFromCurPlayer) noexcept
{
// locals
int i, j;

View File

@ -156,7 +156,7 @@ protected:
PerfectAI* parent; //
// constructor
ThreadVars();
ThreadVars() noexcept;
// Functions
unsigned int* getPossSettingPhase(unsigned int* numPossibilities, void** pPossibilities);
@ -174,7 +174,7 @@ protected:
// 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);
bool fieldIntegrityOK(unsigned int numberOfMillsCurrentPlayer, unsigned int numberOfMillsOpponentPlayer, bool aStoneCanBeRemovedFromCurPlayer) noexcept;
void calcPossibleMoves(Player* player);
void storePredecessor(unsigned int numberOfMillsCurrentPlayer, unsigned int numberOfMillsOpponentPlayer, unsigned int* amountOfPred, RetroAnalysisPredVars* predVars);
};
@ -205,13 +205,13 @@ protected:
void setOpponentLevel(unsigned int threadNo, bool isOpponentLevel) noexcept;
bool getOpponentLevel(unsigned int threadNo) noexcept;
void deletePossibilities(unsigned int threadNo, void* pPossibilities) noexcept;
unsigned int* getPossibilities(unsigned int threadNo, unsigned int* numPossibilities, bool* opponentsMove, void** pPossibilities) noexcept;
unsigned int* getPossibilities(unsigned int threadNo, unsigned int* numPossibilities, bool* opponentsMove, void** pPossibilities);
void undo(unsigned int threadNo, unsigned int idPossibility, bool opponentsMove, void* pBackup, void* pPossibilities) noexcept;
void move(unsigned int threadNo, unsigned int idPossibility, bool opponentsMove, void** pBackup, void* pPossibilities) noexcept;
void printMoveInformation(unsigned int threadNo, unsigned int idPossibility, void* pPossibilities) noexcept;
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) noexcept;
void getSymStateNumWithDoubles(unsigned int threadNo, unsigned int* numSymmetricStates, unsigned int** symStateNumbers) noexcept;
void printBoard(unsigned int threadNo, unsigned char value) noexcept;
void printBoard(unsigned int threadNo, unsigned char value);
string getOutputInformation(unsigned int layerNum);
unsigned int getPartnerLayer(unsigned int layerNum) noexcept;
void prepareDatabaseCalculation() noexcept;

View File

@ -86,7 +86,7 @@ public:
// Other properties of the position
Color side_to_move() const noexcept;
int game_ply() const noexcept;
Thread* this_thread() const;
Thread* this_thread() const noexcept;
bool has_game_cycle() const;
bool has_repeated(Sanmill::Stack<Position>& ss) const;
unsigned int rule50_count() const noexcept;
@ -136,7 +136,7 @@ public:
static void print_board();
int piece_on_board_count(Color c) const noexcept;
int piece_in_hand_count(Color c) const;
int piece_in_hand_count(Color c) const noexcept;
int piece_to_remove_count() const noexcept;
@ -145,7 +145,7 @@ public:
//template <typename Mt> void updateMobility(Square from, Square to);
int calculate_mobility_diff();
bool is_three_endgame() const;
bool is_three_endgame() const noexcept;
static bool is_star_square(Square s);
@ -255,7 +255,7 @@ inline unsigned int Position::rule50_count() const noexcept
return st.rule50;
}
inline Thread* Position::this_thread() const
inline Thread* Position::this_thread() const noexcept
{
return thisThread;
}
@ -334,7 +334,7 @@ inline int Position::piece_on_board_count(Color c) const noexcept
return pieceOnBoardCount[c];
}
inline int Position::piece_in_hand_count(Color c) const
inline int Position::piece_in_hand_count(Color c) const noexcept
{
return pieceInHandCount[c];
}
@ -349,7 +349,7 @@ inline int Position::get_mobility_diff() const noexcept
return mobilityDiff;
}
inline bool Position::is_three_endgame() const
inline bool Position::is_three_endgame() const noexcept
{
if (get_phase() == Phase::placing) {
return false;

View File

@ -29,7 +29,7 @@ Value MTDF(Position* pos, Sanmill::Stack<Position>& ss, Value firstguess, Depth
Value qsearch(Position* pos, Sanmill::Stack<Position>& ss, Depth depth, Depth originDepth, Value alpha, Value beta, Move& bestMove);
bool is_timeout(TimePoint startTime);
bool is_timeout(TimePoint startTime) noexcept;
/// Search::init() is called at startup
@ -490,7 +490,7 @@ Value MTDF(Position* pos, Sanmill::Stack<Position>& ss, Value firstguess, Depth
return g;
}
bool is_timeout(TimePoint startTime)
bool is_timeout(TimePoint startTime) noexcept
{
auto limit = gameOptions.getMoveTime() * 1000;
TimePoint elapsed = now() - startTime;

View File

@ -24,7 +24,7 @@ namespace Sanmill {
template <typename T, size_t capacity = 128>
class Stack {
public:
Stack()
Stack() noexcept
{
arr = new T[capacity];
}
@ -61,7 +61,7 @@ public:
return arr[i];
}
inline void push(const T& obj)
inline void push(const T& obj) noexcept
{
p++;
memcpy(arr + p, &obj, sizeof(T));