settings: Support draw on human experience

This commit is contained in:
Calcitem 2021-06-11 23:17:49 +08:00
parent 881c003791
commit e2b7a37170
14 changed files with 89 additions and 7 deletions

View File

@ -321,6 +321,7 @@
<string>AI</string>
</property>
<addaction name="actionPerfect_AI"/>
<addaction name="actionDrawOnHumanExperience"/>
<addaction name="actionIDS_I"/>
<addaction name="actionDepthExtension_D"/>
<addaction name="actionAiIsLazy"/>
@ -1325,6 +1326,17 @@
<string>Lazy Mode</string>
</property>
</action>
<action name="actionDrawOnHumanExperience">
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="text">
<string>Draw On Human Experience</string>
</property>
</action>
<action name="actionDeveloperMode">
<property name="checkable">
<bool>true</bool>

View File

@ -426,7 +426,7 @@ void move_priority_list_shuffle()
bool is_star_squares_full(Position *pos)
{
bool ret = false;
if (rule.hasDiagonalLines) {
ret = (pos->get_board()[SQ_17] &&
pos->get_board()[SQ_19] &&
@ -455,11 +455,11 @@ Depth get_search_depth(const Position *pos)
if (pos->phase == Phase::placing) {
const Depth placingDepthTable[] = {
+1, 1, +1, 1, /* 0 ~ 3 */
+3, 0 +0, 0, /* 4 ~ 7 */
+0, 0 +0, 0, /* 8 ~ 11 */
+0, 0 +0, 0, /* 12 ~ 15 */
+0, 0 +0, 0, /* 16 ~ 19 */
+0, 0 +0, 0, /* 20 ~ 23 */
+3, 0 + 0, 0, /* 4 ~ 7 */
+0, 0 + 0, 0, /* 8 ~ 11 */
+0, 0 + 0, 0, /* 12 ~ 15 */
+0, 0 + 0, 0, /* 16 ~ 19 */
+0, 0 + 0, 0, /* 20 ~ 23 */
+0 /* 24 */
};
@ -477,7 +477,7 @@ Depth get_search_depth(const Position *pos)
} else {
return d;
}
}
}
}

View File

@ -167,6 +167,20 @@ public:
return openingBook;
}
// DrawOnHumanExperience
void setDrawOnHumanExperience(bool enabled) noexcept
{
drawOnHumanExperience = enabled;
}
bool getDrawOnHumanExperience() const noexcept
{
return drawOnHumanExperience;
}
// Developer Mode
void setDeveloperMode(bool enabled) noexcept
{
developerMode = enabled;
@ -196,6 +210,7 @@ private:
bool IDSEnabled { false };
bool depthExtension {true};
bool openingBook { false };
bool drawOnHumanExperience { true };
bool developerMode { false };
};

View File

