chore: Update LynxChess.Lynx package reference to LynxChess.Lynx.Internal

This commit is contained in:
Anduin Xue
2024-07-03 14:48:00 +00:00
parent e21ea7ee88
commit d35e0989f9
2 changed files with 9 additions and 9 deletions
@@ -15,6 +15,6 @@
<PackageReference Include="Aiursoft.Scanner" Version="8.0.1" />
<PackageReference Include="Aiursoft.WebTools" Version="8.0.21" />
<PackageReference Include="Gera.Chess" Version="1.1.0" />
<PackageReference Include="LynxChess.Lynx" Version="1.5.1" />
<PackageReference Include="LynxChess.Lynx.Internal" Version="1.5.1" />
</ItemGroup>
</Project>
@@ -1,5 +1,4 @@
using System.Threading.Channels;
using Chess;
using Lynx;
using Lynx.Model;
@@ -21,13 +20,14 @@ public class ChessEngine
public string GetBestMove(string fen)
{
var board = ChessBoard.LoadFromFen(fen);
_engine.AdjustPosition($"position fen {fen}");
var moves = _engine.IDDFS(1, 10);
var bestMove = moves.Moves
.Select(t => t.ToEPDString())
.FirstOrDefault(t => board.IsValidMove(t));
return bestMove ?? moves.BestMove.ToEPDString();
var positionClone = new Position(_engine.Game.CurrentPosition);
var result = _engine.IDDFS(1, 10);
_engine.Game.ResetCurrentPositionToBeforeSearchState();
return result
.BestMove
.ToEPDString(positionClone);
}
}