ext: 深度延伸默认启用并且改为做成菜单选项

This commit is contained in:
Calcitem 2020-04-02 23:43:37 +08:00
parent 91aea3c003
commit c8b1fee7a5
8 changed files with 45 additions and 13 deletions

View File

@ -319,6 +319,7 @@
<string>算法(&amp;A)</string>
</property>
<addaction name="actionIDS_I"/>
<addaction name="actionDepthExtension_D"/>
</widget>
<addaction name="menu_F"/>
<addaction name="menu_C"/>
@ -1235,6 +1236,17 @@
<string>迭代加深(&amp;I)</string>
</property>
</action>
<action name="actionDepthExtension_D">
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="text">
<string>深度延伸(&amp;D)</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>

View File

@ -78,12 +78,6 @@
#define SORT_MOVE_WITH_HUMAN_KNOWLEDGES
//#define DEAL_WITH_HORIZON_EFFECT
#ifdef DEAL_WITH_HORIZON_EFFECT
#define HORIZON_EFFECT_ONLY_ONE_MOVE
#endif
//#define IDS_WINDOW
//#define IDS_DEBUG
//#define IDS_ADD_VALUE

View File

@ -863,17 +863,11 @@ value_t AIAlgorithm::search(depth_t depth, value_t alpha, value_t beta, Node *no
doMove(node->children[i]->move);
#ifdef DEAL_WITH_HORIZON_EFFECT
if (false
#ifdef HORIZON_EFFECT_ONLY_ONE_MOVE
|| nchild == 1
#endif // HORIZON_EFFECT_ONLY_ONE_MOVE
) {
if (gameOptions.getDepthExtension() == true && nchild == 1) {
epsilon = 1;
} else {
epsilon = 0;
}
#endif // DEAL_WITH_HORIZON_EFFECT
#ifdef DEEPER_IF_ONLY_ONE_LEGAL_MOVE
if (node->childrenSize == 1) {

View File

@ -88,3 +88,15 @@ bool Options::getIDSEnabled()
{
return IDSEnabled;
}
// DepthExtension
void Options::setDepthExtension(bool enabled)
{
depthExtension = enabled;
}
bool Options::getDepthExtension()
{
return depthExtension;
}

View File

@ -43,6 +43,10 @@ public:
void setIDSEnabled(bool enabled);
bool getIDSEnabled();
// DepthExtension
void setDepthExtension(bool enabled);
bool getDepthExtension();
protected:
private:
@ -67,6 +71,9 @@ private:
// Alpha-Beta 搜索时是否迭代加深
bool IDSEnabled { false };
// DepthExtension
bool depthExtension {true};
};
extern Options gameOptions;

View File

@ -437,6 +437,12 @@ void GameController::setIDS(bool enabled)
gameOptions.setIDSEnabled(enabled);
}
// DepthExtension
void GameController::setDepthExtension(bool enabled)
{
gameOptions.setDepthExtension(enabled);
}
// 上下翻转
void GameController::flip()
{

View File

@ -180,6 +180,9 @@ public slots:
// Alpha-Beta 搜索时是否迭代加深
void setIDS(bool enabled);
// DepthExtension
void setDepthExtension(bool enabled);
// 上下翻转
void flip();

View File

@ -245,6 +245,10 @@ void MillGameWindow::initialize()
connect(ui.actionIDS_I, SIGNAL(toggled(bool)),
gameController, SLOT(setIDS(bool)));
// DepthExtension
connect(ui.actionDepthExtension_D, SIGNAL(toggled(bool)),
gameController, SLOT(setDepthExtension(bool)));
// 视图上下翻转
connect(ui.actionFlip_F, &QAction::triggered,
gameController, &GameController::flip);