新增 config.h 用于宏定义配置

This commit is contained in:
CalciteM Team 2019-06-28 21:57:41 +08:00
parent 0aa7d11ead
commit ffac849fac
15 changed files with 329 additions and 294 deletions

View File

@ -254,7 +254,7 @@
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<SuppressStartupBanner>true</SuppressStartupBanner>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<WarningLevel>Level4</WarningLevel>
<WarningLevel>Level3</WarningLevel>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<ProgramDataBaseFileName>$(IntDir)vc$(PlatformToolsetVersion).pdb</ProgramDataBaseFileName>
</ClCompile>
@ -422,6 +422,7 @@
<IncludePath Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\GeneratedFiles\$(ConfigurationName);.\GeneratedFiles;.;D:\Qt\Qt5.11.0\5.11.0\msvc2017_64\include;release;\include;D:\Qt\Qt5.11.0\5.11.0\msvc2017_64\mkspecs\win32-msvc;D:\Qt\Qt5.11.0\5.11.0\msvc2017_64\include\QtWidgets;D:\Qt\Qt5.11.0\5.11.0\msvc2017_64\include\QtCore;D:\Qt\Qt5.11.0\5.11.0\msvc2017_64\include\QtGui;D:\Qt\Qt5.11.0\5.11.0\msvc2017_64\include\QtANGLE;D:\Qt\Qt5.11.0\5.11.0\msvc2017_64\include\QtMultimedia;D:\Qt\Qt5.11.0\5.11.0\msvc2017_64\include\QtNetwork;%(AdditionalIncludeDirectories)</IncludePath>
<IncludePath Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\GeneratedFiles\$(ConfigurationName);.\GeneratedFiles;.;D:\Qt\Qt5.11.0\5.11.0\msvc2017_64\include;release;\include;D:\Qt\Qt5.11.0\5.11.0\msvc2017_64\mkspecs\win32-msvc;D:\Qt\Qt5.11.0\5.11.0\msvc2017_64\include\QtWidgets;D:\Qt\Qt5.11.0\5.11.0\msvc2017_64\include\QtCore;D:\Qt\Qt5.11.0\5.11.0\msvc2017_64\include\QtGui;D:\Qt\Qt5.11.0\5.11.0\msvc2017_64\include\QtANGLE;D:\Qt\Qt5.11.0\5.11.0\msvc2017_64\include\QtMultimedia;D:\Qt\Qt5.11.0\5.11.0\msvc2017_64\include\QtNetwork;%(AdditionalIncludeDirectories)</IncludePath>
</QtMoc>
<ClInclude Include="src\config.h" />
<ClInclude Include="src\graphicsconst.h" />
<ClInclude Include="src\ninechess.h" />
<QtMoc Include="src\ninechesswindow.h">

View File

@ -107,6 +107,9 @@
<ClInclude Include="src\ninechessai_ab.h">
<Filter>Model</Filter>
</ClInclude>
<ClInclude Include="src\config.h">
<Filter>Control</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<CustomBuild Include="debug\moc_predefs.h.cbt">

View File

@ -1,7 +1,10 @@
#ifndef BOARDITEM_H
#define BOARDITEM_H
#include <QGraphicsItem>
#include "config.h"
class BoardItem : public QGraphicsItem
{
public:

16
NineChess/src/config.h Normal file
View File

@ -0,0 +1,16 @@
#ifndef CONFIG_H
#define CONFIG_H
// 打印更多调试信息
#define DEBUG
// 播放声音
#define PLAY_SOUND
// Alpha-Beta 随机排序孩子结点
//#define AB_RANDOM_SORT_CHILDREN
// 调试博弈树 (耗费大量内存)
#define DEBUG_AB_TREE
#endif // CONFIG_H

View File

@ -305,7 +305,6 @@ void GameController::setSound(bool arg)
void GameController::playSound(const QString &soundPath)
{
#define PLAY_SOUND
#ifdef PLAY_SOUND
if (hasSound) {
QSound::play(soundPath);

View File

@ -15,6 +15,7 @@
#include <QTextStream>
#include <QStringListModel>
#include <QModelIndex>
#include "ninechess.h"
#include "gamescene.h"
#include "pieceitem.h"

View File

@ -3,6 +3,8 @@
#include <QGraphicsScene>
#include "config.h"
class BoardItem;
class GameScene : public QGraphicsScene

View File

@ -4,6 +4,8 @@
#include <QGraphicsView>
#include "config.h"
class GameView : public QGraphicsView
{
Q_OBJECT

View File

@ -14,6 +14,8 @@
#include <QMouseEvent>
#include <QDebug>
#include "config.h"
class ManualListView : public QListView
{
Q_OBJECT

View File

@ -12,6 +12,8 @@
#include <cstring>
#include <list>
#include "config.h"
using std::string;
using std::list;

View File

@ -150,7 +150,6 @@ void NineChessAi_ab::buildChildren(Node *node)
void NineChessAi_ab::sortChildren(Node *node)
{
// 这个函数对效率的影响很大,排序好的话,剪枝较早,节省时间,但不能在此函数耗费太多时间
#define AB_RANDOM_SORT_CHILDREN
#ifdef AB_RANDOM_SORT_CHILDREN
// 这里我用一个随机排序使AI不至于每次走招相同
srand((unsigned)time(0));
@ -513,7 +512,6 @@ int NineChessAi_ab::alphaBetaPruning(int depth, int alpha, int beta, Node *node)
}
// 删除“孙子”节点,防止层数较深的时候节点树太大
//#define DEBUG_AB_TREE
#ifndef DEBUG_AB_TREE
for (auto child : node->children) {
for (auto grandChild : child->children)

View File

@ -7,7 +7,6 @@
#ifndef NINECHESSAI_AB
#define NINECHESSAI_AB
#include "ninechess.h"
#include <list>
#include <stack>
#include <unordered_map>
@ -15,6 +14,8 @@
#include <string>
#include <Qdebug>
#include "ninechess.h"
using namespace std;
// 注意NineChess类不是线程安全的

View File

@ -6,7 +6,9 @@
#include <QStringListModel>
#include <QFile>
#include <QTimer>
#include "ui_ninechesswindow.h"
#include "config.h"
class GameScene;
class GameController;

View File

@ -1,8 +1,11 @@
#ifndef CHESSITEM_H
#define CHESSITEM_H
#include <QObject>
#include <QGraphicsItem>
#include "config.h"
class PieceItem : public QObject, public QGraphicsItem
{
Q_OBJECT