mirror of
https://github.com/lscharen/iigs-sprite-compiler.git
synced 2024-12-21 16:30:15 +00:00
Added initial set of generic AI search files
This commit is contained in:
commit
b3569db950
63
.gitattributes
vendored
Normal file
63
.gitattributes
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
###############################################################################
|
||||
# Set default behavior to automatically normalize line endings.
|
||||
###############################################################################
|
||||
* text=auto
|
||||
|
||||
###############################################################################
|
||||
# Set default behavior for command prompt diff.
|
||||
#
|
||||
# This is need for earlier builds of msysgit that does not have it on by
|
||||
# default for csharp files.
|
||||
# Note: This is only used by command line
|
||||
###############################################################################
|
||||
#*.cs diff=csharp
|
||||
|
||||
###############################################################################
|
||||
# Set the merge driver for project and solution files
|
||||
#
|
||||
# Merging from the command prompt will add diff markers to the files if there
|
||||
# are conflicts (Merging from VS is not affected by the settings below, in VS
|
||||
# the diff markers are never inserted). Diff markers may cause the following
|
||||
# file extensions to fail to load in VS. An alternative would be to treat
|
||||
# these files as binary and thus will always conflict and require user
|
||||
# intervention with every merge. To do so, just uncomment the entries below
|
||||
###############################################################################
|
||||
#*.sln merge=binary
|
||||
#*.csproj merge=binary
|
||||
#*.vbproj merge=binary
|
||||
#*.vcxproj merge=binary
|
||||
#*.vcproj merge=binary
|
||||
#*.dbproj merge=binary
|
||||
#*.fsproj merge=binary
|
||||
#*.lsproj merge=binary
|
||||
#*.wixproj merge=binary
|
||||
#*.modelproj merge=binary
|
||||
#*.sqlproj merge=binary
|
||||
#*.wwaproj merge=binary
|
||||
|
||||
###############################################################################
|
||||
# behavior for image files
|
||||
#
|
||||
# image files are treated as binary by default.
|
||||
###############################################################################
|
||||
#*.jpg binary
|
||||
#*.png binary
|
||||
#*.gif binary
|
||||
|
||||
###############################################################################
|
||||
# diff behavior for common document formats
|
||||
#
|
||||
# Convert binary document formats to text before diffing them. This feature
|
||||
# is only available from the command line. Turn it on by uncommenting the
|
||||
# entries below.
|
||||
###############################################################################
|
||||
#*.doc diff=astextplain
|
||||
#*.DOC diff=astextplain
|
||||
#*.docx diff=astextplain
|
||||
#*.DOCX diff=astextplain
|
||||
#*.dot diff=astextplain
|
||||
#*.DOT diff=astextplain
|
||||
#*.pdf diff=astextplain
|
||||
#*.PDF diff=astextplain
|
||||
#*.rtf diff=astextplain
|
||||
#*.RTF diff=astextplain
|
275
.gitignore
vendored
Normal file
275
.gitignore
vendored
Normal file
@ -0,0 +1,275 @@
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
##
|
||||
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
||||
|
||||
# User-specific files
|
||||
*.suo
|
||||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
*.vcxproj.filters
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
[Rr]eleases/
|
||||
x64/
|
||||
x86/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
[Ll]og/
|
||||
|
||||
# Visual Studio 2015 cache/options directory
|
||||
.vs/
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||
#wwwroot/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
# NUNIT
|
||||
*.VisualState.xml
|
||||
TestResult.xml
|
||||
|
||||
# Build Results of an ATL Project
|
||||
[Dd]ebugPS/
|
||||
[Rr]eleasePS/
|
||||
dlldata.c
|
||||
|
||||
# .NET Core
|
||||
project.lock.json
|
||||
project.fragment.lock.json
|
||||
artifacts/
|
||||
**/Properties/launchSettings.json
|
||||
|
||||
*_i.c
|
||||
*_p.c
|
||||
*_i.h
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*.log
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.svclog
|
||||
*.scc
|
||||
|
||||
# Chutzpah Test files
|
||||
_Chutzpah*
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opendb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
*.VC.db
|
||||
*.VC.VC.opendb
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
*.sap
|
||||
|
||||
# TFS 2012 Local Workspace
|
||||
$tf/
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
*.DotSettings.user
|
||||
|
||||
# JustCode is a .NET coding add-in
|
||||
.JustCode
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# Visual Studio code coverage results
|
||||
*.coverage
|
||||
*.coveragexml
|
||||
|
||||
# NCrunch
|
||||
_NCrunch_*
|
||||
.*crunch*.local.xml
|
||||
nCrunchTemp_*
|
||||
|
||||
# MightyMoose
|
||||
*.mm.*
|
||||
AutoTest.Net/
|
||||
|
||||
# Web workbench (sass)
|
||||
.sass-cache/
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.[Pp]ublish.xml
|
||||
*.azurePubxml
|
||||
# TODO: Comment the next line if you want to checkin your web deploy settings
|
||||
# but database connection strings (with potential passwords) will be unencrypted
|
||||
*.pubxml
|
||||
*.publishproj
|
||||
|
||||
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||
# in these scripts will be unencrypted
|
||||
PublishScripts/
|
||||
|
||||
# NuGet Packages
|
||||
*.nupkg
|
||||
# The packages folder can be ignored because of Package Restore
|
||||
**/packages/*
|
||||
# except build/, which is used as an MSBuild target.
|
||||
!**/packages/build/
|
||||
# Uncomment if necessary however generally it will be regenerated when needed
|
||||
#!**/packages/repositories.config
|
||||
# NuGet v3's project.json files produces more ignoreable files
|
||||
*.nuget.props
|
||||
*.nuget.targets
|
||||
|
||||
# Microsoft Azure Build Output
|
||||
csx/
|
||||
*.build.csdef
|
||||
|
||||
# Microsoft Azure Emulator
|
||||
ecf/
|
||||
rcf/
|
||||
|
||||
# Windows Store app package directories and files
|
||||
AppPackages/
|
||||
BundleArtifacts/
|
||||
Package.StoreAssociation.xml
|
||||
_pkginfo.txt
|
||||
|
||||
# Visual Studio cache files
|
||||
# files ending in .cache can be ignored
|
||||
*.[Cc]ache
|
||||
# but keep track of directories ending in .cache
|
||||
!*.[Cc]ache/
|
||||
|
||||
# Others
|
||||
ClientBin/
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.dbproj.schemaview
|
||||
*.jfm
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
node_modules/
|
||||
orleans.codegen.cs
|
||||
|
||||
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||
#bower_components/
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file
|
||||
# to a newer Visual Studio version. Backup files are not needed,
|
||||
# because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
|
||||
# SQL Server files
|
||||
*.mdf
|
||||
*.ldf
|
||||
|
||||
# Business Intelligence projects
|
||||
*.rdl.data
|
||||
*.bim.layout
|
||||
*.bim_*.settings
|
||||
|
||||
# Microsoft Fakes
|
||||
FakesAssemblies/
|
||||
|
||||
# GhostDoc plugin setting file
|
||||
*.GhostDoc.xml
|
||||
|
||||
# Node.js Tools for Visual Studio
|
||||
.ntvs_analysis.dat
|
||||
|
||||
# Visual Studio 6 build log
|
||||
*.plg
|
||||
|
||||
# Visual Studio 6 workspace options file
|
||||
*.opt
|
||||
|
||||
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||
*.vbw
|
||||
|
||||
# Visual Studio LightSwitch build output
|
||||
**/*.HTMLClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/ModelManifest.xml
|
||||
**/*.Server/GeneratedArtifacts
|
||||
**/*.Server/ModelManifest.xml
|
||||
_Pvt_Extensions
|
||||
|
||||
# Paket dependency manager
|
||||
.paket/paket.exe
|
||||
paket-files/
|
||||
|
||||
# FAKE - F# Make
|
||||
.fake/
|
||||
|
||||
# JetBrains Rider
|
||||
.idea/
|
||||
*.sln.iml
|
||||
|
||||
# CodeRush
|
||||
.cr/
|
||||
|
||||
# Python Tools for Visual Studio (PTVS)
|
||||
__pycache__/
|
||||
*.pyc
|
||||
|
||||
# Cake - Uncomment if you are using it
|
||||
# tools/
|
19
README.md
Normal file
19
README.md
Normal file
@ -0,0 +1,19 @@
|
||||
## Synopsis
|
||||
|
||||
A sprite compiler that targets 16-bit 65816 assembly code on the Apple IIgs computer. The sprite compiler uses informed search techniques to generate optimal code for whole-sprite rendering.
|
||||
|
||||
## Code Example
|
||||
|
||||
## Motivation
|
||||
|
||||
## Installation
|
||||
|
||||
## API Reference
|
||||
|
||||
## Tests
|
||||
|
||||
## Contributors
|
||||
|
||||
## License
|
||||
|
||||
MIT License
|
22
SpriteCompiler.sln
Normal file
22
SpriteCompiler.sln
Normal file
@ -0,0 +1,22 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.25420.1
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SpriteCompiler", "SpriteCompiler/SpriteCompiler.csproj", "{56F54CA9-17C1-45C6-915B-6FABF4DAE5D0}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{56F54CA9-17C1-45C6-915B-6FABF4DAE5D0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{56F54CA9-17C1-45C6-915B-6FABF4DAE5D0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{56F54CA9-17C1-45C6-915B-6FABF4DAE5D0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{56F54CA9-17C1-45C6-915B-6FABF4DAE5D0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
21
SpriteCompiler/AI/AStarComparer.cs
Normal file
21
SpriteCompiler/AI/AStarComparer.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SpriteCompiler.AI
|
||||
{
|
||||
public class AStarComparator<A, S, T, C> : IComparer<T>
|
||||
where T : HeuristicSearchNode<A, S, T, C>
|
||||
where C : IPathCost<C>
|
||||
{
|
||||
public int Compare(T x, T y)
|
||||
{
|
||||
var cost1 = x.Heuristic.Add(x.PathCost);
|
||||
var cost2 = y.Heuristic.Add(y.PathCost);
|
||||
|
||||
return cost1.CompareTo(cost2);
|
||||
}
|
||||
}
|
||||
}
|
17
SpriteCompiler/AI/AStarSearch.cs
Normal file
17
SpriteCompiler/AI/AStarSearch.cs
Normal file
@ -0,0 +1,17 @@
|
||||
namespace SpriteCompiler.AI
|
||||
{
|
||||
public class AStarSearch<A, S, T, C> : BestFirstSearch<A, S, T, C>
|
||||
where T : HeuristicSearchNode<A, S, T, C>
|
||||
where C : IPathCost<C>
|
||||
{
|
||||
public AStarSearch(AbstractAISearch<A, S, T, C> search)
|
||||
: base(search, new AStarComparator<A, S, T, C>())
|
||||
{
|
||||
}
|
||||
|
||||
public AStarSearch(AbstractAISearch<A, S, T, C> search, IQueue<T> fringe)
|
||||
: base(search, fringe)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
79
SpriteCompiler/AI/AbstractAISearch.cs
Normal file
79
SpriteCompiler/AI/AbstractAISearch.cs
Normal file
@ -0,0 +1,79 @@
|
||||
namespace SpriteCompiler.AI
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
public abstract class AbstractAISearch<A, S, T, C>
|
||||
where T : ISearchNode<A, S, T, C>
|
||||
where C : IComparable<C>
|
||||
{
|
||||
// Conceptually the expander is responsible for two things:
|
||||
//
|
||||
// 1. Creating a node's successors via the Successor Function
|
||||
// and wrapping them in SearchNodes (computing path costs
|
||||
// and heuristics, as well).
|
||||
//
|
||||
// 2. Creating a search node from a state. This lets us
|
||||
// decouple the search algorithm from the state expansion
|
||||
|
||||
private INodeExpander<A, S, T, C> expander;
|
||||
|
||||
public AbstractAISearch(INodeExpander<A, S, T, C> expander)
|
||||
{
|
||||
this.expander = expander;
|
||||
}
|
||||
|
||||
public INodeExpander<A, S, T, C> Expander { get { return expander; } }
|
||||
|
||||
public IEnumerable<T> Solution(T node)
|
||||
{
|
||||
var sequence = new List<T>();
|
||||
|
||||
while (node != null)
|
||||
{
|
||||
sequence.Add(node);
|
||||
node = node.Parent;
|
||||
}
|
||||
|
||||
sequence.Reverse();
|
||||
|
||||
return sequence;
|
||||
}
|
||||
|
||||
public IEnumerable<T> ExtendSearch(ISearchProblem<A, S, C> problem, IQueue<T> fringe)
|
||||
{
|
||||
while (!fringe.Empty)
|
||||
{
|
||||
var node = fringe.Remove();
|
||||
|
||||
if (problem.IsGoal(node.State))
|
||||
{
|
||||
return Solution(node);
|
||||
}
|
||||
|
||||
AddNodes(fringe, node, problem);
|
||||
}
|
||||
|
||||
return Enumerable.Empty<T>();
|
||||
}
|
||||
|
||||
public IEnumerable<T> Expand(ISearchProblem<A, S, C> problem, T node)
|
||||
{
|
||||
return expander.Expand(problem, node);
|
||||
}
|
||||
|
||||
public bool IsFailure(IEnumerable<T> solution)
|
||||
{
|
||||
return !solution.Any();
|
||||
}
|
||||
|
||||
public IEnumerable<T> Search(ISearchProblem<A, S, C> problem, IQueue<T> fringe, S initialState)
|
||||
{
|
||||
fringe.Enqueue(expander.CreateNode(default(T), initialState));
|
||||
return ExtendSearch(problem, fringe);
|
||||
}
|
||||
|
||||
protected abstract void AddNodes(IQueue<T> fringe, T node, ISearchProblem<A, S, C> problem);
|
||||
}
|
||||
}
|
47
SpriteCompiler/AI/AbstractSearchNode.cs
Normal file
47
SpriteCompiler/AI/AbstractSearchNode.cs
Normal file
@ -0,0 +1,47 @@
|
||||
namespace SpriteCompiler.AI
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public abstract class AbstractSearchNode<A, S, T, C> : ISearchNode<A, S, T, C>
|
||||
where T : ISearchNode<A, S, T, C>
|
||||
where C : IPathCost<C>
|
||||
{
|
||||
protected readonly S state;
|
||||
protected readonly T parent;
|
||||
protected A action = default(A);
|
||||
|
||||
protected C pathCost = default(C);
|
||||
protected C stepCost = default(C);
|
||||
protected readonly int depth;
|
||||
|
||||
public AbstractSearchNode(T node, S state)
|
||||
{
|
||||
this.state = state;
|
||||
this.parent = node;
|
||||
this.depth = HasParent ? parent.Depth + 1 : 0;
|
||||
}
|
||||
|
||||
private bool HasParent { get { return !EqualityComparer<T>.Default.Equals(parent, default(T)); } }
|
||||
|
||||
public A Action { get { return action; } set { action = value; } }
|
||||
public T Parent { get { return parent; } }
|
||||
public C PathCost { get { return pathCost; } }
|
||||
public int Depth { get { return depth; } }
|
||||
public S State { get { return state; } }
|
||||
|
||||
public C StepCost
|
||||
{
|
||||
get
|
||||
{
|
||||
return stepCost;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
stepCost = value;
|
||||
pathCost = HasParent ? parent.PathCost.Add(value) : value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
35
SpriteCompiler/AI/BestFirstSearch.cs
Normal file
35
SpriteCompiler/AI/BestFirstSearch.cs
Normal file
@ -0,0 +1,35 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
16
SpriteCompiler/AI/HeuristicSearchNode.cs
Normal file
16
SpriteCompiler/AI/HeuristicSearchNode.cs
Normal file
@ -0,0 +1,16 @@
|
||||
namespace SpriteCompiler.AI
|
||||
{
|
||||
using System;
|
||||
|
||||
public class HeuristicSearchNode<A, S, T, C> : AbstractSearchNode<A, S, T, C>, ISearchNode<A, S, T, C>
|
||||
where T : HeuristicSearchNode<A, S, T, C>
|
||||
where C : IPathCost<C>
|
||||
{
|
||||
public HeuristicSearchNode(T node, S state)
|
||||
: base(node, state)
|
||||
{
|
||||
}
|
||||
|
||||
public C Heuristic { get; set; }
|
||||
}
|
||||
}
|
19
SpriteCompiler/AI/INodeExpander.cs
Normal file
19
SpriteCompiler/AI/INodeExpander.cs
Normal file
@ -0,0 +1,19 @@
|
||||
namespace SpriteCompiler.AI
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
/// <summary>
|
||||
/// The NodeExpander class encapsulates a strategy of how the expand one state
|
||||
/// into its successor states.In the simplest case, a node's state is expanded
|
||||
/// using a problem-specific sucessor function, new search nodes are created and
|
||||
/// the list is returned.
|
||||
/// </summary>
|
||||
public interface INodeExpander<A, S, T, C>
|
||||
where T : ISearchNode<A, S, T, C>
|
||||
where C : IComparable<C>
|
||||
{
|
||||
IEnumerable<T> Expand(ISearchProblem<A, S, C> problem, T node);
|
||||
T CreateNode(T parent, S state);
|
||||
}
|
||||
}
|
9
SpriteCompiler/AI/IPathCost.cs
Normal file
9
SpriteCompiler/AI/IPathCost.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace SpriteCompiler.AI
|
||||
{
|
||||
using System;
|
||||
|
||||
public interface IPathCost<C> : IComparable<C>
|
||||
{
|
||||
C Add(C value);
|
||||
}
|
||||
}
|
12
SpriteCompiler/AI/IQueue.cs
Normal file
12
SpriteCompiler/AI/IQueue.cs
Normal file
@ -0,0 +1,12 @@
|
||||
namespace SpriteCompiler.AI
|
||||
{
|
||||
using System;
|
||||
|
||||
public interface IQueue<T>
|
||||
{
|
||||
void Clear();
|
||||
bool Empty { get; }
|
||||
T Remove();
|
||||
void Enqueue(T item);
|
||||
}
|
||||
}
|
24
SpriteCompiler/AI/ISearch.cs
Normal file
24
SpriteCompiler/AI/ISearch.cs
Normal file
@ -0,0 +1,24 @@
|
||||
namespace SpriteCompiler.AI
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
|
||||
public interface ISearch<A, S, T, C>
|
||||
where T : ISearchNode<A, S, T, C>
|
||||
where C : IPathCost<C>
|
||||
{
|
||||
/// Perform a new search on the specified search problem using the given
|
||||
/// initial state as a starting point. The method will return an empty
|
||||
/// list on failure.
|
||||
IEnumerable<T> Search(ISearchProblem<A, S, C> problem, S initialState);
|
||||
|
||||
/**
|
||||
* Continues to run a search after a solution is found. This can
|
||||
* be useful for enumerating over all the solutions to a search problem.
|
||||
*
|
||||
* @param problem
|
||||
* @return Sequence of search nodes desribing a solution
|
||||
*/
|
||||
IEnumerable<T> ExtendSearch(ISearchProblem<A, S, C> problem);
|
||||
|
||||
}
|
||||
}
|
21
SpriteCompiler/AI/ISearchNode.cs
Normal file
21
SpriteCompiler/AI/ISearchNode.cs
Normal file
@ -0,0 +1,21 @@
|
||||
namespace SpriteCompiler.AI
|
||||
{
|
||||
using System;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <typeparam name="A">Action on a node</typeparam>
|
||||
/// <typeparam name="S">State of the search</typeparam>
|
||||
/// <typeparam name="T">Type of the parent</typeparam>
|
||||
/// <typeparam name="C">Cost type</typeparam>
|
||||
public interface ISearchNode<A, S, T, C> where C : IComparable<C>
|
||||
{
|
||||
A Action { get; set; }
|
||||
C StepCost { get; set; }
|
||||
C PathCost { get; }
|
||||
int Depth { get; }
|
||||
S State { get; }
|
||||
T Parent { get; }
|
||||
}
|
||||
}
|
14
SpriteCompiler/AI/ISearchProblem.cs
Normal file
14
SpriteCompiler/AI/ISearchProblem.cs
Normal file
@ -0,0 +1,14 @@
|
||||
namespace SpriteCompiler.AI
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public interface ISearchProblem<A, S, C>
|
||||
where C : IComparable<C>
|
||||
{
|
||||
IDictionary<A, S> Successors(S state);
|
||||
bool IsGoal(S state);
|
||||
C StepCost(S fromState, A action, S toState);
|
||||
C Heuristic(S state);
|
||||
}
|
||||
}
|
6
SpriteCompiler/App.config
Normal file
6
SpriteCompiler/App.config
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
|
||||
</startup>
|
||||
</configuration>
|
9
SpriteCompiler/Program.cs
Normal file
9
SpriteCompiler/Program.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace SpriteCompiler
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
36
SpriteCompiler/Properties/AssemblyInfo.cs
Normal file
36
SpriteCompiler/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("SpriteCompiler")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("SpriteCompiler")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2016")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("56f54ca9-17c1-45c6-915b-6fabf4dae5d0")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
78
SpriteCompiler/SpriteCompiler.csproj
Normal file
78
SpriteCompiler/SpriteCompiler.csproj
Normal file
@ -0,0 +1,78 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{56F54CA9-17C1-45C6-915B-6FABF4DAE5D0}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>SpriteCompiler</RootNamespace>
|
||||
<AssemblyName>SpriteCompiler</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Priority Queue, Version=4.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\OptimizedPriorityQueue.4.0.0\lib\net45\Priority Queue.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AI\AbstractAISearch.cs" />
|
||||
<Compile Include="AI\AbstractSearchNode.cs" />
|
||||
<Compile Include="AI\AStarComparer.cs" />
|
||||
<Compile Include="AI\AStarSearch.cs" />
|
||||
<Compile Include="AI\BestFirstSearch.cs" />
|
||||
<Compile Include="AI\HeuristicSearchNode.cs" />
|
||||
<Compile Include="AI\INodeExpander.cs" />
|
||||
<Compile Include="AI\IPathCost.cs" />
|
||||
<Compile Include="AI\IQueue.cs" />
|
||||
<Compile Include="AI\ISearch.cs" />
|
||||
<Compile Include="AI\ISearchNode.cs" />
|
||||
<Compile Include="AI\ISearchProblem.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
4
SpriteCompiler/packages.config
Normal file
4
SpriteCompiler/packages.config
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="OptimizedPriorityQueue" version="4.0.0" targetFramework="net452" />
|
||||
</packages>
|
Loading…
Reference in New Issue
Block a user