Skip to content

Commit

Permalink
Refactor and simplify Perft
Browse files Browse the repository at this point in the history
  • Loading branch information
eduherminio committed Nov 20, 2024
1 parent 04282f3 commit 4721221
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 47 deletions.
15 changes: 4 additions & 11 deletions src/Lynx.Dev/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -561,21 +561,14 @@ static void _42_Perft()

for (int depth = 0; depth < 7; ++depth)
{
var sw = new Stopwatch();
sw.Start();
var result = Perft.Results(pos, depth);
sw.Stop();

Perft.PrintPerftResult(depth, result, Console.WriteLine);
Perft.RunPerft(pos, depth, Console.WriteLine);
}
}

static void _43_Divide()
{
var result = Perft.Divide(new Position(Constants.InitialPositionFEN), 5, Console.WriteLine);
Perft.PrintPerftResult(5, result, Console.WriteLine);
result = Perft.Divide(new Position(TrickyPosition), 5, Console.WriteLine);
Perft.PrintPerftResult(5, result, Console.WriteLine);
Perft.RunDivide(new Position(Constants.InitialPositionFEN), 5, Console.WriteLine);
Perft.RunDivide(new Position(TrickyPosition), 5, Console.WriteLine);
}

static void _44_ParseUCI()
Expand Down Expand Up @@ -1108,7 +1101,7 @@ static void TesSize(int size)
static void UnmakeMove()
{
var pos = new Position("r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq");
var a = Perft.ResultsImpl(pos, 1, default);
var a = Perft.PerftRecursiveImpl(pos, 1, default);

TestMoveGen(Constants.InitialPositionFEN);
TestMoveGen(Constants.TTPositionFEN);
Expand Down
41 changes: 15 additions & 26 deletions src/Lynx/Perft.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,35 @@ namespace Lynx;
/// </summary>
public static class Perft
{
public static (long Nodes, double ElapsedSeconds) Results(Position position, int depth)
public static void RunPerft(Position position, int depth, Action<string> write)
{
var sw = new Stopwatch();
sw.Start();
var nodes = ResultsImpl(position, depth, 0);
var nodes = PerftRecursiveImpl(position, depth, 0);
sw.Stop();

return (nodes, Utils.CalculateElapsedSeconds(sw));
PrintPerftResult(depth, nodes, Utils.CalculateElapsedSeconds(sw), write);
}

public static (long Nodes, double ElapsedSeconds) Divide(Position position, int depth, Action<string> write)
public static void RunDivide(Position position, int depth, Action<string> write)
{
var sw = new Stopwatch();
sw.Start();
var nodes = DivideImpl(position, depth, 0, write);
var nodes = DivideRecursiveImpl(position, depth, 0, write);
sw.Stop();

return (nodes, Utils.CalculateElapsedSeconds(sw));
PrintPerftResult(depth, nodes, Utils.CalculateElapsedSeconds(sw), write);
}

/// <summary>
/// Proper implementation, used by <see cref="DivideImpl(Position, int, long)"/> as well
/// Proper implementation, used by <see cref="DivideRecursiveImpl(Position, int, long, Action{string})"/> as well
/// </summary>
/// <param name="position"></param>
/// <param name="depth"></param>
/// <param name="nodes"></param>
/// <returns></returns>
[SkipLocalsInit]
internal static long ResultsImpl(Position position, int depth, long nodes)
internal static long PerftRecursiveImpl(Position position, int depth, long nodes)
{
if (depth != 0)
{
Expand All @@ -49,7 +49,7 @@ internal static long ResultsImpl(Position position, int depth, long nodes)

if (position.WasProduceByAValidMove())
{
nodes = ResultsImpl(position, depth - 1, nodes);
nodes = PerftRecursiveImpl(position, depth - 1, nodes);
}
position.UnmakeMove(move, state);
}
Expand All @@ -61,7 +61,7 @@ internal static long ResultsImpl(Position position, int depth, long nodes)
}

[SkipLocalsInit]
private static long DivideImpl(Position position, int depth, long nodes, Action<string> write)
private static long DivideRecursiveImpl(Position position, int depth, long nodes, Action<string> write)
{
if (depth != 0)
{
Expand All @@ -73,7 +73,7 @@ private static long DivideImpl(Position position, int depth, long nodes, Action<
if (position.WasProduceByAValidMove())
{
var accumulatedNodes = nodes;
nodes = ResultsImpl(position, depth - 1, nodes);
nodes = PerftRecursiveImpl(position, depth - 1, nodes);

write($"{move.UCIString()}\t\t{nodes - accumulatedNodes}");
}
Expand All @@ -89,26 +89,15 @@ private static long DivideImpl(Position position, int depth, long nodes, Action<
return nodes + 1;
}

public static void PrintPerftResult(int depth, (long Nodes, double ElapsedSeconds) peftResult, Action<string> write)
private static void PrintPerftResult(int depth, long nodes, double elapsedSeconds, Action<string> write)
{
var timeStr = TimeToString(peftResult.ElapsedSeconds * 1_000);
var timeStr = TimeToString(elapsedSeconds * 1_000);

write(
$"Depth:\t{depth}" + Environment.NewLine +
$"Nodes:\t{peftResult.Nodes}" + Environment.NewLine +
$"Nodes:\t{nodes}" + Environment.NewLine +
$"Time:\t{timeStr}" + Environment.NewLine +
$"nps:\t{peftResult.Nodes / (peftResult.ElapsedSeconds * 1_000_000):F} Mnps" + Environment.NewLine);
}

public static async ValueTask PrintPerftResult(int depth, (long Nodes, double ElapsedSeconds) peftResult, Func<string, ValueTask> write)
{
var timeStr = TimeToString(peftResult.ElapsedSeconds * 1_000);

await write(
$"Depth:\t{depth}" + Environment.NewLine +
$"Nodes:\t{peftResult.Nodes}" + Environment.NewLine +
$"Time:\t{timeStr}" + Environment.NewLine +
$"nps:\t{peftResult.Nodes / (peftResult.ElapsedSeconds * 1_000_000):F} Mnps" + Environment.NewLine);
$"nps:\t{nodes / (elapsedSeconds * 1_000_000):F} Mnps" + Environment.NewLine);
}

private static string TimeToString(double milliseconds)
Expand Down
14 changes: 6 additions & 8 deletions src/Lynx/UCIHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ static ReadOnlySpan<char> ExtractCommandItems(string rawCommand)
HandleNewGame();
break;
case "perft":
await HandlePerft(rawCommand);
HandlePerft(rawCommand);
break;
case "divide":
await HandleDivide(rawCommand);
HandleDivide(rawCommand);
break;
case "bench":
await HandleBench(rawCommand);
Expand Down Expand Up @@ -556,25 +556,23 @@ private void HandleQuit()

private void HandleRegister(ReadOnlySpan<char> rawCommand) => _engine.Registration = new RegisterCommand(rawCommand);

private async Task HandlePerft(string rawCommand)
private void HandlePerft(string rawCommand)
{
var items = rawCommand.Split(' ', StringSplitOptions.RemoveEmptyEntries);

if (items.Length >= 2 && int.TryParse(items[1], out int depth) && depth >= 1)
{
var results = Perft.Results(_engine.Game.CurrentPosition, depth);
await Perft.PrintPerftResult(depth, results, str => _engineToUci.Writer.WriteAsync(str));
Perft.RunPerft(_engine.CurrentPosition, depth, str => _engineToUci.Writer.TryWrite(str));

Check failure on line 565 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / build-and-publish (ubuntu-latest)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 565 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / build-and-publish (ubuntu-latest)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 565 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / winning-at-chess (ubuntu-latest, WinningAtChess_FixedTime)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 565 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / winning-at-chess (ubuntu-latest, WinningAtChess_FixedTime)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 565 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / fast-tests (Debug, ubuntu-latest)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 565 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / fast-tests (Debug, ubuntu-latest)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 565 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / fast-tests (Release, ubuntu-latest)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 565 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / fast-tests (Release, ubuntu-latest)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 565 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / long-running-tests (ubuntu-latest, LongRunning)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 565 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / long-running-tests (ubuntu-latest, LongRunning)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 565 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / make-build (ubuntu-latest)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 565 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / perft-tests (ubuntu-latest, Perft)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 565 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / perft-tests (ubuntu-latest, Perft)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 565 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / other-tests (ubuntu-latest, Configuration)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 565 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / other-tests (ubuntu-latest, Configuration)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 565 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / build-and-publish (macOS-latest)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 565 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / build-and-publish (macOS-latest)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 565 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / fast-tests (Debug, macOS-latest)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 565 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / fast-tests (Debug, macOS-latest)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 565 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / fast-tests (Debug, macOS-13)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 565 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / fast-tests (Debug, macOS-13)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 565 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / build-and-publish (macOS-13)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 565 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / build-and-publish (macOS-13)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 565 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / fast-tests (Release, macOS-latest)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 565 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / fast-tests (Release, macOS-latest)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 565 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / long-running-tests (windows-latest, LongRunning)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 565 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / long-running-tests (windows-latest, LongRunning)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 565 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / long-running-tests (macOS-latest, LongRunning)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 565 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / long-running-tests (macOS-latest, LongRunning)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 565 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / fast-tests (Debug, windows-latest)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 565 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / fast-tests (Debug, windows-latest)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 565 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / build-and-publish (windows-latest)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 565 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / build-and-publish (windows-latest)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 565 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / perft-tests (windows-latest, Perft)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 565 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / perft-tests (windows-latest, Perft)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 565 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / other-tests (windows-latest, Configuration)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 565 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / other-tests (windows-latest, Configuration)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 565 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / fast-tests (Release, macOS-13)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 565 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / fast-tests (Release, macOS-13)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 565 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / make-build (macOS-13)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 565 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / make-build (macOS-latest)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 565 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / other-tests (macOS-latest, Configuration)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 565 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / other-tests (macOS-latest, Configuration)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 565 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / perft-tests (macOS-latest, Perft)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 565 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / perft-tests (macOS-latest, Perft)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 565 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / other-tests (macOS-13, Configuration)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 565 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / other-tests (macOS-13, Configuration)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 565 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / fast-tests (Release, windows-latest)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 565 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / fast-tests (Release, windows-latest)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 565 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / long-running-tests (macOS-13, LongRunning)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 565 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / long-running-tests (macOS-13, LongRunning)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)
}
}

private async ValueTask HandleDivide(string rawCommand)
private void HandleDivide(string rawCommand)
{
var items = rawCommand.Split(' ', StringSplitOptions.RemoveEmptyEntries);

if (items.Length >= 2 && int.TryParse(items[1], out int depth) && depth >= 1)
{
var results = Perft.Divide(_engine.Game.CurrentPosition, depth, str => _engineToUci.Writer.TryWrite(str));
await Perft.PrintPerftResult(depth, results, str => _engineToUci.Writer.WriteAsync(str));
Perft.RunDivide(_engine.CurrentPosition, depth, str => _engineToUci.Writer.TryWrite(str));

Check failure on line 575 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / build-and-publish (ubuntu-latest)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 575 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / build-and-publish (ubuntu-latest)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 575 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / winning-at-chess (ubuntu-latest, WinningAtChess_FixedTime)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 575 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / winning-at-chess (ubuntu-latest, WinningAtChess_FixedTime)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 575 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / fast-tests (Debug, ubuntu-latest)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 575 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / fast-tests (Debug, ubuntu-latest)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 575 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / fast-tests (Release, ubuntu-latest)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 575 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / fast-tests (Release, ubuntu-latest)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 575 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / long-running-tests (ubuntu-latest, LongRunning)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 575 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / long-running-tests (ubuntu-latest, LongRunning)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 575 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / make-build (ubuntu-latest)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 575 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / perft-tests (ubuntu-latest, Perft)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 575 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / perft-tests (ubuntu-latest, Perft)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 575 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / other-tests (ubuntu-latest, Configuration)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 575 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / other-tests (ubuntu-latest, Configuration)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 575 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / build-and-publish (macOS-latest)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 575 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / build-and-publish (macOS-latest)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 575 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / fast-tests (Debug, macOS-latest)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 575 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / fast-tests (Debug, macOS-latest)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 575 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / fast-tests (Debug, macOS-13)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 575 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / fast-tests (Debug, macOS-13)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 575 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / build-and-publish (macOS-13)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 575 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / build-and-publish (macOS-13)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 575 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / fast-tests (Release, macOS-latest)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 575 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / fast-tests (Release, macOS-latest)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 575 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / long-running-tests (windows-latest, LongRunning)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 575 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / long-running-tests (windows-latest, LongRunning)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 575 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / long-running-tests (macOS-latest, LongRunning)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 575 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / long-running-tests (macOS-latest, LongRunning)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 575 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / fast-tests (Debug, windows-latest)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 575 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / fast-tests (Debug, windows-latest)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 575 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / build-and-publish (windows-latest)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 575 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / build-and-publish (windows-latest)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 575 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / perft-tests (windows-latest, Perft)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 575 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / perft-tests (windows-latest, Perft)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 575 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / other-tests (windows-latest, Configuration)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 575 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / other-tests (windows-latest, Configuration)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 575 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / fast-tests (Release, macOS-13)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 575 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / fast-tests (Release, macOS-13)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 575 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / make-build (macOS-13)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 575 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / make-build (macOS-latest)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 575 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / other-tests (macOS-latest, Configuration)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 575 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / other-tests (macOS-latest, Configuration)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 575 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / perft-tests (macOS-latest, Perft)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 575 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / perft-tests (macOS-latest, Perft)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 575 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / other-tests (macOS-13, Configuration)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 575 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / other-tests (macOS-13, Configuration)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 575 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / fast-tests (Release, windows-latest)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 575 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / fast-tests (Release, windows-latest)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 575 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / long-running-tests (macOS-13, LongRunning)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 575 in src/Lynx/UCIHandler.cs

View workflow job for this annotation

GitHub Actions / long-running-tests (macOS-13, LongRunning)

'Engine' does not contain a definition for 'CurrentPosition' and no accessible extension method 'CurrentPosition' accepting a first argument of type 'Engine' could be found (are you missing a using directive or an assembly reference?)
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Lynx.Test/PerftTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,6 @@ public void MartinnPositions(string fen, int depth, long expectedNumberOfNodes)

private static void Validate(string fen, int depth, long expectedNumberOfNodes)
{
Assert.AreEqual(expectedNumberOfNodes, Perft.ResultsImpl(new Position(fen), depth, default));
Assert.AreEqual(expectedNumberOfNodes, Perft.PerftRecursiveImpl(new Position(fen), depth, default));
}
}
2 changes: 1 addition & 1 deletion tests/Lynx.Test/PerftTestSuite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,6 @@ public void Suite(string fen, int depth, long expectedNumberOfNodes)

private static void Validate(string fen, int depth, long expectedNumberOfNodes)
{
Assert.AreEqual(expectedNumberOfNodes, Perft.ResultsImpl(new Position(fen), depth, default));
Assert.AreEqual(expectedNumberOfNodes, Perft.PerftRecursiveImpl(new Position(fen), depth, default));
}
}

0 comments on commit 4721221

Please sign in to comment.