diff --git a/license.md b/license.md index c8e871b..b20b20b 100644 --- a/license.md +++ b/license.md @@ -1,9 +1,9 @@ MIT License Copyright (c) 2023 Nicholas Glenn\ -Credits to Ramon Santamaria (Raylib) (2013-2023) (https://github.com/raysan5/raylib)\ -Credits to ChrisDill (Raylib-cs) (2018-2023) (https://github.com/ChrisDill/Raylib-cs/)\ -Credits to Yaroslav Bondarev (Stockfish.NET) (2020) (https://github.com/Oremiro/Stockfish.NET) +Credits to Ramon Santamaria (Raylib) (2013-2023) (https://github.com/raysan5/raylib)\ +Credits to ChrisDill (Raylib-cs) (2018-2023) (https://github.com/ChrisDill/Raylib-cs/)\ +Credits to Yaroslav Bondarev (Stockfish.NET) (2020) (https://github.com/Oremiro/Stockfish.NET) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -21,4 +21,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +SOFTWARE. diff --git a/resources/stockfish b/resources/stockfish new file mode 100644 index 0000000..528c5bd Binary files /dev/null and b/resources/stockfish differ diff --git a/src/Application/Core/Model.cs b/src/Application/Core/Model.cs index cc0bfdd..c95c2f0 100644 --- a/src/Application/Core/Model.cs +++ b/src/Application/Core/Model.cs @@ -1,5 +1,6 @@ using Raylib_cs; using System.Diagnostics; +using System.Runtime.InteropServices; using ChessBot.Engine; using ChessBot.Helpers; @@ -24,6 +25,8 @@ public enum Gametype { UvU, // UCI vs. UCI } + public string stockfishExecutable; + public int humanColor = 0b00; // 0b10 for white, 0b01 for black, 0b11 for both public Gametype activeGameType = Gametype.HvH; @@ -40,6 +43,14 @@ public enum Gametype { public AnimationCallbackDel PushNewAnimations = (anims) => {}; public Model() { + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { + stockfishExecutable = "stockfish-windows-x86-64-avx2.exe"; + } else + if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { + stockfishExecutable = "stockfish"; + } else { + throw new Exception("This program can only run on Windows and Linux"); + } StartNewGame(); Debug.Assert(board != null); @@ -69,28 +80,28 @@ public void SetPlayerTypes(Gametype type) { (Gametype.HvU, true) => new ChessPlayer(new Player('w'), 300f), (Gametype.CvC, true) => new ChessPlayer(new ComputerPlayer('w', this), 60f), (Gametype.CvU, true) => new ChessPlayer(new ComputerPlayer('w', this), 60f), - (Gametype.UvU, true) => new ChessPlayer(new UCIPlayer('w', this, "stockfish-windows-x86-64-avx2.exe"), 30f), + (Gametype.UvU, true) => new ChessPlayer(new UCIPlayer('w', this, stockfishExecutable), 30f), (Gametype.HvH, false) => new ChessPlayer(new Player('w'), 300f), (Gametype.HvC, false) => new ChessPlayer(new ComputerPlayer('w', this), 60f), - (Gametype.HvU, false) => new ChessPlayer(new UCIPlayer('w', this, "stockfish-windows-x86-64-avx2.exe"), 30f), + (Gametype.HvU, false) => new ChessPlayer(new UCIPlayer('w', this, stockfishExecutable), 30f), (Gametype.CvC, false) => new ChessPlayer(new ComputerPlayer('w', this), 60f), - (Gametype.CvU, false) => new ChessPlayer(new UCIPlayer('w', this, "stockfish-windows-x86-64-avx2.exe"), 30f), - (Gametype.UvU, false) => new ChessPlayer(new UCIPlayer('w', this, "stockfish-windows-x86-64-avx2.exe"), 30f), + (Gametype.CvU, false) => new ChessPlayer(new UCIPlayer('w', this, stockfishExecutable), 30f), + (Gametype.UvU, false) => new ChessPlayer(new UCIPlayer('w', this, stockfishExecutable), 30f), _ => throw new Exception("Shut up compiler!") }; blackPlayer = (type, gameIndex%2==1) switch { (Gametype.HvH, true) => new ChessPlayer(new Player('b'), 300f), (Gametype.HvC, true) => new ChessPlayer(new ComputerPlayer('b', this), 60f), - (Gametype.HvU, true) => new ChessPlayer(new UCIPlayer('b', this, "stockfish-windows-x86-64-avx2.exe"), 30f), + (Gametype.HvU, true) => new ChessPlayer(new UCIPlayer('b', this, stockfishExecutable), 30f), (Gametype.CvC, true) => new ChessPlayer(new ComputerPlayer('b', this), 60f), - (Gametype.CvU, true) => new ChessPlayer(new UCIPlayer('b', this, "stockfish-windows-x86-64-avx2.exe"), 30f), - (Gametype.UvU, true) => new ChessPlayer(new UCIPlayer('b', this, "stockfish-windows-x86-64-avx2.exe"), 30f), + (Gametype.CvU, true) => new ChessPlayer(new UCIPlayer('b', this, stockfishExecutable), 30f), + (Gametype.UvU, true) => new ChessPlayer(new UCIPlayer('b', this, stockfishExecutable), 30f), (Gametype.HvH, false) => new ChessPlayer(new Player('b'), 300f), (Gametype.HvC, false) => new ChessPlayer(new Player('b'), 300f), (Gametype.HvU, false) => new ChessPlayer(new Player('b'), 300f), (Gametype.CvC, false) => new ChessPlayer(new ComputerPlayer('b', this), 60f), (Gametype.CvU, false) => new ChessPlayer(new ComputerPlayer('b', this), 60f), - (Gametype.UvU, false) => new ChessPlayer(new UCIPlayer('b', this, "stockfish-windows-x86-64-avx2.exe"), 30f), + (Gametype.UvU, false) => new ChessPlayer(new UCIPlayer('b', this, stockfishExecutable), 30f), _ => throw new Exception("Shut up compiler!") }; activeGameType = type;