Table of Contents

Class Algorithms

Namespace
Gamelogic.Grids2
Assembly
Gamelogic.Grids2.dll

This class provide generic functions for common grid operations, such as finding the shortest path or connected shapes.

public static class Algorithms
Inheritance
Algorithms
Inherited Members

Methods

AStar<TPoint>(IGrid<TPoint>, TPoint, TPoint, Func<TPoint, TPoint, float>, Func<TPoint, bool>, Func<TPoint, IEnumerable<TPoint>>, Func<TPoint, TPoint, float>)

Find the shortest path between a start and goal node.

AggregateNeighborhood<TPoint, TCell>(IGrid<TPoint, TCell>, Func<TPoint, IEnumerable<TPoint>>, Func<IEnumerable<TPoint>, TCell>)

Creates a new grid where the neighbors of a point are aggregated to the grid changing the type of the points.

AggregateNeighborhood<TPoint, TResultCell>(IGrid<TPoint>, Func<TPoint, IEnumerable<TPoint>>, Func<IEnumerable<TPoint>, TResultCell>)

Creates a new grid where the neighbors of a point are aggregated to the grid changing the type of the points.

Contains<TPoint>(IEnumerable<TPoint>, IEnumerable<TPoint>)

Checks whether all the points in smallShape are contained in the bigShape.

GetBiggestShape<TPoint>(IEnumerable<IEnumerable<TPoint>>)

Gets the biggest shape (by number of points) in the given list.

GetConnectedLines<TPoint>(IImplicitShape<TPoint>, TPoint, IEnumerable<IMap<TPoint, TPoint>>, Func<TPoint, TPoint, bool>)

Gets the longest line of connected points that contains this point. GetConnectedRays<TPoint>(IImplicitShape<TPoint>, TPoint, IEnumerable<IForwardMap<TPoint, TPoint>>, Func<TPoint, TPoint, bool>)

GetConnectedRays<TPoint>(IImplicitShape<TPoint>, TPoint, IEnumerable<IForwardMap<TPoint, TPoint>>, Func<TPoint, TPoint, bool>)

Returns a list containing lines connected to the given points. A line is a list of points. Only returns correct results for square or hex grids.

GetConnectedSet<TPoint>(IExplicitShape<TPoint>, TPoint, Func<TPoint, IEnumerable<TPoint>>)

Gets the largest connected set in the grid from the given point.

GetLongestConnectedLine<TPoint>(IImplicitShape<TPoint>, TPoint, IEnumerable<IMap<TPoint, TPoint>>, Func<TPoint, TPoint, bool>)

Get the longest line of points connected to the given point

GetLongestConnectedRay<TPoint>(IImplicitShape<TPoint>, TPoint, IEnumerable<IForwardMap<TPoint, TPoint>>, Func<TPoint, TPoint, bool>)

Gets the longest of the rays connected to this cell. GetConnectedRays<TPoint>(IImplicitShape<TPoint>, TPoint, IEnumerable<IForwardMap<TPoint, TPoint>>, Func<TPoint, TPoint, bool>)

GetPointsInRangeCost<TPoint>(IGrid<TPoint>, TPoint, Func<TPoint, IEnumerable<TPoint>>, Func<TPoint, bool>, Func<TPoint, TPoint, int>, int)

Gets all the points (and their costs) from a given point in a given range. This result is stored and returned in a dictionary.

GetPointsInRangeCost<TPoint>(IGrid<TPoint>, TPoint, Func<TPoint, IEnumerable<TPoint>>, Func<TPoint, bool>, Func<TPoint, TPoint, float>, float)

A generic function that returns the points in range based on a given start point, moveRange, and a function that returns the cost of moving between neighboring cells.

GetPointsInRange<TPoint>(IGrid<TPoint>, TPoint, Func<TPoint, IEnumerable<TPoint>>, Func<TPoint, bool>, Func<TPoint, TPoint, int>, int)

A generic function that returns the points in range based on a given start point, moveRange, and a function that returns the cost of moving between neighboring cells.

GetPointsInRange<TPoint>(IGrid<TPoint>, TPoint, Func<TPoint, IEnumerable<TPoint>>, Func<TPoint, bool>, Func<TPoint, TPoint, float>, float)

A generic function that returns the points in range based on a given start point, moveRange, and a function that returns the cost of moving between neighboring cells.

IsConnected<TPoint>(IGrid<TPoint>, IEnumerable<TPoint>, Func<TPoint, IEnumerable<TPoint>>)

The set of points is connected if there is a path from one point to each other point in the set. A path exists between two points if isConnected returns true for the two points, or there exists a third point that has a path to both.

IsConnected<TPoint, TCell>(IGrid<TPoint, TCell>, TPoint, TPoint, Func<TPoint, IEnumerable<TPoint>>, Func<TPoint, TPoint, bool>)

The set is connected if the set of points are neighbor-connected, and isNeighborsConnected return true for each two neighbors in the set.Two points are connected if they are neighbors, or one point has a neighbor that is neighbor-connected with the other point.

Another way to put this is, this function returns true if there is a set that connects point1 to point2.

IsEquivalentUnderTransformsAndTranslation<TPoint>(IEnumerable<TPoint>, IEnumerable<TPoint>, IEnumerable<Func<TPoint, TPoint>>, Func<IEnumerable<TPoint>, IEnumerable<TPoint>>)

Applies a function to the shapes and then checks if the results are equivalent.

IsEquivalentUnderTranslation<TPoint>(IEnumerable<TPoint>, IEnumerable<TPoint>, Func<IEnumerable<TPoint>, IEnumerable<TPoint>>)

Applies a function to the shapes and then checks if the results are equivalent.

IsEquivalent<TPoint>(IEnumerable<TPoint>, IEnumerable<TPoint>)

Checks if two shapes are equivalent. This happen when all shape1 points are contained in shape2 and vice versa.

TransformShape<TPoint>(IEnumerable<TPoint>, Func<TPoint, TPoint>)

Transform each point in the list with the give point transformation.