将原来的 main.c 改名为 qt/winmain.c 并增加新的 main.c 给 UCI 使用

This commit is contained in:
Calcitem 2020-07-11 23:41:59 +08:00
parent 68fb9af5cd
commit 8e77d68a4d
6 changed files with 94 additions and 31 deletions

View File

@ -26,6 +26,8 @@
#pragma execution_character_set("utf-8")
#endif
#define QT_UI
//#define MOBILE_APP_UI
//#define TRAINING_MODE

View File

@ -48,7 +48,8 @@ SOURCES += \
src/ui/qt/gamecontroller.cpp \
src/ui/qt/gamescene.cpp \
src/ui/qt/gameview.cpp \
src/ui/qt/client.cpp
src/ui/qt/client.cpp \
src/ui/qt/winmain.cpp \
HEADERS += \
include/config.h \

View File

@ -711,6 +711,7 @@
<ClCompile Include="src\benchmark.cpp" />
<ClCompile Include="src\endgame.cpp" />
<ClCompile Include="src\evaluate.cpp" />
<ClCompile Include="src\main.cpp" />
<ClCompile Include="src\movegen.cpp" />
<ClCompile Include="src\movepick.cpp" />
<ClCompile Include="src\search.cpp" />
@ -726,7 +727,6 @@
<ClCompile Include="src\option.cpp" />
<ClCompile Include="src\position.cpp" />
<ClCompile Include="src\rule.cpp" />
<ClCompile Include="src\main.cpp" />
<ClCompile Include="src\test\test.cpp" />
<ClCompile Include="src\ui\qt\boarditem.cpp" />
<ClCompile Include="src\ui\qt\client.cpp" />
@ -736,6 +736,7 @@
<ClCompile Include="src\ui\qt\gamewindow.cpp" />
<ClCompile Include="src\ui\qt\pieceitem.cpp" />
<ClCompile Include="src\ui\qt\server.cpp" />
<ClCompile Include="src\ui\qt\winmain.cpp" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="millgame.rc" />

View File

@ -287,9 +287,6 @@
</QtMoc>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\test\test.cpp">
<Filter>Qt Files\test</Filter>
</ClCompile>
@ -371,6 +368,12 @@
<ClCompile Include="src\benchmark.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\ui\qt\winmain.cpp">
<Filter>Qt Files</Filter>
</ClCompile>
<ClCompile Include="src\main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="millgame.rc">

View File

@ -1,14 +1,16 @@
/*
Sanmill, a mill game playing engine derived from NineChess 1.5
Copyright (C) 2015-2018 liuweilhy (NineChess author)
Copyright (C) 2019-2020 Calcitem <calcitem@outlook.com>
/*
Fishmill, a UCI Mill Game playing engine derived from Stockfish
Copyright (C) 2004-2008 Tord Romstad (Glaurung author)
Copyright (C) 2008-2015 Marco Costalba, Joona Kiiski, Tord Romstad (Stockfish author)
Copyright (C) 2015-2020 Marco Costalba, Joona Kiiski, Gary Linscott, Tord Romstad (Stockfish author)
Copyright (C) 2020 Calcitem <calcitem@outlook.com>
Sanmill is free software: you can redistribute it and/or modify
Fishmill 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,
Fishmill 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.
@ -17,32 +19,34 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QtWidgets/QApplication>
#include <QDesktopWidget>
#include <iostream>
#include "gamewindow.h"
#include "misc.h"
#include "bitboard.h"
#include "endgame.h"
#include "position.h"
#include "search.h"
#include "thread.h"
#include "tt.h"
#include "uci.h"
QString APP_FILENAME_DEFAULT = "MillGame";
#ifndef QT_UI
#ifndef TRAINING_MODE
#ifndef UCT_DEMO
int main(int argc, char *argv[])
{
Bitboards::init();
int main(int argc, char* argv[]) {
QApplication a(argc, argv);
MillGameWindow w;
w.show();
std::cout << engine_info() << std::endl;
w.setWindowTitle(getAppFileName() + " (" + QString::number(QCoreApplication::applicationPid()) + ")");
UCI::init(Options);
//Tune::init();
Bitboards::init();
//Position::init();
//Bitbases::init();
//Endgames::init();
Threads.set((int)Options["Threads"]);
Search::clear(); // After threads are up
#ifndef _DEBUG
w.move((QApplication::desktop()->width() - w.width()) / 4, (QApplication::desktop()->height() - w.height()) / 2);
#endif
UCI::loop(argc, argv);
return QApplication::exec();
Threads.set(0);
return 0;
}
#endif // !UCT_DEMO
#endif // !TRAINING_MODE
#endif

52
src/ui/qt/winmain.cpp Normal file
View File

@ -0,0 +1,52 @@
/*
Sanmill, a mill game playing engine derived from NineChess 1.5
Copyright (C) 2015-2018 liuweilhy (NineChess author)
Copyright (C) 2019-2020 Calcitem <calcitem@outlook.com>
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/>.
*/
#include <QtWidgets/QApplication>
#include <QDesktopWidget>
#include "gamewindow.h"
#include "misc.h"
#include "bitboard.h"
QString APP_FILENAME_DEFAULT = "MillGame";
#ifdef QT_UI
#ifndef TRAINING_MODE
#ifndef UCT_DEMO
int main(int argc, char *argv[])
{
Bitboards::init();
QApplication a(argc, argv);
MillGameWindow w;
w.show();
w.setWindowTitle(getAppFileName() + " (" + QString::number(QCoreApplication::applicationPid()) + ")");
#ifndef _DEBUG
w.move((QApplication::desktop()->width() - w.width()) / 4, (QApplication::desktop()->height() - w.height()) / 2);
#endif
return QApplication::exec();
}
#endif // !UCT_DEMO
#endif // !TRAINING_MODE
#endif // QT_UI