public void AssignValueToLastSearchTreeSizeProperty_DuringSearch(int depth, int expectedSize) { var state = StateReader.Read("002|022|200|0 0|1 0|-1 -1|-1 -1|"); var ai = new AlphaBetaAi(evaluator, depth); ai.GetAction(state, 1000); ai.LastSearchTreeSize.Should().Be(expectedSize); }
public void AssignValueToLastDepthFullySearchedProperty_DuringSearch(int depth) { var state = StateReader.Read("00000|00000|00000|00000|00000|1 1|2 3|-1 -1|-1 -1|"); var ai = new AlphaBetaAi(evaluator, depth); ai.GetAction(state, 1000); ai.LastDepthFullySearched.Should().Be(depth); }
public void MeasureSearchTreeSize() { var stateInput = "...2...|..303..|.13033.|0010031|.01412.|..121..|...1...|3 5|5 2|2 2|5 4|"; var state = StateReader.Read(stateInput); new AlphaBetaAi(evaluator).GetAction(state, 1); // heat up var ai = new AlphaBetaAi(evaluator, 3); ai.GetAction(state, 3000); // measure Console.WriteLine($"SearchTreeSize: {ai.LastSearchTreeSize}"); }
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}"); }