2016-12-12 06:41:35 +00:00
|
|
|
|
namespace SpriteCompiler.AI
|
2016-12-11 03:56:27 +00:00
|
|
|
|
{
|
2016-12-12 06:41:35 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using Queue;
|
2016-12-11 03:56:27 +00:00
|
|
|
|
|
2016-12-12 06:41:35 +00:00
|
|
|
|
public abstract class AbstractStateSpaceSearch<A, S, T, C> : ISearch<A, S, T, C>
|
2016-12-11 03:56:27 +00:00
|
|
|
|
where T : ISearchNode<A, S, T, C>
|
2016-12-12 06:41:35 +00:00
|
|
|
|
where C : ICost<C>
|
2016-12-11 03:56:27 +00:00
|
|
|
|
{
|
2016-12-12 06:41:35 +00:00
|
|
|
|
protected readonly ISearchStrategy<A, S, T, C> strategy;
|
|
|
|
|
private readonly Func<IQueue<T>> fringe;
|
2016-12-11 03:56:27 +00:00
|
|
|
|
|
2016-12-12 06:41:35 +00:00
|
|
|
|
public AbstractStateSpaceSearch(ISearchStrategy<A, S, T, C> strategy, Func<IQueue<T>> fringe)
|
2016-12-11 03:56:27 +00:00
|
|
|
|
{
|
2016-12-12 06:41:35 +00:00
|
|
|
|
this.strategy = strategy;
|
|
|
|
|
this.fringe = fringe;
|
2016-12-11 03:56:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-12-12 06:41:35 +00:00
|
|
|
|
public virtual IEnumerable<T> Search(ISearchProblem<A, S, C> problem, S initialState)
|
2016-12-11 03:56:27 +00:00
|
|
|
|
{
|
2016-12-12 06:41:35 +00:00
|
|
|
|
return strategy.Search(problem, fringe(), initialState);
|
2016-12-11 03:56:27 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|