mirror of
https://github.com/lscharen/iigs-sprite-compiler.git
synced 2024-12-22 07:30:11 +00:00
37 lines
1.0 KiB
C#
37 lines
1.0 KiB
C#
namespace SpriteCompiler.AI
|
|
{
|
|
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;
|
|
}
|
|
|
|
public BestFirstSearch(AbstractAISearch<A, S, T, C> search)
|
|
{
|
|
this.search = search;
|
|
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);
|
|
}
|
|
}
|
|
}
|