-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add Threads UCI option * Add `bench` support for both UCI and as executable parameter * Add EXE and CC fields to makefile * Follow most accepted standard for node count: after legal move
- Loading branch information
1 parent
6b3196f
commit 7feb991
Showing
15 changed files
with
214 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
using System.Diagnostics; | ||
using System.Threading.Channels; | ||
|
||
namespace Lynx; | ||
|
||
public static class OpenBench | ||
{ | ||
private static readonly string[] _benchmarkFens = new string[] | ||
{ | ||
"r3k2r/2pb1ppp/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/p1p2k1p/P2npP1P/4K1P1/1P6/3R4 w - - 6 54", | ||
"8/8/1p4p1/p1p2k1p/P2n1P1P/4K1P1/1P6/6R1 b - - 6 59", | ||
"8/5k2/1p4p1/p1pK3p/P2n1P1P/6P1/1P6/4R3 b - - 14 63", | ||
"8/1R6/1p1K1kp1/p6p/P1p2P1P/6P1/1Pn5/8 w - - 0 67", | ||
"1rb1rn1k/p3q1bp/2p3p1/2p1p3/2P1P2N/PP1RQNP1/1B3P2/4R1K1 b - - 4 23", | ||
"4rrk1/pp1n1pp1/q5p1/P1pP4/2n3P1/7P/1P3PB1/R1BQ1RK1 w - - 3 22", | ||
"r2qr1k1/pb1nbppp/1pn1p3/2ppP3/3P4/2PB1NN1/PP3PPP/R1BQR1K1 w - - 4 12", | ||
"2r2k2/8/4P1R1/1p6/8/P4K1N/7b/2B5 b - - 0 55", | ||
"6k1/5pp1/8/2bKP2P/2P5/p4PNb/B7/8 b - - 1 44", | ||
"2rqr1k1/1p3p1p/p2p2p1/P1nPb3/2B1P3/5P2/1PQ2NPP/R1R4K w - - 3 25", | ||
"r1b2rk1/p1q1ppbp/6p1/2Q5/8/4BP2/PPP3PP/2KR1B1R b - - 2 14", | ||
"6r1/5k2/p1b1r2p/1pB1p1p1/1Pp3PP/2P1R1K1/2P2P2/3R4 w - - 1 36", | ||
"rnbqkb1r/pppppppp/5n2/8/2PP4/8/PP2PPPP/RNBQKBNR b KQkq c3 0 2", | ||
"2rr2k1/1p4bp/p1q1p1p1/4Pp1n/2PB4/1PN3P1/P3Q2P/2RR2K1 w - f6 0 20", | ||
"3br1k1/p1pn3p/1p3n2/5pNq/2P1p3/1PN3PP/P2Q1PB1/4R1K1 w - - 0 23", | ||
"2r2b2/5p2/5k2/p1r1pP2/P2pB3/1P3P2/K1P3R1/7R w - - 23 93", | ||
"5k2/4q1p1/3P1pQb/1p1B4/pP5p/P1PR4/5PP1/1K6 b - - 0 38", | ||
"6k1/6p1/8/6KQ/1r6/q2b4/8/8 w - - 0 32", | ||
"5rk1/1rP3pp/p4n2/3Pp3/1P2Pq2/2Q4P/P5P1/R3R1K1 b - - 0 32", | ||
"4r1k1/4r1p1/8/p2R1P1K/5P1P/1QP3q1/1P6/3R4 b - - 0 1", | ||
"R4r2/4q1k1/2p1bb1p/2n2B1Q/1N2pP2/1r2P3/1P5P/2B2KNR w - - 3 31", | ||
"r6k/pbR5/1p2qn1p/P2pPr2/4n2Q/1P2RN1P/5PBK/8 w - - 2 31", | ||
"rn2k3/4r1b1/pp1p1n2/1P1q1p1p/3P4/P3P1RP/1BQN1PR1/1K6 w - - 6 28", | ||
"3q1k2/3P1rb1/p6r/1p2Rp2/1P5p/P1N2pP1/5B1P/3QRK2 w - - 1 42", | ||
"4r2k/1p3rbp/2p1N1p1/p3n3/P2NB1nq/1P6/4R1P1/B1Q2RK1 b - - 4 32", | ||
"4r1k1/1q1r3p/2bPNb2/1p1R3Q/pB3p2/n5P1/6B1/4R1K1 w - - 2 36", | ||
"3qr2k/1p3rbp/2p3p1/p7/P2pBNn1/1P3n2/6P1/B1Q1RR1K b - - 1 30", | ||
"3qk1b1/1p4r1/1n4r1/2P1b2B/p3N2p/P2Q3P/8/1R3R1K w - - 2 39" | ||
}; | ||
|
||
/// <summary> | ||
/// Positions taken from Akimbo | ||
/// https://github.com/JacquesRW/akimbo/blob/main/resources/fens.txt | ||
/// </summary> | ||
public static (int TotalNodes, long Nps) Bench() | ||
{ | ||
var engineChannel = Channel.CreateUnbounded<string>(); | ||
var engine = new Engine(engineChannel); | ||
var stopwatch = new Stopwatch(); | ||
|
||
int totalNodes = 0; | ||
long totalTime = 0; | ||
|
||
foreach (var fen in _benchmarkFens) | ||
{ | ||
Console.WriteLine($"Benchmarking {fen} at depth {Configuration.EngineSettings.BenchDepth}"); | ||
|
||
engine.AdjustPosition($"position fen {fen}"); | ||
stopwatch.Restart(); | ||
|
||
var result = engine.BestMove(new($"go depth {Configuration.EngineSettings.BenchDepth}")); | ||
totalTime += stopwatch.ElapsedMilliseconds; | ||
totalNodes += result.Nodes; | ||
} | ||
|
||
Console.WriteLine($"Total time: {totalTime}"); | ||
|
||
return (totalNodes, Utils.CalculateNps(totalNodes, totalTime)); | ||
} | ||
|
||
public static void PrintBenchResults((int TotalNodes, long Nps) benchResult, Action<string> write) => write($"{benchResult.TotalNodes} nodes {benchResult.Nps} nps"); | ||
public static async ValueTask PrintBenchResults((int TotalNodes, long Nps) benchResult, Func<string, ValueTask> write) => await write($"{benchResult.TotalNodes} nodes {benchResult.Nps} nps"); | ||
} |
Oops, something went wrong.