Table of Contents

Method GetPointsInRangeCost

Namespace
Gamelogic.Grids2
Assembly
Gamelogic.Grids2.dll

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.

public static Dictionary<TPoint, float> GetPointsInRangeCost<TPoint>(IGrid<TPoint> grid, TPoint start, Func<TPoint, IEnumerable<TPoint>> getConnectedPoints, Func<TPoint, bool> isAccessible, Func<TPoint, TPoint, float> getCellMoveCost, float moveRange)

Parameters

grid IGrid<TPoint>

The grid to use for the calculations

start TPoint

The starting point for the range calculation

getConnectedPoints Func<TPoint, IEnumerable<TPoint>>

This function is used to get the connected Points to a point.

isAccessible Func<TPoint, bool>

Whether the cell at the given point can be reached.

getCellMoveCost Func<TPoint, TPoint, float>

A function that returns the move cost given a cell

moveRange float

The range from which to return cells

Returns

Dictionary<TPoint, float>

Type Parameters

TPoint

Examples

Example usage:

var costs = Algorithms.GetPointsInRangeCost(
		grid,
		start,
		tile1, tile2 => DistanceBetween(tile1, tile2),
		5f);

Remarks

note

Author: Justin Kivak

See for detailed information on how to use this method.

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.

public static Dictionary<TPoint, int> GetPointsInRangeCost<TPoint>(IGrid<TPoint> grid, TPoint start, Func<TPoint, IEnumerable<TPoint>> getConnectedPoints, Func<TPoint, bool> isAccessible, Func<TPoint, TPoint, int> getCellMoveCost, int moveRange)

Parameters

grid IGrid<TPoint>

The grid used to make the calculations.

start TPoint

Point where the calculations will start.

getConnectedPoints Func<TPoint, IEnumerable<TPoint>>

This function is used to get the connected points to a given point.

isAccessible Func<TPoint, bool>

This function is used to know if a point is accessible within the grid.

getCellMoveCost Func<TPoint, TPoint, int>

This function is used to get the movement cost from moving to a cell.

moveRange int

Range of movement where make the calculations.

Returns

Dictionary<TPoint, int>

Type Parameters

TPoint

The type of the point used on the grid.

Remarks

note

Author: Justin Kivak

See for detailed information on how to use this method.