@@ -9,23 +9,17 @@ internal class AlphaBetaSolver<TPosition, TStep> : ISolver<TStep>
99 private readonly IRules < TPosition , TStep > rules ;
1010 private readonly ISearchManager searchManager ;
1111 private readonly Action < string > logger ;
12- private readonly int maxDepth ;
13- private readonly long timeBudgetMs ;
1412
1513 public AlphaBetaSolver (
1614 AlphaBetaPruning < TPosition , TStep > alphaBetaPruning ,
1715 IRules < TPosition , TStep > rules ,
1816 ISearchManager searchManager ,
19- Action < string > logger ,
20- int maxDepth ,
21- long timeBudgetMs = 0 )
17+ Action < string > logger )
2218 {
2319 this . alphaBetaPruning = alphaBetaPruning ?? throw new ArgumentNullException ( nameof ( alphaBetaPruning ) ) ;
2420 this . rules = rules ?? throw new ArgumentNullException ( nameof ( rules ) ) ;
2521 this . searchManager = searchManager ?? throw new ArgumentNullException ( nameof ( searchManager ) ) ;
2622 this . logger = logger ?? throw new ArgumentNullException ( nameof ( logger ) ) ;
27- this . maxDepth = maxDepth ;
28- this . timeBudgetMs = timeBudgetMs ;
2923 }
3024
3125 public TStep OptimizeNextStep ( IList < TStep > history )
@@ -34,12 +28,11 @@ public TStep OptimizeNextStep(IList<TStep> history)
3428 sw . Restart ( ) ;
3529 var position = CreatePosition ( history ) ;
3630
37- TStep ? bestStep = default ;
38-
39- searchManager . StartTimedSearch ( timeBudgetMs ) ;
31+ TStep ? bestStep = default ;
32+ searchManager . StartSearch ( ) ;
4033 var guess = 0 ;
4134
42- for ( int i = 2 ; i < maxDepth ; i += 2 )
35+ for ( int i = 2 ; i < searchManager . MaxDepth ; i += 2 )
4336 {
4437 searchManager . DepthLimit = i ;
4538 var ( OptimalSteps , Value ) = BestNodeSearch ( position , guess ) ;
@@ -60,7 +53,7 @@ public TStep OptimizeNextStep(IList<TStep> history)
6053
6154 private ( ICollection < TStep > OptimalSteps , int Value ) BestNodeSearch ( TPosition position , int guess )
6255 {
63- const int winScore = sbyte . MaxValue + 48 ; // must match AlphaBetaPruning.MaxSearchDepth
56+ int winScore = sbyte . MaxValue + searchManager . MaxDepth ;
6457 int alpha = - winScore ;
6558 int beta = winScore ;
6659
0 commit comments