Remove unsued TRAINING_MODE code
This commit is contained in:
parent
8269b1587a
commit
04b6f10e1f
|
@ -45,8 +45,6 @@
|
||||||
|
|
||||||
//#define MOBILE_APP_UI
|
//#define MOBILE_APP_UI
|
||||||
|
|
||||||
//#define TRAINING_MODE
|
|
||||||
|
|
||||||
//#define TEST_MODE
|
//#define TEST_MODE
|
||||||
|
|
||||||
//#define UCT_DEMO
|
//#define UCT_DEMO
|
||||||
|
|
|
@ -26,7 +26,6 @@ SOURCES += \
|
||||||
src/movegen.cpp \
|
src/movegen.cpp \
|
||||||
src/movepick.cpp \
|
src/movepick.cpp \
|
||||||
src/thread.cpp \
|
src/thread.cpp \
|
||||||
src/trainer.cpp \
|
|
||||||
src/tt.cpp \
|
src/tt.cpp \
|
||||||
src/misc.cpp \
|
src/misc.cpp \
|
||||||
src/uci.cpp \
|
src/uci.cpp \
|
||||||
|
@ -58,7 +57,6 @@ HEADERS += \
|
||||||
src/movegen.h \
|
src/movegen.h \
|
||||||
src/movepick.h \
|
src/movepick.h \
|
||||||
src/thread.h \
|
src/thread.h \
|
||||||
src/trainer.h \
|
|
||||||
src/tt.h \
|
src/tt.h \
|
||||||
src/hashnode.h \
|
src/hashnode.h \
|
||||||
src/debug.h \
|
src/debug.h \
|
||||||
|
|
|
@ -462,7 +462,6 @@
|
||||||
<ClInclude Include="src\movegen.h" />
|
<ClInclude Include="src\movegen.h" />
|
||||||
<ClInclude Include="src\movepick.h" />
|
<ClInclude Include="src\movepick.h" />
|
||||||
<ClInclude Include="src\search.h" />
|
<ClInclude Include="src\search.h" />
|
||||||
<ClInclude Include="src\trainer.h" />
|
|
||||||
<ClInclude Include="src\tt.h" />
|
<ClInclude Include="src\tt.h" />
|
||||||
<ClInclude Include="src\debug.h" />
|
<ClInclude Include="src\debug.h" />
|
||||||
<ClInclude Include="src\hashmap.h" />
|
<ClInclude Include="src\hashmap.h" />
|
||||||
|
@ -733,7 +732,6 @@
|
||||||
<ClCompile Include="src\movegen.cpp" />
|
<ClCompile Include="src\movegen.cpp" />
|
||||||
<ClCompile Include="src\movepick.cpp" />
|
<ClCompile Include="src\movepick.cpp" />
|
||||||
<ClCompile Include="src\search.cpp" />
|
<ClCompile Include="src\search.cpp" />
|
||||||
<ClCompile Include="src\trainer.cpp" />
|
|
||||||
<ClCompile Include="src\tt.cpp" />
|
<ClCompile Include="src\tt.cpp" />
|
||||||
<ClCompile Include="src\misc.cpp" />
|
<ClCompile Include="src\misc.cpp" />
|
||||||
<ClCompile Include="src\thread.cpp" />
|
<ClCompile Include="src\thread.cpp" />
|
||||||
|
|
|
@ -105,9 +105,6 @@
|
||||||
<ClInclude Include="src\stack.h">
|
<ClInclude Include="src\stack.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="src\trainer.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="src\option.h">
|
<ClInclude Include="src\option.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
@ -305,9 +302,6 @@
|
||||||
<ClCompile Include="src\search.cpp">
|
<ClCompile Include="src\search.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\trainer.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="src\tt.cpp">
|
<ClCompile Include="src\tt.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
|
|
@ -114,8 +114,6 @@ int Thread::search()
|
||||||
posKeyHistory.push_back(key);
|
posKeyHistory.push_back(key);
|
||||||
#endif // UCI_DO_BEST_MOVE
|
#endif // UCI_DO_BEST_MOVE
|
||||||
|
|
||||||
//sync_cout << "posKeyHistory Size = " << posKeyHistory.size();
|
|
||||||
//std::cout << sync_endl;
|
|
||||||
assert(posKeyHistory.size() < 256);
|
assert(posKeyHistory.size() < 256);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,44 +0,0 @@
|
||||||
/*
|
|
||||||
This file is part of Sanmill.
|
|
||||||
Copyright (C) 2019-2021 The Sanmill developers (see AUTHORS file)
|
|
||||||
|
|
||||||
Sanmill is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
Sanmill is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef TRAINING_MODE
|
|
||||||
#include "game.h"
|
|
||||||
#include "trainer.h"
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
loggerDebug("Training start...\n");
|
|
||||||
|
|
||||||
Game *game = new Game();
|
|
||||||
|
|
||||||
game->gameReset();
|
|
||||||
game->gameStart();
|
|
||||||
|
|
||||||
game->isAiPlayer[BLACK] = game->isAiPlayer[WHITE] = true;
|
|
||||||
|
|
||||||
game->setEngine(1, true);
|
|
||||||
game->setEngine(2, true);
|
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
system("pause");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // TRAINING_MODE
|
|
|
@ -1,24 +0,0 @@
|
||||||
/*
|
|
||||||
This file is part of Sanmill.
|
|
||||||
Copyright (C) 2019-2021 The Sanmill developers (see AUTHORS file)
|
|
||||||
|
|
||||||
Sanmill is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
Sanmill is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef TRAINER_H
|
|
||||||
#define TRAINER_H
|
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
|
|
||||||
#endif // TRAINER_H
|
|
|
@ -26,7 +26,6 @@ add_library( # Sets the name of the library.
|
||||||
../../../../rule.cpp
|
../../../../rule.cpp
|
||||||
../../../../search.cpp
|
../../../../search.cpp
|
||||||
../../../../thread.cpp
|
../../../../thread.cpp
|
||||||
../../../../trainer.cpp
|
|
||||||
../../../../tt.cpp
|
../../../../tt.cpp
|
||||||
../../../../uci.cpp
|
../../../../uci.cpp
|
||||||
../../../../ucioption.cpp)
|
../../../../ucioption.cpp)
|
||||||
|
|
|
@ -42,15 +42,11 @@
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
Game::Game(
|
Game::Game(
|
||||||
#ifndef TRAINING_MODE
|
|
||||||
GameScene & scene,
|
GameScene & scene,
|
||||||
#endif
|
|
||||||
QObject * parent
|
QObject * parent
|
||||||
) :
|
) :
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
#ifndef TRAINING_MODE
|
|
||||||
scene(scene),
|
scene(scene),
|
||||||
#endif
|
|
||||||
currentPiece(nullptr),
|
currentPiece(nullptr),
|
||||||
currentRow(-1),
|
currentRow(-1),
|
||||||
isEditing(false),
|
isEditing(false),
|
||||||
|
@ -94,7 +90,6 @@ Game::Game(
|
||||||
#endif // QT_GUI_LIB
|
#endif // QT_GUI_LIB
|
||||||
|
|
||||||
#ifdef NET_FIGHT_SUPPORT
|
#ifdef NET_FIGHT_SUPPORT
|
||||||
#ifndef TRAINING_MODE
|
|
||||||
server = new Server(nullptr, 30001); // TODO: WARNING: ThreadSanitizer: data race
|
server = new Server(nullptr, 30001); // TODO: WARNING: ThreadSanitizer: data race
|
||||||
uint16_t clientPort = server->getPort() == 30001 ? 30002 : 30001;
|
uint16_t clientPort = server->getPort() == 30001 ? 30002 : 30001;
|
||||||
client = new Client(nullptr, clientPort);
|
client = new Client(nullptr, clientPort);
|
||||||
|
@ -102,7 +97,6 @@ Game::Game(
|
||||||
// 关联AI和网络类的着法命令行
|
// 关联AI和网络类的着法命令行
|
||||||
connect(getClient(), SIGNAL(command(const string &, bool)),
|
connect(getClient(), SIGNAL(command(const string &, bool)),
|
||||||
this, SLOT(command(const string &, bool)));
|
this, SLOT(command(const string &, bool)));
|
||||||
#endif // TRAINING_MODE
|
|
||||||
#endif // NET_FIGHT_SUPPORT
|
#endif // NET_FIGHT_SUPPORT
|
||||||
|
|
||||||
#ifdef ENDGAME_LEARNING_FORCE
|
#ifdef ENDGAME_LEARNING_FORCE
|
||||||
|
@ -143,7 +137,6 @@ const map<int, QStringList> Game::getActions()
|
||||||
// 之所以不用信号和槽的模式,是因为发信号的时候槽还来不及关联
|
// 之所以不用信号和槽的模式,是因为发信号的时候槽还来不及关联
|
||||||
map<int, QStringList> actions;
|
map<int, QStringList> actions;
|
||||||
|
|
||||||
#ifndef TRAINING_MODE
|
|
||||||
for (int i = 0; i < N_RULES; i++) {
|
for (int i = 0; i < N_RULES; i++) {
|
||||||
// map的key存放int索引值,value存放规则名称和规则提示
|
// map的key存放int索引值,value存放规则名称和规则提示
|
||||||
QStringList strlist;
|
QStringList strlist;
|
||||||
|
@ -151,7 +144,6 @@ const map<int, QStringList> Game::getActions()
|
||||||
strlist.append(tr(RULES[i].description));
|
strlist.append(tr(RULES[i].description));
|
||||||
actions.insert(map<int, QStringList>::value_type(i, strlist));
|
actions.insert(map<int, QStringList>::value_type(i, strlist));
|
||||||
}
|
}
|
||||||
#endif // TRAINING_MODE
|
|
||||||
|
|
||||||
return actions;
|
return actions;
|
||||||
}
|
}
|
||||||
|
@ -217,7 +209,6 @@ void Game::gameReset()
|
||||||
resetAiPlayers();
|
resetAiPlayers();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef TRAINING_MODE
|
|
||||||
// 清除棋子
|
// 清除棋子
|
||||||
qDeleteAll(pieceList);
|
qDeleteAll(pieceList);
|
||||||
pieceList.clear();
|
pieceList.clear();
|
||||||
|
@ -305,19 +296,15 @@ void Game::gameReset()
|
||||||
|
|
||||||
// 播放音效
|
// 播放音效
|
||||||
//playSound(":/sound/resources/sound/newgame.wav");
|
//playSound(":/sound/resources/sound/newgame.wav");
|
||||||
#endif // TRAINING_MODE
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::setEditing(bool arg)
|
void Game::setEditing(bool arg)
|
||||||
{
|
{
|
||||||
#ifndef TRAINING_MODE
|
|
||||||
isEditing = arg;
|
isEditing = arg;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::setInvert(bool arg)
|
void Game::setInvert(bool arg)
|
||||||
{
|
{
|
||||||
#ifndef TRAINING_MODE
|
|
||||||
isInverted = arg;
|
isInverted = arg;
|
||||||
|
|
||||||
// 遍历所有棋子
|
// 遍历所有棋子
|
||||||
|
@ -335,7 +322,6 @@ void Game::setInvert(bool arg)
|
||||||
pieceItem->update();
|
pieceItem->update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // TRAINING_MODE
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::setRule(int ruleNo, int stepLimited /*= -1*/, int timeLimited /*= -1*/)
|
void Game::setRule(int ruleNo, int stepLimited /*= -1*/, int timeLimited /*= -1*/)
|
||||||
|
@ -411,7 +397,6 @@ void Game::getAiDepthTime(int &time1, int &time2)
|
||||||
|
|
||||||
void Game::setAnimation(bool arg)
|
void Game::setAnimation(bool arg)
|
||||||
{
|
{
|
||||||
#ifndef TRAINING_MODE
|
|
||||||
hasAnimation = arg;
|
hasAnimation = arg;
|
||||||
|
|
||||||
// 默认动画时间500ms
|
// 默认动画时间500ms
|
||||||
|
@ -419,14 +404,11 @@ void Game::setAnimation(bool arg)
|
||||||
durationTime = 500;
|
durationTime = 500;
|
||||||
else
|
else
|
||||||
durationTime = 0;
|
durationTime = 0;
|
||||||
#endif // TRAINING_MODE
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::setSound(bool arg)
|
void Game::setSound(bool arg)
|
||||||
{
|
{
|
||||||
#ifndef TRAINING_MODE
|
|
||||||
hasSound = arg;
|
hasSound = arg;
|
||||||
#endif // TRAINING_MODE
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::playSound(GameSound soundType, Color c)
|
void Game::playSound(GameSound soundType, Color c)
|
||||||
|
@ -521,7 +503,6 @@ void Game::playSound(GameSound soundType, Color c)
|
||||||
#ifndef DONOT_PLAY_SOUND
|
#ifndef DONOT_PLAY_SOUND
|
||||||
QString soundPath = QString::fromStdString(soundDir + filename);
|
QString soundPath = QString::fromStdString(soundDir + filename);
|
||||||
|
|
||||||
#ifndef TRAINING_MODE
|
|
||||||
if (soundPath == "") {
|
if (soundPath == "") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -530,7 +511,6 @@ void Game::playSound(GameSound soundType, Color c)
|
||||||
QSound::play(soundPath);
|
QSound::play(soundPath);
|
||||||
}
|
}
|
||||||
#endif /* ! DONOT_PLAY_SOUND */
|
#endif /* ! DONOT_PLAY_SOUND */
|
||||||
#endif // TRAINING_MODE
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::setResignIfMostLose(bool enabled)
|
void Game::setResignIfMostLose(bool enabled)
|
||||||
|
@ -584,7 +564,6 @@ void Game::setOpeningBook(bool enabled)
|
||||||
// 上下翻转
|
// 上下翻转
|
||||||
void Game::flip()
|
void Game::flip()
|
||||||
{
|
{
|
||||||
#ifndef TRAINING_MODE
|
|
||||||
stopAndWaitAiThreads();
|
stopAndWaitAiThreads();
|
||||||
|
|
||||||
position.mirror(moveHistory);
|
position.mirror(moveHistory);
|
||||||
|
@ -604,13 +583,11 @@ void Game::flip()
|
||||||
|
|
||||||
threadsSetAi(&position);
|
threadsSetAi(&position);
|
||||||
startAiThreads();
|
startAiThreads();
|
||||||
#endif // TRAINING_MODE
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 左右镜像
|
// 左右镜像
|
||||||
void Game::mirror()
|
void Game::mirror()
|
||||||
{
|
{
|
||||||
#ifndef TRAINING_MODE
|
|
||||||
stopAndWaitAiThreads();
|
stopAndWaitAiThreads();
|
||||||
|
|
||||||
position.mirror(moveHistory);
|
position.mirror(moveHistory);
|
||||||
|
@ -632,13 +609,11 @@ void Game::mirror()
|
||||||
|
|
||||||
threadsSetAi(&position);
|
threadsSetAi(&position);
|
||||||
startAiThreads();
|
startAiThreads();
|
||||||
#endif // TRAINING_MODE
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 视图须时针旋转90°
|
// 视图须时针旋转90°
|
||||||
void Game::turnRight()
|
void Game::turnRight()
|
||||||
{
|
{
|
||||||
#ifndef TRAINING_MODE
|
|
||||||
stopAndWaitAiThreads();
|
stopAndWaitAiThreads();
|
||||||
|
|
||||||
position.rotate(moveHistory, -90);
|
position.rotate(moveHistory, -90);
|
||||||
|
@ -658,13 +633,11 @@ void Game::turnRight()
|
||||||
|
|
||||||
threadsSetAi(&position);
|
threadsSetAi(&position);
|
||||||
startAiThreads();
|
startAiThreads();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 视图逆时针旋转90°
|
// 视图逆时针旋转90°
|
||||||
void Game::turnLeft()
|
void Game::turnLeft()
|
||||||
{
|
{
|
||||||
#ifndef TRAINING_MODE
|
|
||||||
stopAndWaitAiThreads();
|
stopAndWaitAiThreads();
|
||||||
|
|
||||||
position.rotate(moveHistory, 90);
|
position.rotate(moveHistory, 90);
|
||||||
|
@ -680,7 +653,6 @@ void Game::turnLeft()
|
||||||
|
|
||||||
threadsSetAi(&position);
|
threadsSetAi(&position);
|
||||||
startAiThreads();
|
startAiThreads();
|
||||||
#endif // TRAINING_MODE
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::updateTime()
|
void Game::updateTime()
|
||||||
|
@ -735,7 +707,6 @@ void Game::timerEvent(QTimerEvent *event)
|
||||||
// 定时器ID为0
|
// 定时器ID为0
|
||||||
timeID = 0;
|
timeID = 0;
|
||||||
|
|
||||||
#ifndef TRAINING_MODE
|
|
||||||
// 发信号更新状态栏
|
// 发信号更新状态栏
|
||||||
updateScence();
|
updateScence();
|
||||||
message = QString::fromStdString(getTips());
|
message = QString::fromStdString(getTips());
|
||||||
|
@ -748,7 +719,6 @@ void Game::timerEvent(QTimerEvent *event)
|
||||||
#ifndef DONOT_PLAY_WIN_SOUND
|
#ifndef DONOT_PLAY_WIN_SOUND
|
||||||
playSound(GameSound::win, winner);
|
playSound(GameSound::win, winner);
|
||||||
#endif
|
#endif
|
||||||
#endif // TRAINING_MODE
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 测试用代码
|
// 测试用代码
|
||||||
|
@ -782,7 +752,6 @@ bool Game::isAIsTurn()
|
||||||
// 关键槽函数,根据QGraphicsScene的信号和状态来执行选子、落子或去子
|
// 关键槽函数,根据QGraphicsScene的信号和状态来执行选子、落子或去子
|
||||||
bool Game::actionPiece(QPointF p)
|
bool Game::actionPiece(QPointF p)
|
||||||
{
|
{
|
||||||
#ifndef TRAINING_MODE
|
|
||||||
// 点击非落子点,不执行
|
// 点击非落子点,不执行
|
||||||
File f;
|
File f;
|
||||||
Rank r;
|
Rank r;
|
||||||
|
@ -939,9 +908,6 @@ bool Game::actionPiece(QPointF p)
|
||||||
sideToMove = position.side_to_move();
|
sideToMove = position.side_to_move();
|
||||||
updateScence();
|
updateScence();
|
||||||
return result;
|
return result;
|
||||||
#else
|
|
||||||
return true;
|
|
||||||
#endif // TRAINING_MODE
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -953,8 +919,6 @@ bool Game::resign()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef TRAINING_MODE
|
|
||||||
|
|
||||||
// 将新增的棋谱行插入到ListModel
|
// 将新增的棋谱行插入到ListModel
|
||||||
currentRow = manualListModel.rowCount() - 1;
|
currentRow = manualListModel.rowCount() - 1;
|
||||||
int k = 0;
|
int k = 0;
|
||||||
|
@ -971,7 +935,6 @@ bool Game::resign()
|
||||||
if (position.get_winner() != NOBODY) {
|
if (position.get_winner() != NOBODY) {
|
||||||
playSound(GameSound::resign, position.side_to_move());
|
playSound(GameSound::resign, position.side_to_move());
|
||||||
}
|
}
|
||||||
#endif // TRAINING_MODE
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -982,9 +945,7 @@ bool Game::command(const string &cmd, bool update /* = true */)
|
||||||
int total;
|
int total;
|
||||||
float bwinrate, wwinrate, drawrate;
|
float bwinrate, wwinrate, drawrate;
|
||||||
|
|
||||||
#ifndef TRAINING_MODE
|
|
||||||
Q_UNUSED(hasSound)
|
Q_UNUSED(hasSound)
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef QT_GUI_LIB
|
#ifdef QT_GUI_LIB
|
||||||
// 防止接收滞后结束的线程发送的指令
|
// 防止接收滞后结束的线程发送的指令
|
||||||
|
@ -995,7 +956,6 @@ bool Game::command(const string &cmd, bool update /* = true */)
|
||||||
return false;
|
return false;
|
||||||
#endif // QT_GUI_LIB
|
#endif // QT_GUI_LIB
|
||||||
|
|
||||||
#ifndef TRAINING_MODE
|
|
||||||
// 声音
|
// 声音
|
||||||
GameSound soundType = GameSound::none;
|
GameSound soundType = GameSound::none;
|
||||||
|
|
||||||
|
@ -1010,7 +970,7 @@ bool Game::command(const string &cmd, bool update /* = true */)
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
//#endif
|
||||||
|
|
||||||
// 如果未开局则开局
|
// 如果未开局则开局
|
||||||
if (position.get_phase() == Phase::ready) {
|
if (position.get_phase() == Phase::ready) {
|
||||||
|
@ -1026,7 +986,6 @@ bool Game::command(const string &cmd, bool update /* = true */)
|
||||||
|
|
||||||
sideToMove = position.side_to_move();
|
sideToMove = position.side_to_move();
|
||||||
|
|
||||||
#ifndef TRAINING_MODE
|
|
||||||
if (soundType == GameSound::drog && position.get_action() == Action::remove) {
|
if (soundType == GameSound::drog && position.get_action() == Action::remove) {
|
||||||
soundType = GameSound::mill;
|
soundType = GameSound::mill;
|
||||||
}
|
}
|
||||||
|
@ -1072,7 +1031,6 @@ bool Game::command(const string &cmd, bool update /* = true */)
|
||||||
playSound(GameSound::win, winner);
|
playSound(GameSound::win, winner);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif // TRAINING_MODE
|
|
||||||
|
|
||||||
// AI设置
|
// AI设置
|
||||||
// 如果还未决出胜负
|
// 如果还未决出胜负
|
||||||
|
@ -1157,10 +1115,8 @@ bool Game::command(const string &cmd, bool update /* = true */)
|
||||||
gameTest->writeToMemory(QString::fromStdString(cmd));
|
gameTest->writeToMemory(QString::fromStdString(cmd));
|
||||||
|
|
||||||
#ifdef NET_FIGHT_SUPPORT
|
#ifdef NET_FIGHT_SUPPORT
|
||||||
#ifndef TRAINING_MODE
|
|
||||||
// 网络: 将着法放到服务器的发送列表中
|
// 网络: 将着法放到服务器的发送列表中
|
||||||
getServer()->setAction(QString::fromStdString(cmd));
|
getServer()->setAction(QString::fromStdString(cmd));
|
||||||
#endif // TRAINING_MODE
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (isAiPlayer[WHITE]) {
|
if (isAiPlayer[WHITE]) {
|
||||||
|
@ -1190,7 +1146,6 @@ bool Game::command(const string &cmd, bool update /* = true */)
|
||||||
// 浏览历史局面,通过command函数刷新局面显示
|
// 浏览历史局面,通过command函数刷新局面显示
|
||||||
bool Game::phaseChange(int row, bool forceUpdate)
|
bool Game::phaseChange(int row, bool forceUpdate)
|
||||||
{
|
{
|
||||||
#ifndef TRAINING_MODE
|
|
||||||
// 如果row是当前浏览的棋谱行,则不需要刷新
|
// 如果row是当前浏览的棋谱行,则不需要刷新
|
||||||
if (currentRow == row && !forceUpdate)
|
if (currentRow == row && !forceUpdate)
|
||||||
return false;
|
return false;
|
||||||
|
@ -1212,23 +1167,17 @@ bool Game::phaseChange(int row, bool forceUpdate)
|
||||||
|
|
||||||
// 刷新棋局场景
|
// 刷新棋局场景
|
||||||
updateScence(position);
|
updateScence(position);
|
||||||
#endif // TRAINING_MODE
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Game::updateScence()
|
bool Game::updateScence()
|
||||||
{
|
{
|
||||||
#ifndef TRAINING_MODE
|
|
||||||
return updateScence(position);
|
return updateScence(position);
|
||||||
#else
|
|
||||||
return true;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Game::updateScence(Position &p)
|
bool Game::updateScence(Position &p)
|
||||||
{
|
{
|
||||||
#ifndef TRAINING_MODE
|
|
||||||
const Piece *board = p.get_board();
|
const Piece *board = p.get_board();
|
||||||
QPointF pos;
|
QPointF pos;
|
||||||
|
|
||||||
|
@ -1377,17 +1326,14 @@ bool Game::updateScence(Position &p)
|
||||||
|
|
||||||
setTips();
|
setTips();
|
||||||
|
|
||||||
#endif // !TRAINING_MODE
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef NET_FIGHT_SUPPORT
|
#ifdef NET_FIGHT_SUPPORT
|
||||||
void Game::showNetworkWindow()
|
void Game::showNetworkWindow()
|
||||||
{
|
{
|
||||||
#ifndef TRAINING_MODE
|
|
||||||
getServer()->show();
|
getServer()->show();
|
||||||
getClient()->show();
|
getClient()->show();
|
||||||
#endif // TRAINING_MODE
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -81,9 +81,7 @@ class Game : public QObject
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Game(
|
explicit Game(
|
||||||
#ifndef TRAINING_MODE
|
|
||||||
GameScene &scene,
|
GameScene &scene,
|
||||||
#endif
|
|
||||||
QObject *parent = nullptr
|
QObject *parent = nullptr
|
||||||
);
|
);
|
||||||
~Game() override;
|
~Game() override;
|
||||||
|
@ -390,10 +388,8 @@ private:
|
||||||
// 2个AI的线程
|
// 2个AI的线程
|
||||||
Thread *aiThread[COLOR_NB];
|
Thread *aiThread[COLOR_NB];
|
||||||
|
|
||||||
#ifndef TRAINING_MODE
|
|
||||||
// 棋局的场景类
|
// 棋局的场景类
|
||||||
GameScene &scene;
|
GameScene &scene;
|
||||||
#endif
|
|
||||||
|
|
||||||
// 所有棋子
|
// 所有棋子
|
||||||
vector<PieceItem *> pieceList;
|
vector<PieceItem *> pieceList;
|
||||||
|
|
|
@ -158,12 +158,8 @@ void MillGameWindow::initialize()
|
||||||
if (game)
|
if (game)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#ifndef TRAINING_MODE
|
|
||||||
// 开辟一个新的游戏控制器
|
// 开辟一个新的游戏控制器
|
||||||
game = new Game(*scene, this);
|
game = new Game(*scene, this);
|
||||||
#else
|
|
||||||
game = new Game(this);
|
|
||||||
#endif // TRAINING_MODE
|
|
||||||
|
|
||||||
// 添加新菜单栏动作
|
// 添加新菜单栏动作
|
||||||
map<int, QStringList> actions = game->getActions();
|
map<int, QStringList> actions = game->getActions();
|
||||||
|
|
|
@ -29,7 +29,6 @@ QString APP_FILENAME_DEFAULT = "MillGame";
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
|
|
||||||
#ifndef TRAINING_MODE
|
|
||||||
#ifndef UCT_DEMO
|
#ifndef UCT_DEMO
|
||||||
|
|
||||||
QString getAppFileName()
|
QString getAppFileName()
|
||||||
|
@ -63,5 +62,4 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // !UCT_DEMO
|
#endif // !UCT_DEMO
|
||||||
#endif // !TRAINING_MODE
|
|
||||||
#endif // QT_GUI_LIB
|
#endif // QT_GUI_LIB
|
||||||
|
|
Loading…
Reference in New Issue