cpp: Fix Vera++ issues

Use profile: .vera-profile
This commit is contained in:
Calcitem 2021-11-20 22:10:58 +08:00
parent fba36047f0
commit 35527ddd1c
6 changed files with 57 additions and 101 deletions

19
.vera-profile Normal file
View File

@ -0,0 +1,19 @@
# This file defines the set of scripts (rules) that should be executed.
rule=F001
rule=L001
rule=L002
rule=L003
rule=L004
rule=L005
rule=T001
rule=T004
rule=T005
rule=T006
rule=T007
rule=T008
rule=T010
rule=T013
rule=T015
rule=T017

View File

@ -591,7 +591,7 @@ int best_group(size_t idx)
if (nodes != 0) {
groups.push_back(t % nodes);
}
}
}
// If we still have more threads than the total number of logical processors
// then return -1 and let the OS to decide what to do.

View File

@ -1,10 +1,10 @@
/***************************************************************************************************************************
/*******************************************************************************
miniMax.h
Copyright (c) Thomas Weber. All rights reserved.
Copyright (C) 2021 The Sanmill developers (see AUTHORS file)
Licensed under the GPLv3 License.
https://github.com/madweasel/Muehle
***************************************************************************************************************************/
*******************************************************************************/
#ifndef MINIMAX_H_INCLUDED
#define MINIMAX_H_INCLUDED
@ -33,28 +33,28 @@
using std::iostream; // use standard library namespace
/*** Wiki
***************************************************************************************************************************
********************************************************************************
player:
layer: The states are divided in layers. For
layer: The states are divided in layers. For
example depending on number of stones on the board.
state: A unique game state representing a
current game situation. situation: Used as synonym
state: A unique game state representing a
current game situation. situation: Used as synonym
to state.
knot: Each knot of the graph corresponds to a
knot: Each knot of the graph corresponds to a
game state. The knots are connected by possible valid moves. ply info:
Number of plies/moves necessary to win the game. state address:
A state is identified by the corresponding layer and the state number within the
layer.
short knot value: Each knot/state can have the value
short knot value: Each knot/state can have the value
SKV_VALUE_INVALID, SKV_VALUE_GAME_LOST, SKV_VALUE_GAME_DRAWN or
SKV_VALUE_GAME_WON. float point knot value: Each knot/state can be evaluated
SKV_VALUE_GAME_WON. float point knot value: Each knot/state can be evaluated
by a floating point value. High positive values represents winning situations.
Negative values stand for loosing situations.
database: The database contains the arrays with
database: The database contains the arrays with
the short knot values and the ply infos.
/*** Constants
***************************************************************************************************************************/
*******************************************************************************/
#define FPKV_MIN_VALUE -100000.0f // minimum float point knot value
#define FPKV_MAX_VALUE 100000.0f // maximum float point knot value
#define FPKV_THRESHOLD \
@ -124,7 +124,7 @@ the short knot values and the ply infos.
#define MM_ACTION_NONE 8
/*** Macros
* ***************************************************************************************************************************/
* ****************************************************************************/
#define SAFE_DELETE(p) \
{ \
if (p) { \
@ -156,14 +156,14 @@ the short knot values and the ply infos.
}
/*** Classes
* ***************************************************************************************************************************/
* ****************************************************************************/
class MiniMax {
friend class MiniMaxWinInspectDb;
friend class MiniMaxWinCalcDb;
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 predecessors
@ -171,7 +171,7 @@ public:
StateNumberVarType; // 4 Bytes for addressing states within a layer
/*** protected structures
* ********************************************************************************************************************/
* ************************************************************************/
struct SkvFileHeader // header of the short knot value file
{
@ -305,7 +305,7 @@ public:
};
/*** public functions
* *********************************************************************************************/
* ************************************************************************/
// Constructor / destructor
MiniMax();
@ -867,7 +867,7 @@ private:
frequency; // performance-counter frequency, in counts per second
/*** private functions
* ***************************************************************************************************************************/
* ************************************************************************/
// database functions
void openSkvFile(const char* path, unsigned int maximumNumberOfBranches);

View File

@ -28,47 +28,6 @@ public:
}
};
/*------------------------------------------------------------------------------------
| -------------------------------------
--------------------------------- | | |
| | | | | |
| | | | | | pTreeViewInspect
| | MiniMaxGuiField | | |
| |
| | | |
| |
| | | |
| |
| | | |
| |
| | | |
| |
| | | |
| |
| | | |
| |
| | | |
| |
| | | |
| |
| | | |
| |
| | | |
| |
| | | |
| |
| | | |
| |
| | | |
| |
| | | |
| |
| | | |
------------------------------------- --------------------------------- | |
|
-----------------------------------------------------------------------------------*/
class MiniMaxWinInspectDb {
protected:
// General Variables
@ -93,39 +52,6 @@ public:
void resize(wildWeasel::alignment& rcNewArea);
};
/*------------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
| | |
| | | |
| | | | hListViewLayer
| | | |
| | | |
| | | |
| | | |
| | |
-----------------------------------------------------------------------------
| |
| | -------------------------------------
--------------------------------- | | |
| | | | | |
| | hEditOutputBox | | |
| hListViewArray | |
| |
| |
| | | | | |
| | | | | |
| | | | | |
| | | | | -------------------------------------
--------------------------------- | |
| | hLabelCalculationRunning hLabelCalculatingLayer
hLabelCalculationAction | |
| | ------------------- ----------------- ---------------- ---------------
| | hButtonCalcContinue hButtonCalcCancel hButtonCalcPause
hButtonCalcTest | | ------------------- -----------------
---------------- --------------- |
-----------------------------------------------------------------------------------*/
class MiniMaxWinCalcDb {
protected:
// Calculation variables

View File

@ -2610,7 +2610,7 @@ void PerfectAI::ThreadVars::storePredecessor(
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:
// - board->curPlayer->numStones
@ -2619,7 +2619,7 @@ void PerfectAI::getPredecessors(unsigned int threadNo,
// - board->board
// - board->stoneMustBeRemoved
// - board->settingPhase
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
// locals
ThreadVars* tv = &threadVars[threadNo];
@ -3161,18 +3161,27 @@ bool PerfectAI::checkGetPredThanGetPoss()
return false;
#if 0
// perform several commands to see in debug mode where the error occurs
// perform several commands to see in debug mode where the
// error occurs
for (k = 0; k < tv->field->size; k++)
symField[k] = tv->field->board[k];
applySymmetryOperationOnField(reverseSymOperation[predVars[j].predSymOperation], (unsigned int *)symField, (unsigned int *)tv->field->board);
applySymmetryOperationOnField(
reverseSymOperation[predVars[j].predSymOperation],
(unsigned int*)symField,
(unsigned int*)tv->field->board);
for (k = 0; k < tv->field->size; k++)
symField[k] = tv->field->stonePartOfMill[k];
applySymmetryOperationOnField(reverseSymOperation[predVars[j].predSymOperation], (unsigned int *)symField, (unsigned int *)tv->field->stonePartOfMill);
applySymmetryOperationOnField(
reverseSymOperation[predVars[j].predSymOperation],
(unsigned int*)symField,
(unsigned int*)tv->field->stonePartOfMill);
cout << "predecessor" << endl;
cout << " layerNum: " << predVars[j].predLayerNumbers << "\tstateNum: " << predVars[j].predStateNumbers << endl;
cout << " layerNum: " << predVars[j].predLayerNumbers
<< "\tstateNum: " << predVars[j].predStateNumbers
<< endl;
printBoard(threadNo, 0);
if (predVars[j].playerToMoveChanged) {
@ -3183,10 +3192,12 @@ bool PerfectAI::checkGetPredThanGetPoss()
tv->field->board[k] = -1 * tv->field->board[k];
}
idPossibility = getPossibilities(threadNo, &numPossibilities, &isOpponentLevel, &pPossibilities);
idPossibility = getPossibilities(threadNo,
&numPossibilities, &isOpponentLevel, &pPossibilities);
setSituation(threadNo, layerNum, stateNum);
cout << "current state" << endl;
cout << " layerNum: " << layerNum << "\tstateNum: " << stateNum << endl;
cout << " layerNum: " << layerNum
<< "\tstateNum: " << stateNum << endl;
printBoard(threadNo, 0);
getPredecessors(threadNo, &amountOfPred, predVars);
#endif

View File

@ -31,7 +31,7 @@
#include <QPushButton>
#include <QScreen>
#include <QSpinBox>
#include <QTimer>
#include <QTimer>
#include <QToolTip>
#include <QVBoxLayout>