iigs-sprite-compiler/SpriteCompiler/AI/BestFirstSearch.cs

37 lines
1.0 KiB
C#
Raw Normal View History

namespace SpriteCompiler.AI
{
2016-11-27 05:39:50 +00:00
using Adapters;
using System.Collections.Generic;
public class BestFirstSearch<A, S, T, C> : ISearch<A, S, T, C>
where T : ISearchNode<A, S, T, C>
where C : IPathCost<C>
{
protected readonly AbstractAISearch<A, S, T, C> search;
protected readonly IQueue<T> fringe;
public BestFirstSearch(AbstractAISearch<A, S, T, C> search, IQueue<T> fringe)
{
this.search = search;
this.fringe = fringe;
}
2016-11-27 05:39:50 +00:00
public BestFirstSearch(AbstractAISearch<A, S, T, C> search)
{
this.search = search;
2016-11-27 05:39:50 +00:00
this.fringe = new QueueAdapter<T, C>();
}
public IEnumerable<T> Search(ISearchProblem<A, S, C> problem, S initialState)
{
fringe.Clear();
return search.Search(problem, fringe, initialState);
}
public IEnumerable<T> ExtendSearch(ISearchProblem<A, S, C> problem)
{
return search.ExtendSearch(problem, fringe);
}
}
}