perfect: Fix build errors
This commit is contained in:
parent
726c8a4223
commit
4c7088713a
|
@ -264,7 +264,7 @@
|
|||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>.\GeneratedFiles\$(ConfigurationName);.\GeneratedFiles;.;$(QTDIR)\include;debug;\include;$(QTDIR)\mkspecs\win32-msvc;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtMultimedia;$(QTDIR)\include\QtMultimediaWidgets;$(QTDIR)\include\QtNetwork;$(QTDIR)\include\QtNetworkAuth;$(QTDIR)\include\QtWidgets;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalOptions>-Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions>-Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 /D_HAS_STD_BYTE=0 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AssemblerListingLocation>debug\</AssemblerListingLocation>
|
||||
<BrowseInformation>false</BrowseInformation>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
|
@ -469,6 +469,7 @@
|
|||
<ClInclude Include="src\perfect\miniMaxAI.h" />
|
||||
<ClInclude Include="src\perfect\miniMaxWin.h" />
|
||||
<ClInclude Include="src\perfect\miniMax_retroAnalysis.h" />
|
||||
<ClInclude Include="src\perfect\perfect.h" />
|
||||
<ClInclude Include="src\perfect\perfectAI.h" />
|
||||
<ClInclude Include="src\perfect\randomAI.h" />
|
||||
<ClInclude Include="src\perfect\strLib.h" />
|
||||
|
@ -754,6 +755,7 @@
|
|||
<ClCompile Include="src\perfect\miniMax_statistics.cpp" />
|
||||
<ClCompile Include="src\perfect\miniMax_test.cpp" />
|
||||
<ClCompile Include="src\perfect\minMaxAI.cpp" />
|
||||
<ClCompile Include="src\perfect\perfect.cpp" />
|
||||
<ClCompile Include="src\perfect\perfectAI.cpp" />
|
||||
<ClCompile Include="src\perfect\randomAI.cpp" />
|
||||
<ClCompile Include="src\perfect\strLib.cpp" />
|
||||
|
|
|
@ -162,6 +162,9 @@
|
|||
<ClInclude Include="src\perfect\threadManager.h">
|
||||
<Filter>Perfect AI Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\perfect\perfect.h">
|
||||
<Filter>Perfect AI Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CustomBuild Include="debug\moc_predefs.h.cbt">
|
||||
|
@ -446,6 +449,9 @@
|
|||
<ClCompile Include="src\perfect\threadManager.cpp">
|
||||
<Filter>Perfect AI Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\perfect\perfect.cpp">
|
||||
<Filter>Perfect AI Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="millgame.rc">
|
||||
|
|
|
@ -0,0 +1,99 @@
|
|||
#include "perfect.h"
|
||||
|
||||
|
||||
// Perfect AI
|
||||
Mill *mill;
|
||||
PerfectAI *ai;
|
||||
|
||||
int perfect_init(void)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
char databaseDirectory[] = "D:\\database";
|
||||
#elif _RELEASE_X64
|
||||
char databaseDirectory[] = "";
|
||||
#endif
|
||||
|
||||
mill = new Mill();
|
||||
ai = new PerfectAI(databaseDirectory);
|
||||
ai->setDatabasePath(databaseDirectory);
|
||||
mill->beginNewGame(ai, ai, fieldStruct::playerOne);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Square perfect_sq_to_sq(unsigned int sq)
|
||||
{
|
||||
Square map[] = {
|
||||
SQ_31, SQ_24, SQ_25, SQ_23, SQ_16, SQ_17, SQ_15, SQ_8,
|
||||
SQ_9, SQ_30, SQ_22, SQ_14, SQ_10, SQ_18, SQ_26, SQ_13,
|
||||
SQ_12, SQ_11, SQ_21, SQ_20, SQ_19, SQ_29, SQ_28, SQ_27,
|
||||
SQ_0 };
|
||||
|
||||
return map[sq];
|
||||
}
|
||||
|
||||
Move perfect_move_to_move(unsigned int from, unsigned int to)
|
||||
{
|
||||
if (mill->mustStoneBeRemoved())
|
||||
return (Move)-perfect_sq_to_sq(to);
|
||||
else if (mill->inSettingPhase())
|
||||
return (Move)perfect_sq_to_sq(to);
|
||||
else
|
||||
return (Move)(make_move(perfect_sq_to_sq(from), perfect_sq_to_sq(to)));
|
||||
}
|
||||
|
||||
unsigned sq_to_perfect_sq(Square sq)
|
||||
{
|
||||
int map[] = {
|
||||
-1, -1, -1, -1, -1, -1, -1, -1,
|
||||
7, 8, 12, 17, 16, 15, 11, 6, /* 8 - 15 */
|
||||
4, 5, 13, 20, 19, 18, 10, 3, /* 16 - 23 */
|
||||
1, 2, 14, 23, 22, 21, 9, 0, /* 24 - 31 */
|
||||
-1, -1, -1, -1, -1, -1, -1, -1,
|
||||
};
|
||||
|
||||
return map[sq];
|
||||
}
|
||||
|
||||
void move_to_perfect_move(Move move, unsigned int &from, unsigned int &to)
|
||||
{
|
||||
Square f = from_sq(move);
|
||||
Square t = to_sq(move);
|
||||
|
||||
if (mill->mustStoneBeRemoved()) {
|
||||
from = fieldStruct::size;
|
||||
to = sq_to_perfect_sq(t);
|
||||
} else if (mill->inSettingPhase()) {
|
||||
from = fieldStruct::size;
|
||||
to = sq_to_perfect_sq(t);
|
||||
} else {
|
||||
from = sq_to_perfect_sq(f);
|
||||
to = sq_to_perfect_sq(t);
|
||||
}
|
||||
}
|
||||
|
||||
Move perfect_search()
|
||||
{
|
||||
unsigned int from, to;
|
||||
mill->getComputersChoice(&from, &to);
|
||||
|
||||
cout << "\nlast move was from " << (char)(mill->getLastMoveFrom() + 'a') << " to " << (char)(mill->getLastMoveTo() + 'a') << "\n\n";
|
||||
|
||||
mill->printBoard();
|
||||
|
||||
return perfect_move_to_move(mill->getLastMoveFrom(), mill->getLastMoveTo());
|
||||
}
|
||||
|
||||
bool perfect_do_move(Move move)
|
||||
{
|
||||
bool ret;
|
||||
unsigned int from, to;
|
||||
|
||||
move_to_perfect_move(move, from, to);
|
||||
|
||||
ret = mill->doMove(from, to);
|
||||
return ret;
|
||||
}
|
||||
|
||||
// mill->getWinner() == 0
|
||||
// mill->getCurrentPlayer() == fieldStruct::playerTwo
|
|
@ -0,0 +1,21 @@
|
|||
#ifndef PERFECT_H
|
||||
#define PERFECT_H
|
||||
|
||||
|
||||
#include "mill.h"
|
||||
#include "perfectAI.h"
|
||||
#include "types.h"
|
||||
|
||||
extern Mill *mill;
|
||||
extern PerfectAI *ai;
|
||||
|
||||
// Perfect AI
|
||||
int perfect_init(void);
|
||||
Square perfect_sq_to_sq(unsigned int sq);
|
||||
Move perfect_move_to_move(unsigned int from, unsigned int to);
|
||||
unsigned sq_to_perfect_sq(Square sq);
|
||||
void move_to_perfect_move(Move move, unsigned int &from, unsigned int &to);
|
||||
Move perfect_search();
|
||||
bool perfect_do_move(Move move);
|
||||
|
||||
#endif
|
100
src/thread.cpp
100
src/thread.cpp
|
@ -58,7 +58,7 @@ Thread::Thread(size_t n
|
|||
idx(n), stdThread(&Thread::idle_loop, this),
|
||||
timeLimit(3600)
|
||||
{
|
||||
perfect_init();
|
||||
// perfect_init();
|
||||
|
||||
wait_for_search_finished();
|
||||
}
|
||||
|
@ -695,101 +695,3 @@ void ThreadPool::start_thinking(Position *pos, bool ponderMode)
|
|||
|
||||
main()->start_searching();
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int Thread::perfect_init(void)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
char databaseDirectory[] = "D:\\database";
|
||||
#elif _RELEASE_X64
|
||||
char databaseDirectory[] = "";
|
||||
#endif
|
||||
|
||||
mill = new Mill();
|
||||
ai = new PerfectAI(databaseDirectory);
|
||||
ai->setDatabasePath(databaseDirectory);
|
||||
mill->beginNewGame(ai, ai, fieldStruct::playerOne);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Square Thread::perfect_sq_to_sq(unsigned int sq)
|
||||
{
|
||||
Square map[] = {
|
||||
SQ_31, SQ_24, SQ_25, SQ_23, SQ_16, SQ_17, SQ_15, SQ_8,
|
||||
SQ_9, SQ_30, SQ_22, SQ_14, SQ_10, SQ_18, SQ_26, SQ_13,
|
||||
SQ_12, SQ_11, SQ_21, SQ_20, SQ_19, SQ_29, SQ_28, SQ_27,
|
||||
SQ_0 };
|
||||
|
||||
return map[sq];
|
||||
}
|
||||
|
||||
Move Thread::perfect_move_to_move(unsigned int from, unsigned int to)
|
||||
{
|
||||
if (mill->mustStoneBeRemoved())
|
||||
return (Move)-perfect_sq_to_sq(to);
|
||||
else if (mill->inSettingPhase())
|
||||
return (Move)perfect_sq_to_sq(to);
|
||||
else
|
||||
return (Move)(make_move(perfect_sq_to_sq(from), perfect_sq_to_sq(to)));
|
||||
}
|
||||
|
||||
unsigned Thread::sq_to_perfect_sq(Square sq)
|
||||
{
|
||||
int map[] = {
|
||||
-1, -1, -1, -1, -1, -1, -1, -1,
|
||||
7, 8, 12, 17, 16, 15, 11, 6, /* 8 - 15 */
|
||||
4, 5, 13, 20, 19, 18, 10, 3, /* 16 - 23 */
|
||||
1, 2, 14, 23, 22, 21, 9, 0, /* 24 - 31 */
|
||||
-1, -1, -1, -1, -1, -1, -1, -1,
|
||||
};
|
||||
|
||||
return map[sq];
|
||||
}
|
||||
|
||||
void Thread::move_to_perfect_move(Move move, unsigned int &from, unsigned int &to)
|
||||
{
|
||||
Square f = from_sq(move);
|
||||
Square t = to_sq(move);
|
||||
|
||||
if (mill->mustStoneBeRemoved()) {
|
||||
from = fieldStruct::size;
|
||||
to = sq_to_perfect_sq(t);
|
||||
} else if (mill->inSettingPhase()) {
|
||||
from = fieldStruct::size;
|
||||
to = sq_to_perfect_sq(t);
|
||||
} else {
|
||||
from = sq_to_perfect_sq(f);
|
||||
to = sq_to_perfect_sq(t);
|
||||
}
|
||||
}
|
||||
|
||||
int Thread::perfect_search()
|
||||
{
|
||||
unsigned int from, to;
|
||||
mill->getComputersChoice(&from, &to);
|
||||
|
||||
cout << "\nlast move was from " << (char)(mill->getLastMoveFrom() + 'a') << " to " << (char)(mill->getLastMoveTo() + 'a') << "\n\n";
|
||||
|
||||
mill->printBoard();
|
||||
|
||||
bestMove = perfect_move_to_move(mill->getLastMoveFrom(), mill->getLastMoveTo());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Thread::perfect_do_move(Move move)
|
||||
{
|
||||
bool ret;
|
||||
unsigned int from, to;
|
||||
|
||||
move_to_perfect_move(move, from, to);
|
||||
|
||||
ret = mill->doMove(from, to);
|
||||
return ret;
|
||||
}
|
||||
|
||||
// mill->getWinner() == 0
|
||||
// mill->getCurrentPlayer() == fieldStruct::playerTwo
|
16
src/thread.h
16
src/thread.h
|
@ -29,9 +29,6 @@
|
|||
#include "search.h"
|
||||
#include "thread_win32_osx.h"
|
||||
|
||||
#include "perfect/mill.h"
|
||||
#include "perfect/perfectAI.h"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifdef QT_GUI_LIB
|
||||
|
@ -54,10 +51,6 @@ public:
|
|||
bool exit = false, searching = true; // Set before starting std::thread
|
||||
NativeThread stdThread;
|
||||
|
||||
// Perfect AI
|
||||
Mill *mill;
|
||||
PerfectAI *ai;
|
||||
|
||||
explicit Thread(size_t n
|
||||
#ifdef QT_GUI_LIB
|
||||
, QObject *parent = nullptr
|
||||
|
@ -92,15 +85,6 @@ public:
|
|||
|
||||
void analyze(Color c);
|
||||
|
||||
// Perfect AI
|
||||
int perfect_init(void);
|
||||
Square perfect_sq_to_sq(unsigned int sq);
|
||||
Move perfect_move_to_move(unsigned int from, unsigned int to);
|
||||
unsigned sq_to_perfect_sq(Square sq);
|
||||
void move_to_perfect_move(Move move, unsigned int &from, unsigned int &to);
|
||||
int perfect_search();
|
||||
bool perfect_do_move(Move move);
|
||||
|
||||
#ifdef TIME_STAT
|
||||
TimePoint sortTime{ 0 };
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue