diff --git a/src/Rudzoft.ChessLib/Game.cs b/src/Rudzoft.ChessLib/Game.cs index 364b7db6..5184700d 100644 --- a/src/Rudzoft.ChessLib/Game.cs +++ b/src/Rudzoft.ChessLib/Game.cs @@ -75,6 +75,10 @@ static Game() public bool IsRepetition => _pos.IsRepetition; + public bool IsRule50 => _pos.Rule50 >= 100; + + public bool IsMated => _pos.IsMate; + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void NewGame(string fen = Fen.Fen.StartPositionFen) { @@ -86,14 +90,16 @@ public void NewGame(string fen = Fen.Fen.StartPositionFen) [MethodImpl(MethodImplOptions.AggressiveInlining)] public FenData GetFen() => _pos.GenerateFen(); - public void UpdateDrawTypes() + public void UpdateGameEndTypes() { var gameEndType = GameEndTypes.None; if (IsRepetition) gameEndType |= GameEndTypes.Repetition; - if (Pos.Rule50 >= 100) + if (IsRule50) gameEndType |= GameEndTypes.FiftyMove; - + if (IsMated) + gameEndType |= GameEndTypes.CheckMate; + var moveList = _moveLists.Get(); moveList.Generate(in _pos); // ReSharper disable once LoopCanBeConvertedToQuery diff --git a/src/Rudzoft.ChessLib/IGame.cs b/src/Rudzoft.ChessLib/IGame.cs index ef20d316..f36fc287 100644 --- a/src/Rudzoft.ChessLib/IGame.cs +++ b/src/Rudzoft.ChessLib/IGame.cs @@ -51,7 +51,7 @@ public interface IGame : IEnumerable FenData GetFen(); - void UpdateDrawTypes(); + void UpdateGameEndTypes(); string ToString();