Table of Contents

Class NeighborhoodExtensions

Namespace
LibGameAI.Util
Assembly
Util.dll

Useful extension methods for processing neighborhoods.

public static class NeighborhoodExtensions
Inheritance
NeighborhoodExtensions
Inherited Members

Methods

GetNeighborhood(Neighborhood, int)

Returns a collection of relative positions constituting the neighborhood of the given neighborhood type and radius.

public static IEnumerable<(int x, int y)> GetNeighborhood(this Neighborhood neighborhood, int radius)

Parameters

neighborhood Neighborhood

Neighborhood type.

radius int

Neighborhood radius.

Returns

IEnumerable<(int x, int y)>

A collection of relative positions constituting the neighborhood of the given neighborhood type and radius.

Exceptions

ArgumentException

Thrown if the neighborhood type is unknown.

HexNeighbors(int)

Returns a collection of relative positions constituting the hexagonal neighborhood with the given radius.

public static IEnumerable<(int x, int y)> HexNeighbors(int radius)

Parameters

radius int

Neighborhood radius.

Returns

IEnumerable<(int x, int y)>

A collection of relative positions constituting the hexagonal neighborhood with the given radius.

MaxNeighbors(Neighborhood, int)

Maximum number of neighbors for this neighborhood type and radius.

public static int MaxNeighbors(this Neighborhood neighborhood, int radius)

Parameters

neighborhood Neighborhood

Neighborhood type.

radius int

Neighborhood radius.

Returns

int

Maximum number of neighbors for this neighborhood type and radius.

Exceptions

ArgumentException

Thrown if the neighborhood type is unknown.

MooreNeighbors(int)

Returns a collection of relative positions constituting the Moore neighborhood with the given radius.

public static IEnumerable<(int x, int y)> MooreNeighbors(int radius)

Parameters

radius int

Neighborhood radius.

Returns

IEnumerable<(int x, int y)>

A collection of relative positions constituting the Moore neighborhood with the given radius.

VonNeumannNeighbors(int)

Returns a collection of relative positions constituting the Von Neumann neighborhood with the given radius.

public static IEnumerable<(int x, int y)> VonNeumannNeighbors(int radius)

Parameters

radius int

Neighborhood radius.

Returns

IEnumerable<(int x, int y)>

A collection of relative positions constituting the Von Neumann neighborhood with the given radius.