public void RepeatedStateInStateDefinesDepthGame_CacheRepeatedValue(bool dieEarly, bool favorShortPaths) { var searchTree = new RepeatStateTree(); searchTree.ChildState2.SetEvaluationTo(3, 4); var engine = new SearchEngine(CacheMode.NewCache, CacheKeyType.StateOnly) { FavorShortPaths = favorShortPaths, DieEarly = dieEarly, StateDefinesDepth = true, ParallelismMode = ParallelismMode.NonParallelism }; var result = engine.Search(searchTree.RootState, 2); Assert.AreEqual(3, result.Evaluation); // Check that we read the evaluation for Child1 from the cache the second time }
public void RepeatedStateInStateDefinesDepthGame_StatesPrunedByAlphaBeta_CacheDoesntRepeatedValue(bool dieEarly, bool favorShortPaths) { var searchTree = new RepeatStateTree(); searchTree.EndState1.SetEvaluationTo(5); searchTree.EndState2.SetEvaluationTo(4, 7); searchTree.EndState3.SetEvaluationTo(6); var engine = new SearchEngine(CacheMode.NewCache, CacheKeyType.StateOnly) { FavorShortPaths = favorShortPaths, DieEarly = dieEarly, StateDefinesDepth = true, ParallelismMode = ParallelismMode.NonParallelism }; var result = engine.Search(searchTree.RootState, 4); Assert.AreEqual(6, result.Evaluation); // Check that we didn't read the evaluation for endState2 from the cache the second time }
public void RepeatedStateInStateDefinesDepthGame_DontCacheRepeatedValue(bool useUnstableStateMethod, bool reuseCache, bool stateDefinesDepth) { var searchTree = new RepeatStateTree(); searchTree.ChildState2.SetEvaluationTo(3, 4); var engine = new SearchEngine(reuseCache ? CacheMode.ReuseCache : CacheMode.NewCache, CacheKeyType.StateOnly) { StateDefinesDepth = stateDefinesDepth, ParallelismMode = ParallelismMode.NonParallelism }; if (useUnstableStateMethod) { engine.IsUnstableState = (s, d, l) => false; } var result = engine.Search(searchTree.RootState, 2); Assert.AreEqual(4, result.Evaluation); // Check that we didn't read the evaluation for Child1 from the cache the second time }
public void RepeatedStateInStateDefinesDepthGame_StatesPrunedByPruner_CacheDoesntRepeatedValue(bool dieEarly, bool favorShortPaths) { var searchTree = new RepeatStateTree(); searchTree.ChildState4.SetEvaluationTo(3, 4); var myPruner = A.Fake <IPruner>(); A.CallTo(() => myPruner.ShouldPrune(A <IState> ._, A <int> ._, A <List <IState> > ._)) .ReturnsLazily((IState s, int d, List <IState> l) => s == searchTree.ChildState5); var engine = new SearchEngine(CacheMode.NewCache, CacheKeyType.StateOnly) { FavorShortPaths = favorShortPaths, DieEarly = dieEarly, StateDefinesDepth = true, ParallelismMode = ParallelismMode.NonParallelism }.AddPruner(myPruner); var result = engine.Search(searchTree.RootState, 3); Assert.AreEqual(4, result.Evaluation); // Check that we didn't read the evaluation for childState5 from the cache the second time }