2016-11-30 14:17:05 +00:00
|
|
|
|
namespace SpriteCompiler.Problem
|
2016-11-27 05:41:11 +00:00
|
|
|
|
{
|
2016-11-30 14:17:05 +00:00
|
|
|
|
using SpriteCompiler.AI;
|
2016-11-27 05:41:11 +00:00
|
|
|
|
|
2016-11-30 14:17:05 +00:00
|
|
|
|
public sealed class SpriteGeneratorSearchProblem
|
2016-11-27 05:41:11 +00:00
|
|
|
|
{
|
2016-12-12 06:41:35 +00:00
|
|
|
|
public static ISearchProblem<CodeSequence, SpriteGeneratorState, IntegerCost> CreateSearchProblem()
|
2016-11-27 05:41:11 +00:00
|
|
|
|
{
|
|
|
|
|
var goalTest = new SpriteGeneratorGoalTest();
|
|
|
|
|
var stepCost = new SpriteGeneratorStepCost();
|
|
|
|
|
var successors = new SpriteGeneratorSuccessorFunction();
|
|
|
|
|
var heuristic = new SpriteGeneratorHeuristicFunction();
|
|
|
|
|
|
2016-12-12 06:41:35 +00:00
|
|
|
|
return new SearchProblem<CodeSequence, SpriteGeneratorState, IntegerCost>(goalTest, stepCost, successors, heuristic);
|
2016-11-27 05:41:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-12-12 06:41:35 +00:00
|
|
|
|
public static ISearch<CodeSequence, SpriteGeneratorState, SpriteGeneratorSearchNode, IntegerCost> Create()
|
2016-11-27 05:41:11 +00:00
|
|
|
|
{
|
2016-11-30 22:07:22 +00:00
|
|
|
|
var expander = new SpriteGeneratorNodeExpander();
|
2016-12-12 06:41:35 +00:00
|
|
|
|
var strategy = new TreeSearch<CodeSequence, SpriteGeneratorState, SpriteGeneratorSearchNode, IntegerCost>(expander);
|
|
|
|
|
var queue = new Adapters.QueueAdapter<SpriteGeneratorSearchNode, IntegerCost>();
|
2016-11-27 05:41:11 +00:00
|
|
|
|
|
2016-12-12 06:41:35 +00:00
|
|
|
|
return new AStarSearch<CodeSequence, SpriteGeneratorState, SpriteGeneratorSearchNode, IntegerCost>(strategy, queue);
|
2016-11-27 05:41:11 +00:00
|
|
|
|
}
|
2016-12-11 03:56:27 +00:00
|
|
|
|
|
2016-12-12 06:41:35 +00:00
|
|
|
|
public static ISearch<CodeSequence, SpriteGeneratorState, SpriteGeneratorSearchNode, IntegerCost> Create(int maxCycles)
|
2016-12-11 03:56:27 +00:00
|
|
|
|
{
|
|
|
|
|
var expander = new SpriteGeneratorNodeExpander();
|
2016-12-12 06:41:35 +00:00
|
|
|
|
var strategy = new TreeSearch<CodeSequence, SpriteGeneratorState, SpriteGeneratorSearchNode, IntegerCost>(expander);
|
|
|
|
|
var queue = new Adapters.QueueAdapter<SpriteGeneratorSearchNode, IntegerCost>();
|
2016-12-11 03:56:27 +00:00
|
|
|
|
|
2016-12-12 06:41:35 +00:00
|
|
|
|
var maxCost = (IntegerCost)maxCycles;
|
|
|
|
|
return new IterativeDeepeningAStarSearch<CodeSequence, SpriteGeneratorState, SpriteGeneratorSearchNode, IntegerCost>(strategy, maxCost);
|
2016-12-11 03:56:27 +00:00
|
|
|
|
}
|
2016-11-27 05:41:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|