@ -75,6 +75,11 @@ void on_random_move(const Option &o)
gameOptions.setShufflingEnabled((bool)o);
}
void on_drawOnHumanExperience(const Option &o)
{
gameOptions.setDrawOnHumanExperience((bool)o);
}
void on_developerMode(const Option &o)
{
gameOptions.setDeveloperMode((bool)o);
@ -176,6 +181,7 @@ void init(OptionsMap &o)
o["UCI_Elo"] << Option(1350, 1350, 2850);
o["Shuffling"] << Option(true, on_random_move);
o["DrawOnHumanExperience"] << Option(true, on_drawOnHumanExperience);
o["DeveloperMode"] << Option(true, on_developerMode);
// Rules

View File

@ -41,6 +41,7 @@ class Config {
static bool idsEnabled = false;
static bool depthExtension = true;
static bool openingBook = false;
static bool drawOnHumanExperience = true;
static bool developerMode = false;
static bool experimentsEnabled = false;
@ -101,6 +102,7 @@ class Config {
Config.idsEnabled = settings['IdsEnabled'] ?? false;
Config.depthExtension = settings['DepthExtension'] ?? false;
Config.openingBook = settings['OpeningBook'] ?? false;
Config.drawOnHumanExperience = settings['DrawOnHumanExperience'] ?? true;
Config.developerMode = settings['DeveloperMode'] ?? false;
Config.experimentsEnabled = settings['ExperimentsEnabled'] ?? false;
@ -182,6 +184,7 @@ class Config {
settings['IdsEnabled'] = Config.idsEnabled;
settings['DepthExtension'] = Config.depthExtension;
settings['OpeningBook'] = Config.openingBook;
settings['DrawOnHumanExperience'] = Config.drawOnHumanExperience;
settings['DeveloperMode'] = Config.developerMode;
settings['ExperimentsEnabled'] = Config.experimentsEnabled;

View File

@ -138,6 +138,8 @@ class NativeEngine extends Engine {
}
await send('setoption name DeveloperMode value ${Config.developerMode}');
await send(
'setoption name DrawOnHumanExperience value ${Config.drawOnHumanExperience}');
await send('setoption name SkillLevel value ${Config.skillLevel}');
await send('setoption name MoveTime value ${Config.moveTime}');
await send('setoption name AiIsLazy value ${Config.aiIsLazy}');

View File

@ -980,6 +980,10 @@
"@developerMode": {
"description": "Developer mode"
},
"drawOnHumanExperience": "Auf menschliche Erfahrung zurückgreifen",
"@drawOnHumanExperience": {
"description": "Draw on human experience"
},
"pieceCount": "Anzahl Steine",
"@pieceCount": {
"description": "Piece count"

View File

@ -980,6 +980,10 @@
"@developerMode": {
"description": "Developer mode"
},
"drawOnHumanExperience": "Draw on human experience",
"@drawOnHumanExperience": {
"description": "Draw on human experience"
},
"pieceCount": "Piece count",
"@pieceCount": {
"description": "Piece count"

View File

@ -980,6 +980,10 @@
"@developerMode": {
"description": "Developer mode"
},
"drawOnHumanExperience": "از تجربه بشر استفاده کنید",
"@drawOnHumanExperience": {
"description": "Draw on human experience"
},
"pieceCount": "تعداد قطعه",
"@pieceCount": {
"description": "Piece count"

View File

@ -245,6 +245,7 @@
"personalization": "外观设置",
"forDevelopers": "开发者选项",
"developerMode": "开发者模式",
"drawOnHumanExperience": "借鉴人类经验",
"pieceCount": "棋子数",
"inHand": "手上",
"onBoard": "棋盘上",

View File

@ -205,6 +205,13 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
SettingsCard(
context: context,
children: <Widget>[
SettingsSwitchListTile(
context: context,
value: Config.drawOnHumanExperience,
onChanged: setDrawOnHumanExperience,
titleString: S.of(context).drawOnHumanExperience,
),
ListItemDivider(),
SettingsSwitchListTile(
context: context,
value: Config.aiIsLazy,
@ -369,6 +376,16 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
Config.save();
}
setDrawOnHumanExperience(bool value) async {
setState(() {
Config.drawOnHumanExperience = value;
});
print("[config] drawOnHumanExperience: $value");
Config.save();
}
setIsAutoRestart(bool value) async {
setState(() {
Config.isAutoRestart = value;

View File

@ -135,6 +135,7 @@ void Game::loadSettings()
setAnimation(empty ? true : settings->value("Options/Animation").toBool());
setSkillLevel(empty ? 1 : settings->value("Options/SkillLevel").toInt());
setMoveTime(empty ? 1 : settings->value("Options/MoveTime").toInt());
setDrawOnHumanExperience(empty ? true : settings->value("Options/DrawOnHumanExperience").toBool());
setAiIsLazy(empty ? false : settings->value("Options/AiIsLazy").toBool());
setShuffling(empty ? true : settings->value("Options/Shuffling").toBool());
setResignIfMostLose(empty ? false : settings->value("Options/ResignIfMostLose").toBool());
@ -581,6 +582,12 @@ void Game::setMoveTime(int val)
settings->setValue("Options/MoveTime", val);
}
void Game::setDrawOnHumanExperience(bool enabled)
{
gameOptions.setDrawOnHumanExperience(enabled);
settings->setValue("Options/DrawOnHumanExperience", enabled);
}
void Game::setAiIsLazy(bool enabled)
{
gameOptions.setAiIsLazy(enabled);

View File

@ -239,6 +239,9 @@ public slots:
// Move Time
void setMoveTime(int val);
// Draw on human experience
void setDrawOnHumanExperience(bool enabled);
// AI is Lazy
void setAiIsLazy(bool enabled);

View File

@ -205,6 +205,9 @@ void MillGameWindow::initialize()
connect(ui.actionAnimation_A, SIGNAL(toggled(bool)),
game, SLOT(setAnimation(bool)));
connect(ui.actionDrawOnHumanExperience, SIGNAL(toggled(bool)),
game, SLOT(setDrawOnHumanExperience(bool)));
connect(ui.actionAiIsLazy, SIGNAL(toggled(bool)),
game, SLOT(setAiIsLazy(bool)));
@ -389,6 +392,7 @@ void MillGameWindow::initialize()
ui.actionSound_S->setChecked(game->soundEnabled());
ui.actionAnimation_A->setChecked(game->animationEnabled());
ui.actionDrawOnHumanExperience->setChecked(gameOptions.getDrawOnHumanExperience());
ui.actionAiIsLazy->setChecked(gameOptions.getAiIsLazy());
ui.actionShuffling_R->setChecked(gameOptions.getShufflingEnabled());
ui.actionPerfect_AI->setChecked(gameOptions.getPerfectAiEnabled());