Class TilePropagator
TilePropagator is the main entrypoint to the DeBroglie library.
It takes a TileModel and an output Topology and generates
an output array using those parameters.
Inheritance
TilePropagator
Assembly: DeBroglie.dll
Syntax
public class TilePropagator
Constructors
|
Edit this page
View Source
TilePropagator(TileModel, ITopology, TilePropagatorOptions)
Declaration
public TilePropagator(TileModel tileModel, ITopology topology, TilePropagatorOptions options)
Parameters
|
Edit this page
View Source
TilePropagator(TileModel, ITopology, bool, ITileConstraint[])
Constructs a TilePropagator.
Declaration
public TilePropagator(TileModel tileModel, ITopology topology, bool backtrack = false, ITileConstraint[] constraints = null)
Parameters
Type |
Name |
Description |
TileModel |
tileModel |
The model to guide the generation.
|
ITopology |
topology |
The dimensions of the output to generate
|
bool |
backtrack |
If true, store additional information to allow rolling back choices that lead to a contradiction.
|
ITileConstraint[] |
constraints |
Extra constraints to control the generation process.
|
Properties
|
Edit this page
View Source
BackjumpCount
This is incremented each time it is necessary to backjump
while generating results (i.e. when multiple steps are undone simultaneously).
It is reset when Clear() is called.
Declaration
public int BackjumpCount { get; }
Property Value
|
Edit this page
View Source
BacktrackCount
This is incremented each time it is necessary to backtrack
a tile while generating results.
It is reset when Clear() is called.
Declaration
public int BacktrackCount { get; }
Property Value
|
Edit this page
View Source
ContradictionReason
A string indicating the reason a contradiction occured. This is sometimes set when Status is Contradiction.
Declaration
public string ContradictionReason { get; }
Property Value
|
Edit this page
View Source
ContradictionSource
An object indicating what caused the contradiction. This is somtimes set to a give constraint if the constraint caused the issue.
Declaration
public object ContradictionSource { get; }
Property Value
|
Edit this page
View Source
RandomDouble
Declaration
public Func<double> RandomDouble { get; }
Property Value
|
Edit this page
View Source
Status
The overall resolution of the generated array.
This will be Contradiction if at least one location is in contradiction (has no possible tiles)
otherwilse will be Undecided if at least one location is undecided (has multiple possible tiles)
and will be Decided otherwise (exactly one tile valid for each location).
Declaration
public Resolution Status { get; }
Property Value
|
Edit this page
View Source
TileModel
The model to use when generating.
Declaration
public TileModel TileModel { get; }
Property Value
|
Edit this page
View Source
Topology
The topology of the output.
Declaration
public ITopology Topology { get; }
Property Value
Methods
|
Edit this page
View Source
Ban(int, int, int, Tile)
Marks the given tile as not being a valid choice at a given location.
Then it propagates that information to other nearby tiles.
Declaration
public Resolution Ban(int x, int y, int z, Tile tile)
Parameters
Returns
|
Edit this page
View Source
Ban(int, int, int, TilePropagatorTileSet)
Marks the given tiles as not being a valid choice at a given location.
Then it propagates that information to other nearby tiles.
Declaration
public Resolution Ban(int x, int y, int z, TilePropagatorTileSet tiles)
Parameters
Returns
|
Edit this page
View Source
Ban(int, int, int, IEnumerable<Tile>)
Marks the given tiles as not being a valid choice at a given location.
Then it propagates that information to other nearby tiles.
Declaration
public Resolution Ban(int x, int y, int z, IEnumerable<Tile> tiles)
Parameters
Returns
|
Edit this page
View Source
Clear()
Resets the TilePropagator to the state it was in at construction.
Declaration
public Resolution Clear()
Returns
|
Edit this page
View Source
CreateChangeTracker()
Returns a tracker that indicates all recently changed tiles.
This is mostly useful as a performance optimization.
Trackers are valid until Clear() is called.
Declaration
public ChangeTracker CreateChangeTracker()
Returns
|
Edit this page
View Source
CreateSelectedChangeTracker(TilePropagatorTileSet, IQuadstateChanged)
Returns a tracker that runs a callback when the banned/selected status of tile changes with respect to a tileset.
Declaration
public SelectedChangeTracker CreateSelectedChangeTracker(TilePropagatorTileSet tileSet, IQuadstateChanged onChange)
Parameters
Returns
|
Edit this page
View Source
CreateSelectedTracker(TilePropagatorTileSet)
Returns a tracker that tracks the banned/selected status of each tile with respect to a tileset.
Declaration
public SelectedTracker CreateSelectedTracker(TilePropagatorTileSet tileSet)
Parameters
Returns
|
Edit this page
View Source
CreateTileSet(IEnumerable<Tile>)
Creates a set of tiles. This set can be used with some operations, and is marginally
faster than passing in a fresh list of tiles ever time.
Declaration
public TilePropagatorTileSet CreateTileSet(IEnumerable<Tile> tiles)
Parameters
Returns
|
Edit this page
View Source
GetBannedSelected(int, int, int, Tile, out bool, out bool)
Gets the results of both IsBanned and IsSelected
Declaration
public void GetBannedSelected(int x, int y, int z, Tile tile, out bool isBanned, out bool isSelected)
Parameters
|
Edit this page
View Source
GetBannedSelected(int, int, int, TilePropagatorTileSet, out bool, out bool)
isBanned is set to true if all the tiles are not valid in the location.
isSelected is set to true if no other the tiles are valid in the location.
Declaration
public void GetBannedSelected(int x, int y, int z, TilePropagatorTileSet tiles, out bool isBanned, out bool isSelected)
Parameters
|
Edit this page
View Source
GetBannedSelected(int, int, int, IEnumerable<Tile>, out bool, out bool)
isBanned is set to true if all the tiles are not valid in the location.
isSelected is set to true if no other the tiles are valid in the location.
Declaration
public void GetBannedSelected(int x, int y, int z, IEnumerable<Tile> tiles, out bool isBanned, out bool isSelected)
Parameters
|
Edit this page
View Source
GetPossibleTiles(int)
Declaration
public ISet<Tile> GetPossibleTiles(int index)
Parameters
Type |
Name |
Description |
int |
index |
|
Returns
|
Edit this page
View Source
GetPossibleValues<T>(int)
Declaration
public ISet<T> GetPossibleValues<T>(int index)
Parameters
Type |
Name |
Description |
int |
index |
|
Returns
Type Parameters
|
Edit this page
View Source
GetProgress()
Returns a number between 0 and 1 indicating how much of the generation is complete.
This number may decrease at times due to backtracking.
Declaration
public double GetProgress()
Returns
|
Edit this page
View Source
GetTile(int, Tile, Tile)
Gets the tile that has been decided at a given index.
Otherwise returns undecided or contradiction as appropriate.
Declaration
public Tile GetTile(int index, Tile undecided = default, Tile contradiction = default)
Parameters
Type |
Name |
Description |
int |
index |
|
Tile |
undecided |
|
Tile |
contradiction |
|
Returns
|
Edit this page
View Source
GetValue<T>(int, T, T)
Gets the value of a Tile that has been decided at a given index.
Otherwise returns undecided or contradiction as appropriate.
Declaration
public T GetValue<T>(int index, T undecided = default, T contradiction = default)
Parameters
Type |
Name |
Description |
int |
index |
|
T |
undecided |
|
T |
contradiction |
|
Returns
Type Parameters
|
Edit this page
View Source
GetWeightedTiles(int)
Declaration
public IDictionary<Tile, double> GetWeightedTiles(int index)
Parameters
Type |
Name |
Description |
int |
index |
|
Returns
|
Edit this page
View Source
IsBanned(int, int, int, Tile)
Returns true if this tile is the not a valid selection for a given location.
Declaration
public bool IsBanned(int x, int y, int z, Tile tile)
Parameters
Returns
|
Edit this page
View Source
IsSelected(int, int, int, Tile)
Returns true if this tile is the only valid selection for a given location.
Declaration
public bool IsSelected(int x, int y, int z, Tile tile)
Parameters
Returns
|
Edit this page
View Source
Run()
Repeatedly Steps until the status is Decided or Contradiction.
Declaration
Returns
|
Edit this page
View Source
Select(int, int, int, Tile)
Marks the given tile as the only valid choice at a given location.
This is equivalent to banning all other tiles.
Then it propagates that information to other nearby tiles.
Declaration
public Resolution Select(int x, int y, int z, Tile tile)
Parameters
Returns
|
Edit this page
View Source
Select(int, int, int, TilePropagatorTileSet)
Marks the given tiles as the only valid choice at a given location.
This is equivalent to banning all other tiles.
Then it propagates that information to other nearby tiles.
Declaration
public Resolution Select(int x, int y, int z, TilePropagatorTileSet tiles)
Parameters
Returns
|
Edit this page
View Source
Select(int, int, int, IEnumerable<Tile>)
Marks the given tiles as the only valid choice at a given location.
This is equivalent to banning all other tiles.
Then it propagates that information to other nearby tiles.
Declaration
public Resolution Select(int x, int y, int z, IEnumerable<Tile> tiles)
Parameters
Returns
|
Edit this page
View Source
SetContradiction()
Indicates that the generation cannot proceed, forcing the algorithm to backtrack or exit.
Declaration
public void SetContradiction()
|
Edit this page
View Source
SetContradiction(string, object)
Indicates that the generation cannot proceed, forcing the algorithm to backtrack or exit.
Declaration
public void SetContradiction(string reason, object source)
Parameters
|
Edit this page
View Source
Step()
Makes a single tile selection.
Then it propagates that information to other nearby tiles.
If backtracking is enabled a single step can include several backtracks,.
Declaration
Returns
|
Edit this page
View Source
StepConstraints()
Declaration
public void StepConstraints()
|
Edit this page
View Source
ToArray(Tile, Tile)
Converts the generated results to an ITopoArray<T>,
using specific tiles for locations that have not been decided or are in contradiction.
The arguments are not relevant if the Status is Decided.
Declaration
public ITopoArray<Tile> ToArray(Tile undecided = default, Tile contradiction = default)
Parameters
Type |
Name |
Description |
Tile |
undecided |
|
Tile |
contradiction |
|
Returns
|
Edit this page
View Source
ToArraySets()
Convert the generated result to an array of sets, where each set
indicates the tiles that are still valid at the location.
The size of the set indicates the resolution of that location:
Declaration
public ITopoArray<ISet<Tile>> ToArraySets()
Returns
|
Edit this page
View Source
ToValueArray<T>(T, T)
Converts the generated results to an ITopoArray<T>,
by extracting the value of each decided tile and
using specific values for locations that have not been decided or are in contradiction.
This is simply a convenience over
The arguments are not relevant if the Status is Decided.
Declaration
public ITopoArray<T> ToValueArray<T>(T undecided = default, T contradiction = default)
Parameters
Type |
Name |
Description |
T |
undecided |
|
T |
contradiction |
|
Returns
Type Parameters
|
Edit this page
View Source
ToValueSets<T>()
Convert the generated result to an array of sets, where each set
indicates the values of tiles that are still valid at the location.
The size of the set indicates the resolution of that location:
Declaration
public ITopoArray<ISet<T>> ToValueSets<T>()
Returns
Type Parameters
|
Edit this page
View Source
ToWeightedArraySets()
Declaration
public ITopoArray<IDictionary<Tile, double>> ToWeightedArraySets()
Returns