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

Class containing various word algorithsm More...

Static Public Member Functions

static int LevenshteinDistance (String a, String b, IWordAlphabet alphabet)
 Calculates the edit distance between two strings using the given alphabet More...
 
static int LevenshteinDistance (IList< String > splitWordA, IList< String > splitWordB, IWordAlphabet alphabet)
 Calculates the edit distance between two pre-split words using the given alphabet More...
 
static int HammingDistance (String word1, String word2, IWordAlphabet alphabet)
 Calculates the hamming distance between two pre-split words using a given alphabet. More...
 
static int HammingDistance (IList< String > splitWordA, IList< String > splitWordB, IWordAlphabet alphabet)
 Calculates the hamming distance between two strings using a given alphabet. More...
 
static String ShuffleWord (String word, int minHammingDistance, IWordAlphabet alphabet)
 Shuffle the letters of a word and ensure a minimum hamming distance More...
 
static String MutateWord (String word, int minEditDistance, IWordAlphabet alphabet)
 Mutates a word to ensure a specific edit distance. More...
 
static String MutateWord (String word, int minEditDistance, int minWordLength, IWordAlphabet alphabet)
 Mutates a word to ensure a specific edit distance. More...
 
static String MutateWord (String word, IWordDictionary dictionary)
 Mutates a word to ensure a that no substrings are valid words More...
 
static String MutateWord (String word, int minWordLength, IWordDictionary dictionary)
 Mutates a word to ensure a that no substrings are valid words More...
 
static IList< IList< string > > LargestCommonSubstring (List< string > s1, List< string > s2)
 Returns the longests substrings of two strings as a list of letters. More...
 
static IList< string > LargestOverlap (List< string > s1, List< string > s2)
 Find the largest overlap shared between two words. More...
 

Detailed Description

Class containing various word algorithsm

Member Function Documentation

static int Gamelogic.Words.Algorithms.HammingDistance ( String  word1,
String  word2,
IWordAlphabet  alphabet 
)
static

Calculates the hamming distance between two pre-split words using a given alphabet.

Exceptions
ArgumentNullExceptionword1 or word2 or alphabet is null
InvalidOperationExceptionword1 and word2 are not the same length
Parameters
word1The first collection of letters
word2The second collection of letters
alphabetThe alphabet to operate on
static int Gamelogic.Words.Algorithms.HammingDistance ( IList< String >  splitWordA,
IList< String >  splitWordB,
IWordAlphabet  alphabet 
)
static

Calculates the hamming distance between two strings using a given alphabet.

Exceptions
ArgumentNullExceptionsplitWordA or splitWordA or alphabet is null
InvalidOperationExceptionsplitWordA and splitWordB are not the same length
Parameters
splitWordAThe first string
splitWordBThe second string
alphabetThe alphabet to operate on
static IList<IList<string> > Gamelogic.Words.Algorithms.LargestCommonSubstring ( List< string >  s1,
List< string >  s2 
)
static

Returns the longests substrings of two strings as a list of letters.

Parameters
s1The one string as a list of letters
s2The other string as a list of letters
Returns
A list whose elements are the longest substrings the given strings have in common, \ represented as a list of letters.
static IList<string> Gamelogic.Words.Algorithms.LargestOverlap ( List< string >  s1,
List< string >  s2 
)
static

Find the largest overlap shared between two words.

An overlap is a sufffix of the left word that is equal to a prefix of the right word. This operation is not symmetric.

LargestOverlap([smokey], [keys]) is [key], but LargestOverlap([keys], [smokey]) is [s]

Parameters
s1The left word, as a list of letters
s2The right word, as a list of letters
Returns
The biggest overlap shared between the two words.
static int Gamelogic.Words.Algorithms.LevenshteinDistance ( String  a,
String  b,
IWordAlphabet  alphabet 
)
static

Calculates the edit distance between two strings using the given alphabet

Implements Wagner-Fischer algorithm in two rows

Exceptions
ArgumentNullExceptionalphabet is null
Parameters
aThe first string
bThe second string
alphabetThe alphabet to operate on
static int Gamelogic.Words.Algorithms.LevenshteinDistance ( IList< String >  splitWordA,
IList< String >  splitWordB,
IWordAlphabet  alphabet 
)
static

Calculates the edit distance between two pre-split words using the given alphabet

Implements Wagner-Fischer algorithm in two rows

Exceptions
ArgumentNullExceptionalphabet or either word is null
Parameters
splitWordAThe first collection of letters
splitWordBThe second collection of letters
alphabetThe alphabet to operate on
static String Gamelogic.Words.Algorithms.MutateWord ( String  word,
int  minEditDistance,
IWordAlphabet  alphabet 
)
static

Mutates a word to ensure a specific edit distance.

Can add, remove, and mutate letters

While it is valid to specify an edit distance higher than the length of the word, this is not recommended. It is entirely possible for the algorithm to take a long time to complete, or to never terminate at all, if this value is too high. A sane range would keep the value between 2 and word .Length

Parameters
wordThe word to mutate
minEditDistanceThe minimum edit distance to ensure
alphabetThe alphabet we're operating with
Exceptions
ArgumentNullExceptionalphabet or word is null
Returns
The mutated word
static String Gamelogic.Words.Algorithms.MutateWord ( String  word,
int  minEditDistance,
int  minWordLength,
IWordAlphabet  alphabet 
)
static

Mutates a word to ensure a specific edit distance.

Can add, remove, and mutate letters

While it is valid to specify an edit distance higher than the length of the word, this is not recommended. It is entirely possible for the algorithm to take a long time to complete, or to never terminate at all, if this value is too high. A sane range would keep the value between 2 and word .Length

Parameters
wordThe word to mutate
minEditDistanceThe minimum edit distance to ensure
minWordLengthA minimum word length to maintain. The mutation will never remove more characters than this
alphabetThe alphabet we're operating with
Exceptions
ArgumentNullExceptionalphabet or word is null
Returns
The mutated word
static String Gamelogic.Words.Algorithms.MutateWord ( String  word,
IWordDictionary  dictionary 
)
static

Mutates a word to ensure a that no substrings are valid words

In the event that the source word already contains no substrings, no mutation operations will be performed and the source word will be returned as-is

Parameters
wordThe word to mutate
dictionaryThe dictionary to use to look for subwords
Exceptions
ArgumentNullExceptiondictionary or word is null
Returns
The mutated word
static String Gamelogic.Words.Algorithms.MutateWord ( String  word,
int  minWordLength,
IWordDictionary  dictionary 
)
static

Mutates a word to ensure a that no substrings are valid words

In the event that the source word already contains no substrings, no mutation operations will be performed and the source word will be returned as-is

Parameters
wordThe word to mutate
minWordLengthA minimum word length to maintain. The mutation will never remove more characters than this
dictionaryThe dictionary to use to look for subwords
Exceptions
ArgumentNullExceptiondictionary or word is null
Returns
The mutated word
static String Gamelogic.Words.Algorithms.ShuffleWord ( String  word,
int  minHammingDistance,
IWordAlphabet  alphabet 
)
static

Shuffle the letters of a word and ensure a minimum hamming distance

Parameters
wordThe word to shuffle
minHammingDistanceThe minimum hamming distance to ensure
alphabetThe alphabet we're operating with
Exceptions
ArgumentNullExceptionalphabet or word is null
ArgumentExceptionMinimum hamming distance is greater than the length of the word
Returns
A shuffled string

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