Words Library for Unity  1.0
A C# library for building and manipulating grids in Unity Game Engine.
Gamelogic.Words.Grids.GridAlgorithms Class Reference

Static Public Member Functions

static List< string > FillGridWithWords< TPoint > (AbstractUniformGrid< String, TPoint > grid, IWordAlphabet alphabet, IEnumerable< String > words)
 Fills a grid with a given collection of words More...
 
static List< string > FillGridWithWords< TPoint > (IGrid< String, TPoint > grid, IWordAlphabet alphabet, IEnumerable< String > words, Func< TPoint, int, bool, TPoint > directionFunction, int numDirections)
 Fills a grid with a given collection of words, providing the valid reading directions for the words More...
 
static void FillGridWithLetters< TPoint > (IGrid< String, TPoint > grid, IWordAlphabet alphabet, bool leaveExisting)
 Fills a grid with letters More...
 
static void FillGridWithLetters< TPoint > (IGrid< String, TPoint > grid, Func< string > letterFunc, bool leaveExisting)
 Fills a grid with letters More...
 
static List< TPoint > CheckForWord< TPoint > (AbstractUniformGrid< String, TPoint > grid, IWordDictionary dictionary, TPoint center)
 Check if any words can be made starting at this block and moving in any direction outwards More...
 
static List< TPoint > CheckForWord< TPoint > (IGrid< String, TPoint > grid, IWordDictionary dictionary, TPoint center, Func< TPoint, int, TPoint > directionFunction, int numDirections)
 Check if any words can be made starting at this block and moving in any direction outwards More...
 
static IEnumerable< IEnumerable< TPoint > > GetConnectedLines< TCell, TPoint, TBasePoint > (IEvenGrid< TCell, TPoint, TBasePoint > grid, TPoint point, Func< TPoint, TPoint, bool > isNeighborsConnected)
 Gets all the cells in the grid that is connected in a "line" from the given point. More...
 
static IEnumerable< IEnumerable< TPoint > > GetConnectedLines< TCell, TPoint > (IGrid< TCell, TPoint > grid, TPoint point, Func< TPoint, TPoint, bool > isNeighborsConnected, Func< TPoint, int, bool, TPoint > getNextPoint, int directionCount)
 Gets all the cells in the grid that is connected in a "line" from the given point. More...
 
static bool AreAllLinesWords< TPoint, TBasePoint > (IEvenGrid< string, TPoint, TBasePoint > grid, IEnumerable< TPoint > pointsToCheck, IWordDictionary dictionary)
 
static IEnumerable< IEnumerable< TPoint > > FindAllConnectedLines< TPoint, TBasePoint > (IEvenGrid< string, TPoint, TBasePoint > grid, IEnumerable< TPoint > pointsToCheck)
 

Member Function Documentation

static bool Gamelogic.Words.Grids.GridAlgorithms.AreAllLinesWords< TPoint, TBasePoint > ( IEvenGrid< string, TPoint, TBasePoint >  grid,
IEnumerable< TPoint >  pointsToCheck,
IWordDictionary  dictionary 
)
static

Template Parameters
TPoint
TBasePoint
Parameters
grid
pointsToCheck
dictionary
Returns
Type Constraints
TPoint :ISplicedVectorPoint 
TPoint :TPoint 
TPoint :TBasePoint 
TPoint :IGridPoint<TPoint> 
TBasePoint :IVectorPoint<TBasePoint> 
TBasePoint :IGridPoint<TBasePoint> 
static List<TPoint> Gamelogic.Words.Grids.GridAlgorithms.CheckForWord< TPoint > ( AbstractUniformGrid< String, TPoint >  grid,
IWordDictionary  dictionary,
TPoint  center 
)
static

Check if any words can be made starting at this block and moving in any direction outwards

Parameters
gridThe grid to search
dictionaryThe dictionary we're searching
centerThe point to search from
Returns
The list of points that describe the word found, or an empty list if none were.
Type Constraints
TPoint :IGridPoint<TPoint> 
TPoint :IVectorPoint<TPoint> 
static List<TPoint> Gamelogic.Words.Grids.GridAlgorithms.CheckForWord< TPoint > ( IGrid< String, TPoint >  grid,
IWordDictionary  dictionary,
TPoint  center,
Func< TPoint, int, TPoint >  directionFunction,
int  numDirections 
)
static

Check if any words can be made starting at this block and moving in any direction outwards

Parameters
gridThe grid to search
dictionaryThe dictionary we're searching
centerThe point to search from
directionFunctionA function to walk the given grid in a direction specified by some index
numDirectionsThe number of valid indices to directionFunction
Returns
The list of points that describe the word found, or an empty list if none were.
Type Constraints
TPoint :IGridPoint<TPoint> 
static void Gamelogic.Words.Grids.GridAlgorithms.FillGridWithLetters< TPoint > ( IGrid< String, TPoint >  grid,
IWordAlphabet  alphabet,
bool  leaveExisting 
)
static

Fills a grid with letters

Parameters
gridThe grid to fill. Must be a grid of strings
alphabetThe alphabet to use
leaveExistingWhether existing letters in the grid should be replaced. If this is true, all non-null grid elements will be left intact
Type Constraints
TPoint :IGridPoint<TPoint> 
static void Gamelogic.Words.Grids.GridAlgorithms.FillGridWithLetters< TPoint > ( IGrid< String, TPoint >  grid,
Func< string >  letterFunc,
bool  leaveExisting 
)
static

