Chess-Challenge icon indicating copy to clipboard operation
Chess-Challenge copied to clipboard

It would be great to have a benchmarking mode.

Open Rhxydos opened this issue 2 years ago • 2 comments

It would be really helpful to have a mode where instead of our bot playing against another bot, it just gets fed a bunch of different board positions so that we can record things like how long it takes to evaluate each one. I tried my hand at setting it up myself, but I'm not good enough with c#.

Rhxydos avatar Jul 25 '23 15:07 Rhxydos

Make it play against itself and make it so playing as black it returns a null move.

Pds314 avatar Jul 27 '23 10:07 Pds314

Here's what I do to get some basic info

// Declare an array of int, which will hold evaluations for root moves
int[] array_intEvaluations = new int[moves.Length];

// Save time at the start of the root loop
DateTime floatStartTime = System.DateTime.Now;

for (int i = 0; i < moves.Length; i++)
{
    board.MakeMove(moves[i]);
    array_intEvaluations[i] = -Search(1, -color, -99999999, 99999999);
    board.UndoMove(moves[i]);
}

// Save time at the end of the root loop
DateTime floatFinishTime = System.DateTime.Now;

// Calculate time span between finish and start
TimeSpan timespanSpan = floatFinishTime - floatStartTime;

// Output final evaluations for root moves into console
for (int i = 0; i < array_intEvaluations.Length; i++)
{
    Console.Write(array_intEvaluations[i].ToString() + " ");
}

// Output measurements, including time spent on evaluation, into console
Console.WriteLine
(
"\nTime taken: "        + timespanSpan.TotalMilliseconds.ToString()
+ ", nodes visited: "   + intNodesVisited.ToString()
+ ", kN/s: "            + (intNodesVisited / timespanSpan.TotalMilliseconds).ToString()
+ ", Table hits: "      + intTableHits.ToString() + ", out of: " +intTableSize.ToString()
+ " AB triggered: "     + intABTriggers.ToString()
+ ", branches pruned: " + intBranchesPruned.ToString()
);

WhiteMouse1 avatar Jul 30 '23 15:07 WhiteMouse1