Skip to content

Commit

Permalink
Fixed default engines
Browse files Browse the repository at this point in the history
  • Loading branch information
sakya committed Feb 9, 2022
1 parent 2e3f0dc commit 256d6e6
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 36 deletions.
79 changes: 45 additions & 34 deletions CoreChess/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Un4seen.Bass;
Expand Down Expand Up @@ -139,46 +140,56 @@ static async Task<bool> CheckEngines()
}
}

if (engines.Count == 0) {
if (Environment.OSVersion.Platform == PlatformID.Unix) {
// Add default engines (flatpak)
engines.Add(
new Uci("Stockfish", "/app/bin/Engines/stockfish/stockfish")
{
WorkingDir = "/app/bin/Engines/stockfish"
}
);
} else if (Environment.OSVersion.Platform == PlatformID.Win32NT) {
// Add default engines (Inno Setup)
engines.Add(
new Uci("Stockfish", Path.Combine(App.BinaryPath, @"Engines\stockfish\stockfish_14.1_win_x64.exe"))
{
WorkingDir = Path.Combine(App.BinaryPath, @"Engines\stockfish")
}
);
engines.Add(
new Uci("Leela Chess Zero", Path.Combine(App.BinaryPath, @"Engines\lc0\lc0.exe"))
{
WorkingDir = Path.Combine(App.BinaryPath, @"Engines\lc0")
}
);
}
List<EngineBase> defaultEngines = new List<EngineBase>();
if (Environment.OSVersion.Platform == PlatformID.Unix) {
// Add default engines (flatpak)
defaultEngines.Add(
new Uci("Stockfish", "/app/bin/Engines/stockfish/stockfish")
{
WorkingDir = "/app/bin/Engines/stockfish"
}
);
defaultEngines.Add(
new Uci("Leela Chess Zero", "/app/bin/Engines/lc0/lc0")
{
WorkingDir = "/app/bin/Engines/lc0"
}
);
} else if (Environment.OSVersion.Platform == PlatformID.Win32NT) {
// Add default engines (Inno Setup)
defaultEngines.Add(
new Uci("Stockfish", Path.Combine(App.BinaryPath, @"Engines\stockfish\stockfish_14.1_win_x64.exe"))
{
WorkingDir = Path.Combine(App.BinaryPath, @"Engines\stockfish")
}
);
defaultEngines.Add(
new Uci("Leela Chess Zero", Path.Combine(App.BinaryPath, @"Engines\lc0\lc0.exe"))
{
WorkingDir = Path.Combine(App.BinaryPath, @"Engines\lc0")
}
);
}

// Initialize engines (get options list)
foreach (var engine in engines) {
if (File.Exists(engine.Command)) {
try {
await engine.Start();
await engine.Stop();
// Check missing engines
foreach (var dEngine in defaultEngines) {
var existingEngine = engines.Where(e => e.Command == dEngine.Command).FirstOrDefault();
if (existingEngine == null) {
// Initialize engine (get options list)
try {
await dEngine.Start();
await dEngine.Stop();

engine.SetPondering(true);
engine.SetOwnBook(false);
} catch {
dEngine.SetPondering(true);
dEngine.SetOwnBook(false);

engines.Add(dEngine);
} catch {

}
}
}
}

App.Settings.Engines = engines;
App.Settings.Save(App.SettingsPath);

Expand Down
17 changes: 16 additions & 1 deletion Flatpak/com.github.sakya.corechess.appdata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
<content_rating type="oars-1.1"/>
<url type="homepage">https://github.com/sakya/corechess</url>
<description>
<p>Included engines:</p>
<ul>
<li>Stockfish</li>
<li>Leela Chess Zero</li>
</ul>

<p>Supported engines:</p>
<ul>
<li>UCI (Universal Chess Interface) like Stockfish, Komodo and Leela Chess Zero</li>
Expand All @@ -28,7 +34,16 @@
</screenshot>
</screenshots>
<releases>
<release version="0.9.0" date="2022-02-05">
<release version="0.10.0" date="2022-02-09">
<description>
<p>Changelog</p>
<ul>
<li>Added Leela Chess Zero engine</li>
<li>Select engine when creating a new game</li>
</ul>
</description>
</release>
<release version="0.9.0" date="2022-02-05">
<description>
<p>First public release</p>
</description>
Expand Down
2 changes: 1 addition & 1 deletion SolutionInfo.proj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<PropertyGroup>
<Authors>Paolo Iommarini</Authors>
<Copyright>Copyright © 2022, Paolo Iommarini</Copyright>
<Version>0.9.0.0</Version>
<Version>0.10.0.0</Version>
</PropertyGroup>
</Project>

0 comments on commit 256d6e6

Please sign in to comment.