Skip to content

Commit

Permalink
Added Linux compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Sargates authored and Sargates committed Aug 15, 2023
1 parent c50cc23 commit a31f271
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
8 changes: 4 additions & 4 deletions license.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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.
SOFTWARE.
Binary file added resources/stockfish
Binary file not shown.
27 changes: 19 additions & 8 deletions src/Application/Core/Model.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Raylib_cs;
using System.Diagnostics;
using System.Runtime.InteropServices;
using ChessBot.Engine;
using ChessBot.Helpers;

Expand All @@ -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;
Expand All @@ -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);

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit a31f271

Please sign in to comment.