[gnome-chess] Support passing arguments to UCI go command
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-chess] Support passing arguments to UCI go command
- Date: Sat, 3 Aug 2013 03:33:03 +0000 (UTC)
commit 2b7722b7888c7321e9b85c2f5e88d93f6decee42
Author: Michael Catanzaro <mike catanzaro gmail com>
Date: Fri Aug 2 22:21:18 2013 -0500
Support passing arguments to UCI go command
You can now specify arguments to UCI "go" in engines.conf. An example
command would be "go depth 1" or "go nodes 20" (to expand only 20 nodes
per level), or in combination "go depth 1 nodes 20". See the UCI spec
for a full list of valid commands.
src/ai-profile.vala | 6 ++++++
src/chess-engine-uci.vala | 6 ++++--
src/gnome-chess.vala | 12 ++++++++++--
3 files changed, 20 insertions(+), 4 deletions(-)
---
diff --git a/src/ai-profile.vala b/src/ai-profile.vala
index bf6a97a..ea74103 100644
--- a/src/ai-profile.vala
+++ b/src/ai-profile.vala
@@ -21,6 +21,9 @@ public class AIProfile
public string[] easy_options { get; private set; }
public string[] normal_options { get; private set; }
public string[] hard_options { get; private set; }
+ public string[] easy_uci_go_options { get; private set; }
+ public string[] normal_uci_go_options { get; private set; }
+ public string[] hard_uci_go_options { get; private set; }
public static List<AIProfile> load_ai_profiles (string filename)
{
@@ -57,6 +60,9 @@ public class AIProfile
profile.easy_options = load_array (file, name, "option", "easy");
profile.normal_options = load_array (file, name, "option", "normal");
profile.hard_options = load_array (file, name, "option", "hard");
+ profile.easy_uci_go_options = load_array (file, name, "uci-go-option", "easy");
+ profile.normal_uci_go_options = load_array (file, name, "uci-go-option", "normal");
+ profile.hard_uci_go_options = load_array (file, name, "uci-go-option", "hard");
}
catch (KeyFileError e)
{
diff --git a/src/chess-engine-uci.vala b/src/chess-engine-uci.vala
index 8998756..333e3d3 100644
--- a/src/chess-engine-uci.vala
+++ b/src/chess-engine-uci.vala
@@ -13,12 +13,14 @@ public class ChessEngineUCI : ChessEngine
private char[] buffer;
private string moves;
private string[] options;
+ private string go_options;
private bool waiting_for_move;
- public ChessEngineUCI (string binary, string[] args, string[] options)
+ public ChessEngineUCI (string binary, string[] args, string[] options, string[] go_options)
{
base (binary, args);
this.options = options;
+ this.go_options = string.joinv (" ", go_options);
buffer = new char[0];
moves = "";
starting.connect (start_cb);
@@ -41,7 +43,7 @@ public class ChessEngineUCI : ChessEngine
else
write_line ("position startpos");
waiting_for_move = true;
- write_line ("go wtime 30000 btime 30000");
+ write_line ("go wtime 30000 btime 30000 %s".printf (go_options));
}
public override void report_move (ChessMove move)
diff --git a/src/gnome-chess.vala b/src/gnome-chess.vala
index 932c4fd..db10b8a 100644
--- a/src/gnome-chess.vala
+++ b/src/gnome-chess.vala
@@ -598,28 +598,36 @@ public class Application : Gtk.Application
profile = ai_profiles.data;
}
- string[] options, args;
+ string[] options, uci_go_options, args;
switch (difficulty)
{
case "easy":
options = profile.easy_options;
+ uci_go_options = profile.easy_uci_go_options;
args = profile.easy_args;
break;
default:
case "normal":
options = profile.normal_options;
+ uci_go_options = profile.normal_uci_go_options;
args = profile.normal_args;
break;
case "hard":
options = profile.hard_options;
+ uci_go_options = profile.hard_uci_go_options;
args = profile.hard_args;
break;
}
if (profile.protocol == "cecp")
+ {
+ warn_if_fail (uci_go_options.length == 0);
engine = new ChessEngineCECP (profile.binary, args, options);
+ }
else if (profile.protocol == "uci")
- engine = new ChessEngineUCI (profile.binary, args, options);
+ {
+ engine = new ChessEngineUCI (profile.binary, args, options, uci_go_options);
+ }
else
{
warning ("Unknown AI protocol %s", profile.protocol);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]