diff --git a/include/config.h b/include/config.h index aa87d578..a9910542 100644 --- a/include/config.h +++ b/include/config.h @@ -45,8 +45,6 @@ //#define MOBILE_APP_UI -//#define TRAINING_MODE - //#define TEST_MODE //#define UCT_DEMO diff --git a/millgame.pro b/millgame.pro index b8efadb0..b5ebe46c 100644 --- a/millgame.pro +++ b/millgame.pro @@ -26,7 +26,6 @@ SOURCES += \ src/movegen.cpp \ src/movepick.cpp \ src/thread.cpp \ - src/trainer.cpp \ src/tt.cpp \ src/misc.cpp \ src/uci.cpp \ @@ -58,7 +57,6 @@ HEADERS += \ src/movegen.h \ src/movepick.h \ src/thread.h \ - src/trainer.h \ src/tt.h \ src/hashnode.h \ src/debug.h \ diff --git a/millgame.vcxproj b/millgame.vcxproj index 996e6605..4ab0d1c8 100644 --- a/millgame.vcxproj +++ b/millgame.vcxproj @@ -462,7 +462,6 @@ - @@ -733,7 +732,6 @@ - diff --git a/millgame.vcxproj.filters b/millgame.vcxproj.filters index d4c06b13..a3316b2e 100644 --- a/millgame.vcxproj.filters +++ b/millgame.vcxproj.filters @@ -105,9 +105,6 @@ Header Files - - Header Files - Header Files @@ -305,9 +302,6 @@ Source Files - - Source Files - Source Files diff --git a/src/search.cpp b/src/search.cpp index fd982b6d..e6ffa8a0 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -114,8 +114,6 @@ int Thread::search() posKeyHistory.push_back(key); #endif // UCI_DO_BEST_MOVE - //sync_cout << "posKeyHistory Size = " << posKeyHistory.size(); - //std::cout << sync_endl; assert(posKeyHistory.size() < 256); } diff --git a/src/trainer.cpp b/src/trainer.cpp deleted file mode 100644 index b25dab0a..00000000 --- a/src/trainer.cpp +++ /dev/null @@ -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 . -*/ - -#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 diff --git a/src/trainer.h b/src/trainer.h deleted file mode 100644 index c6ba5ece..00000000 --- a/src/trainer.h +++ /dev/null @@ -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 . -*/ - -#ifndef TRAINER_H -#define TRAINER_H - -#include "config.h" - -#endif // TRAINER_H diff --git a/src/ui/flutter/android/app/CMakeLists.txt b/src/ui/flutter/android/app/CMakeLists.txt index 87f757d6..e0a7040a 100644 --- a/src/ui/flutter/android/app/CMakeLists.txt +++ b/src/ui/flutter/android/app/CMakeLists.txt @@ -26,7 +26,6 @@ add_library( # Sets the name of the library. ../../../../rule.cpp ../../../../search.cpp ../../../../thread.cpp - ../../../../trainer.cpp ../../../../tt.cpp ../../../../uci.cpp ../../../../ucioption.cpp) diff --git a/src/ui/qt/game.cpp b/src/ui/qt/game.cpp index d53af240..be09e839 100644 --- a/src/ui/qt/game.cpp +++ b/src/ui/qt/game.cpp @@ -42,15 +42,11 @@ using namespace std; Game::Game( -#ifndef TRAINING_MODE GameScene & scene, -#endif QObject * parent ) : QObject(parent), -#ifndef TRAINING_MODE scene(scene), -#endif currentPiece(nullptr), currentRow(-1), isEditing(false), @@ -94,7 +90,6 @@ Game::Game( #endif // QT_GUI_LIB #ifdef NET_FIGHT_SUPPORT -#ifndef TRAINING_MODE server = new Server(nullptr, 30001); // TODO: WARNING: ThreadSanitizer: data race uint16_t clientPort = server->getPort() == 30001 ? 30002 : 30001; client = new Client(nullptr, clientPort); @@ -102,7 +97,6 @@ Game::Game( // 关联AI和网络类的着法命令行 connect(getClient(), SIGNAL(command(const string &, bool)), this, SLOT(command(const string &, bool))); -#endif // TRAINING_MODE #endif // NET_FIGHT_SUPPORT #ifdef ENDGAME_LEARNING_FORCE @@ -143,7 +137,6 @@ const map Game::getActions() // 之所以不用信号和槽的模式,是因为发信号的时候槽还来不及关联 map actions; -#ifndef TRAINING_MODE for (int i = 0; i < N_RULES; i++) { // map的key存放int索引值,value存放规则名称和规则提示 QStringList strlist; @@ -151,7 +144,6 @@ const map Game::getActions() strlist.append(tr(RULES[i].description)); actions.insert(map::value_type(i, strlist)); } -#endif // TRAINING_MODE return actions; } @@ -217,7 +209,6 @@ void Game::gameReset() resetAiPlayers(); } -#ifndef TRAINING_MODE // 清除棋子 qDeleteAll(pieceList); pieceList.clear(); @@ -305,19 +296,15 @@ void Game::gameReset() // 播放音效 //playSound(":/sound/resources/sound/newgame.wav"); -#endif // TRAINING_MODE } void Game::setEditing(bool arg) { -#ifndef TRAINING_MODE isEditing = arg; -#endif } void Game::setInvert(bool arg) { -#ifndef TRAINING_MODE isInverted = arg; // 遍历所有棋子 @@ -335,7 +322,6 @@ void Game::setInvert(bool arg) pieceItem->update(); } } -#endif // TRAINING_MODE } 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) { -#ifndef TRAINING_MODE hasAnimation = arg; // 默认动画时间500ms @@ -419,14 +404,11 @@ void Game::setAnimation(bool arg) durationTime = 500; else durationTime = 0; -#endif // TRAINING_MODE } void Game::setSound(bool arg) { -#ifndef TRAINING_MODE hasSound = arg; -#endif // TRAINING_MODE } void Game::playSound(GameSound soundType, Color c) @@ -521,7 +503,6 @@ void Game::playSound(GameSound soundType, Color c) #ifndef DONOT_PLAY_SOUND QString soundPath = QString::fromStdString(soundDir + filename); -#ifndef TRAINING_MODE if (soundPath == "") { return; } @@ -530,7 +511,6 @@ void Game::playSound(GameSound soundType, Color c) QSound::play(soundPath); } #endif /* ! DONOT_PLAY_SOUND */ -#endif // TRAINING_MODE } void Game::setResignIfMostLose(bool enabled) @@ -584,7 +564,6 @@ void Game::setOpeningBook(bool enabled) // 上下翻转 void Game::flip() { -#ifndef TRAINING_MODE stopAndWaitAiThreads(); position.mirror(moveHistory); @@ -604,13 +583,11 @@ void Game::flip() threadsSetAi(&position); startAiThreads(); -#endif // TRAINING_MODE } // 左右镜像 void Game::mirror() { -#ifndef TRAINING_MODE stopAndWaitAiThreads(); position.mirror(moveHistory); @@ -632,13 +609,11 @@ void Game::mirror() threadsSetAi(&position); startAiThreads(); -#endif // TRAINING_MODE } // 视图须时针旋转90° void Game::turnRight() { -#ifndef TRAINING_MODE stopAndWaitAiThreads(); position.rotate(moveHistory, -90); @@ -658,13 +633,11 @@ void Game::turnRight() threadsSetAi(&position); startAiThreads(); -#endif } // 视图逆时针旋转90° void Game::turnLeft() { -#ifndef TRAINING_MODE stopAndWaitAiThreads(); position.rotate(moveHistory, 90); @@ -680,7 +653,6 @@ void Game::turnLeft() threadsSetAi(&position); startAiThreads(); -#endif // TRAINING_MODE } void Game::updateTime() @@ -735,7 +707,6 @@ void Game::timerEvent(QTimerEvent *event) // 定时器ID为0 timeID = 0; -#ifndef TRAINING_MODE // 发信号更新状态栏 updateScence(); message = QString::fromStdString(getTips()); @@ -748,7 +719,6 @@ void Game::timerEvent(QTimerEvent *event) #ifndef DONOT_PLAY_WIN_SOUND playSound(GameSound::win, winner); #endif -#endif // TRAINING_MODE } // 测试用代码 @@ -782,7 +752,6 @@ bool Game::isAIsTurn() // 关键槽函数,根据QGraphicsScene的信号和状态来执行选子、落子或去子 bool Game::actionPiece(QPointF p) { -#ifndef TRAINING_MODE // 点击非落子点,不执行 File f; Rank r; @@ -939,9 +908,6 @@ bool Game::actionPiece(QPointF p) sideToMove = position.side_to_move(); updateScence(); return result; -#else - return true; -#endif // TRAINING_MODE } @@ -953,8 +919,6 @@ bool Game::resign() return false; } -#ifndef TRAINING_MODE - // 将新增的棋谱行插入到ListModel currentRow = manualListModel.rowCount() - 1; int k = 0; @@ -971,7 +935,6 @@ bool Game::resign() if (position.get_winner() != NOBODY) { playSound(GameSound::resign, position.side_to_move()); } -#endif // TRAINING_MODE return result; } @@ -982,9 +945,7 @@ bool Game::command(const string &cmd, bool update /* = true */) int total; float bwinrate, wwinrate, drawrate; -#ifndef TRAINING_MODE Q_UNUSED(hasSound) -#endif #ifdef QT_GUI_LIB // 防止接收滞后结束的线程发送的指令 @@ -995,7 +956,6 @@ bool Game::command(const string &cmd, bool update /* = true */) return false; #endif // QT_GUI_LIB -#ifndef TRAINING_MODE // 声音 GameSound soundType = GameSound::none; @@ -1010,7 +970,7 @@ bool Game::command(const string &cmd, bool update /* = true */) default: break; } -#endif +//#endif // 如果未开局则开局 if (position.get_phase() == Phase::ready) { @@ -1026,7 +986,6 @@ bool Game::command(const string &cmd, bool update /* = true */) sideToMove = position.side_to_move(); -#ifndef TRAINING_MODE if (soundType == GameSound::drog && position.get_action() == Action::remove) { soundType = GameSound::mill; } @@ -1072,7 +1031,6 @@ bool Game::command(const string &cmd, bool update /* = true */) playSound(GameSound::win, winner); } #endif -#endif // TRAINING_MODE // AI设置 // 如果还未决出胜负 @@ -1157,10 +1115,8 @@ bool Game::command(const string &cmd, bool update /* = true */) gameTest->writeToMemory(QString::fromStdString(cmd)); #ifdef NET_FIGHT_SUPPORT -#ifndef TRAINING_MODE // 网络: 将着法放到服务器的发送列表中 getServer()->setAction(QString::fromStdString(cmd)); -#endif // TRAINING_MODE #endif if (isAiPlayer[WHITE]) { @@ -1190,7 +1146,6 @@ bool Game::command(const string &cmd, bool update /* = true */) // 浏览历史局面,通过command函数刷新局面显示 bool Game::phaseChange(int row, bool forceUpdate) { -#ifndef TRAINING_MODE // 如果row是当前浏览的棋谱行,则不需要刷新 if (currentRow == row && !forceUpdate) return false; @@ -1212,23 +1167,17 @@ bool Game::phaseChange(int row, bool forceUpdate) // 刷新棋局场景 updateScence(position); -#endif // TRAINING_MODE return true; } bool Game::updateScence() { -#ifndef TRAINING_MODE return updateScence(position); -#else - return true; -#endif } bool Game::updateScence(Position &p) { -#ifndef TRAINING_MODE const Piece *board = p.get_board(); QPointF pos; @@ -1377,17 +1326,14 @@ bool Game::updateScence(Position &p) setTips(); -#endif // !TRAINING_MODE return true; } #ifdef NET_FIGHT_SUPPORT void Game::showNetworkWindow() { -#ifndef TRAINING_MODE getServer()->show(); getClient()->show(); -#endif // TRAINING_MODE } #endif diff --git a/src/ui/qt/game.h b/src/ui/qt/game.h index 45fc255f..1d7b73a2 100644 --- a/src/ui/qt/game.h +++ b/src/ui/qt/game.h @@ -81,9 +81,7 @@ class Game : public QObject public: explicit Game( -#ifndef TRAINING_MODE GameScene &scene, -#endif QObject *parent = nullptr ); ~Game() override; @@ -390,10 +388,8 @@ private: // 2个AI的线程 Thread *aiThread[COLOR_NB]; -#ifndef TRAINING_MODE // 棋局的场景类 GameScene &scene; -#endif // 所有棋子 vector pieceList; diff --git a/src/ui/qt/gamewindow.cpp b/src/ui/qt/gamewindow.cpp index a2441c70..d22ff1d1 100644 --- a/src/ui/qt/gamewindow.cpp +++ b/src/ui/qt/gamewindow.cpp @@ -158,12 +158,8 @@ void MillGameWindow::initialize() if (game) return; -#ifndef TRAINING_MODE // 开辟一个新的游戏控制器 game = new Game(*scene, this); -#else - game = new Game(this); -#endif // TRAINING_MODE // 添加新菜单栏动作 map actions = game->getActions(); diff --git a/src/ui/qt/winmain.cpp b/src/ui/qt/winmain.cpp index d6b71524..eac48e38 100644 --- a/src/ui/qt/winmain.cpp +++ b/src/ui/qt/winmain.cpp @@ -29,7 +29,6 @@ QString APP_FILENAME_DEFAULT = "MillGame"; #include #include -#ifndef TRAINING_MODE #ifndef UCT_DEMO QString getAppFileName() @@ -63,5 +62,4 @@ int main(int argc, char *argv[]) } #endif // !UCT_DEMO -#endif // !TRAINING_MODE #endif // QT_GUI_LIB