public void AddMaxEvaluation(IState state, int depth, IList <IState> passedThroughStates, double maxEvaluation) { var containsValue = cache.TryGetValue(state, out var evaluation); if (containsValue && evaluation.MaxEvaluation > maxEvaluation) { if (evaluation.MinEvaluation > maxEvaluation) { throw new UnknownProblemException($"cache's {nameof(maxEvaluation)} is smaller than {nameof(evaluation.MinEvaluation)}"); } cache[state].MaxEvaluation = maxEvaluation; } else if (!containsValue) { cache[state] = new EvaluationRange(int.MinValue, maxEvaluation); } }
public void AddMinEvaluation(IState state, int depth, IList <IState> passedThroughStates, double minEvaluation) { var key = new StateAndPassedThroughStates(state, passedThroughStates); var containsValue = cache.TryGetValue(key, out var evaluation); if (containsValue && evaluation.MinEvaluation < minEvaluation) { if (evaluation.MaxEvaluation < minEvaluation) { throw new UnknownProblemException($"cache's {nameof(minEvaluation)} is greater than {nameof(evaluation.MaxEvaluation)}"); } cache[key].MinEvaluation = minEvaluation; } else if (!containsValue) { cache[key] = new EvaluationRange(minEvaluation, int.MaxValue); } }
public void AddExactEvaluation(IState state, int depth, IList <IState> passedThroughStates, double evaluation) => cache[new StateAndPassedThroughStates(state, passedThroughStates)] = new EvaluationRange(evaluation);