public void PerformanceTest() { var state = new StateReader("...0...|..000..|.00000.|0000000|.00010.|..000..|...1...|3 5|5 4|3 4|1 1|") .ReadState(new InitializationData(7, 2)); for (var j = 0; j < 10; j++) { var alphabetaAi = new AlphabetaAi(evaluator); for (var i = 0; i < 10; i++) { var action = alphabetaAi.GetAction(state, 100); action.ApplyTo(state); state.ChangeCurrentPlayer(); //Console.WriteLine(state); Console.WriteLine(action); } } }
public void MeasurePerformance() { var state = new StateReader("...0...|..000..|.00000.|0000000|.00010.|..000..|...1...|3 5|5 4|3 4|1 1|") .ReadState(new InitializationData(7, 2)); var alphabetaAi = new AlphaBetaAi(evaluator) { LoggingEnabled = false }; var totalNodesProcessed = 0; var totalDepths = 0; var count = 50; for (var turn = 0; turn < count; turn++) { var action = alphabetaAi.GetAction(state, turn == 0 ? 100 : 50); action.ApplyTo(state); state.ChangeCurrentPlayer(); totalNodesProcessed += alphabetaAi.LastSearchTreeSize; totalDepths += alphabetaAi.LastDepthFullySearched; } Console.WriteLine($"Total Nodes Searched: {totalNodesProcessed}"); Console.WriteLine($"Average search depth: {totalDepths / (double)count}"); }