mirror of
https://github.com/lscharen/iigs-sprite-compiler.git
synced 2024-09-16 15:55:41 +00:00
36 lines
1.1 KiB
C#
36 lines
1.1 KiB
C#
namespace SpriteCompiler.AI
|
|
{
|
|
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, IComparer<T> comparator)
|
|
{
|
|
this.search = search;
|
|
// this.fringe = new PriorityQueue<T>(INITIAL_CAPACITY, comparator);
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|
|
}
|