using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SpriteCompiler.AI
{
public class SearchProblem : ISearchProblem
where C : IPathCost
{
private readonly IGoalTest goalTest;
private readonly IStepCostFunction stepCost;
private readonly ISuccessorFunction successorFn;
private readonly IHeuristicFunction heuristicFn;
public SearchProblem(IGoalTest goalTest, IStepCostFunction stepCost, ISuccessorFunction successor, IHeuristicFunction heuristicFn)
{
this.goalTest = goalTest;
this.stepCost = stepCost;
this.successorFn = successor;
this.heuristicFn = heuristicFn;
}
public IEnumerable> Successors(S state)
{
return successorFn.Successors(state);
}
public bool IsGoal(S state)
{
return goalTest.IsGoal(state);
}
public C StepCost(S fromState, A action, S toState)
{
return stepCost.StepCost(fromState, action, toState);
}
public C Heuristic(S state)
{
return heuristicFn.Eval(state);
}
}
}