Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/Rudzoft.ChessLib/Game.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Rudzoft.ChessLib/IGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public interface IGame : IEnumerable<Piece>

FenData GetFen();

void UpdateDrawTypes();
void UpdateGameEndTypes();

string ToString();

Expand Down