Fills a grid with letters

Parameters
gridThe grid to fill. Must be a grid of strings
letterFuncLetter generating function
leaveExistingWhether existing letters in the grid should be replaced. If this is true, all non-null grid elements will be left intact
Type Constraints
TPoint :IGridPoint<TPoint> 
static List<string> Gamelogic.Words.Grids.GridAlgorithms.FillGridWithWords< TPoint > ( AbstractUniformGrid< String, TPoint >  grid,
IWordAlphabet  alphabet,
IEnumerable< String >  words 
)
static

Fills a grid with a given collection of words

This function will not clear the grid in advance. It will attempt to place words in null or empty cells in the grid, around existing elements if they exist. It is not guaranteed to fit all the words in the grid

Parameters
gridThe grid to fill. Must be a grid of strings
alphabetThe alphabet to use
wordsThe words to attempt to place inside the grid
Type Constraints
TPoint :IGridPoint<TPoint> 
TPoint :IVectorPoint<TPoint> 
static List<string> Gamelogic.Words.Grids.GridAlgorithms.FillGridWithWords< TPoint > ( IGrid< String, TPoint >  grid,
IWordAlphabet  alphabet,
IEnumerable< String >  words,
Func< TPoint, int, bool, TPoint >  directionFunction,
int  numDirections 
)
static

Fills a grid with a given collection of words, providing the valid reading directions for the words

This function will not clear the grid in advance. It will attempt to place words in null or empty cells in the grid, around existing elements if they exist. It is not guaranteed to fit all the words in the grid

Parameters
gridThe grid to fill. Must be a grid of strings
alphabetThe alphabet to use
wordsThe words to attempt to place inside the grid
directionFunctionA function to walk the given grid in a direction specified by some index
numDirectionsThe number of valid indices to directionFunction
Returns
The words successfully added to the grid
Type Constraints
TPoint :IGridPoint<TPoint> 
static IEnumerable<IEnumerable<TPoint> > Gamelogic.Words.Grids.GridAlgorithms.FindAllConnectedLines< TPoint, TBasePoint > ( IEvenGrid< string, TPoint, TBasePoint >  grid,
IEnumerable< TPoint >  pointsToCheck 
)
static
Type Constraints
TPoint :ISplicedVectorPoint 
TPoint :TPoint 
TPoint :TBasePoint 
TPoint :IGridPoint<TPoint> 
TBasePoint :IVectorPoint<TBasePoint> 
TBasePoint :IGridPoint<TBasePoint> 
static IEnumerable<IEnumerable<TPoint> > Gamelogic.Words.Grids.GridAlgorithms.GetConnectedLines< TCell, TPoint > ( IGrid< TCell, TPoint >  grid,
TPoint  point,
Func< TPoint, TPoint, bool >  isNeighborsConnected,
Func< TPoint, int, bool, TPoint >  getNextPoint,
int  directionCount 
)
static

Gets all the cells in the grid that is connected in a "line" from the given point.

Line is defined by an arbitrary function that gives the next point in line, given a current point, the direction, and whether to go forward or backward.

Template Parameters
TCellThe cell type of the grid
TPointThe point type of the grid
Parameters
gridThe grid
pointThe point to start at
isNeighborsConnectedWhether of not neighbors are connected. Neighbors in this case are consecutive points on a line.
getNextPointA function used to traverse lines. It should give the next point in line from the given line in the given direction, either forward or backwards depending on the bool. It is up to the caller to interpret the direction index. This function will be called for all values of the direction index between 0 and one less than the direction count. It does not matter which direction is which index, as long as you handle it consistently. Finaly, if q == getNextPoint(p, n, true), then the following must hold: p == getNextPoint(q, n, false). Here is an example of a function that traverses lines on a rect grid:
public RectPoint GetNextPointInLineOnRectGrid(RectPoint p, int directionIndex, bool forward)
{
switch(directionIndex)
{
case 0: return point + forward?RectPoint.North, RectPoint.South;
case 1: return point + forward?RectPoint.West, RectPoint.East;
case 2: return point + forward?RectPoint.South, RectPoint.North;
case 3: return point + forward?RectPoint.East, RectPoint.West;
}
throw(new IllegalArgumentException);
}
Parameters
directionCountHow many line directions there are at each point. For example, hex grids have 6 for typical lines
Returns
Type Constraints
TPoint :IGridPoint<TPoint> 
static IEnumerable<IEnumerable<TPoint> > Gamelogic.Words.Grids.GridAlgorithms.GetConnectedLines< TCell, TPoint, TBasePoint > ( IEvenGrid< TCell, TPoint, TBasePoint >  grid,
TPoint  point,
Func< TPoint, TPoint, bool >  isNeighborsConnected 
)
static

Gets all the cells in the grid that is connected in a "line" from the given point.

Template Parameters
TCellThe cell type of the grid
TPointThe point type of the grid
TBasePointThe base point type of the point
Parameters
gridThe grid
pointThe point to start at
isNeighborsConnectedWhether of not neighbors are connected
Returns
Type Constraints
TPoint :ISplicedVectorPoint 
TPoint :TPoint 
TPoint :TBasePoint 
TPoint :IGridPoint<TPoint> 
TBasePoint :IVectorPoint<TBasePoint> 
TBasePoint :IGridPoint<TBasePoint> 

The documentation for this class was generated from the following file: