MFMv2.0.10
Movable Feast Machine Simulator 2.0.10
|
#include <WindowScanner.h>
Public Member Functions | |
WindowScanner (EventWindow< CC > &window) | |
~WindowScanner () | |
bool | FillIfType (const SPoint &relative, const u32 type, const T &atom) |
bool | FillIfNotType (const SPoint &relative, const u32 type, const T &atom) |
bool | FillIfEmpty (const SPoint &relative, const T &atom) |
bool | CanSeeAtomOfType (const u32 type, const u32 radius) const |
u32 | CountAtomsOfType (const u32 type, const u32 radius) const |
u32 | CountEmptyAtoms (const u32 radius) const |
bool | IsBorderingNeighborhood (const u32 type, const Dir *neighborhood, const u32 dirCount) const |
bool | IsBorderingMoore (const u32 type) const |
bool | IsBorderingVonNeumann (const u32 type) const |
u32 | CountInNeighborhood (const u32 type, const Dir *neighborhood, const u32 dirCount) const |
u32 | CountMooreNeighbors (const u32 type) const |
u32 | CountVonNeumannNeighbors (const u32 type) const |
u32 | FindRandomLocationOfType (const u32 type, SPoint &outPoint) const |
u32 | FindRandomLocationOfType (const u32 type, const u32 radius, SPoint &outPoint) const |
u32 | FindRandomInSubWindow (const u32 type, const SPoint *subWindow, const u32 subCount, SPoint &outPoint) const |
u32 | FindEmptyInSubWindow (const SPoint *subWindow, const u32 subCount, SPoint &outPoint) const |
u32 | FindRandomInNeighborhood (const u32 type, const Dir *dirs, const u32 dirCount, SPoint &outPoint) const |
u32 | FindEmptyInNeighborhood (const Dir *dirs, const u32 dirCount, SPoint &outPoint) const |
u32 | FindRandomInMoore (const u32 type, SPoint &outPoint) const |
u32 | FindRandomInVonNeumann (const u32 type, SPoint &outPoint) const |
u32 | FindEmptyInMoore (SPoint &outPoint) const |
u32 | FindEmptyInVonNeumann (SPoint &outPoint) const |
void | FindRandomAtoms (const u32 radius, const u32 count,...) const |
void | FindRandomAtoms (const u32 count,...) const |
bool | FindRandomAtomsInSubWindows (const u32 count,...) const |
A wrapper for the EventWindow class which allows for EventWindow searching and other powerful EventWindow modifications.
MFM::WindowScanner< CC >::WindowScanner | ( | EventWindow< CC > & | window | ) |
Constructs a new WindowScanner that is ready to be used on a given EventWindow.
window | A reference to the EventWindow which the new instance of this class may read or write to. |
|
inline |
Deconstructs this WindowScanner .
bool MFM::WindowScanner< CC >::CanSeeAtomOfType | ( | const u32 | type, |
const u32 | radius | ||
) | const |
Scans the held EventWindow up to a specified radius (not including the center Atom) and sees whether or not an Atom of a specified type exists.
type | The type of the Atom being scanned for. |
radius | The maximum radius to expand this search to. This FAILs with ILLEGAL_ARGUMENT if this argument is either 0 or greater than the EventWindow radius. |
true
if an Atom of type type
is found within radius
of the center atom (discluding the center atom), else false
. u32 MFM::WindowScanner< CC >::CountAtomsOfType | ( | const u32 | type, |
const u32 | radius | ||
) | const |
Scans the held EventWindow up to a specified radius (not including the center Atom) and counts the Atoms which are of a specified type.
type | The type of the Atom being scanned for. |
radius | The maximum radius to expand this search to. This FAILs with ILLEGAL_ARGUMENT if this argument is either 0 or greater than the EventWindow radius. |
type
within of the center atom (not including the center atom) in the held EventWindow. u32 MFM::WindowScanner< CC >::CountEmptyAtoms | ( | const u32 | radius | ) | const |
Scans the held EventWindow up to a specified radius (not including the center Atom) and counts the Atoms which represent Element_Empty
radius | The maximum radius to expand this search to. This FAILs with ILLEGAL_ARGUMENT if this argument is either 0 or greater than the EventWindow radius. |
u32 MFM::WindowScanner< CC >::CountInNeighborhood | ( | const u32 | type, |
const Dir * | neighborhood, | ||
const u32 | dirCount | ||
) | const |
Scans a specified neighborhood consisting of Dirs directly surrounding the center Atom and counts the Atoms of a specified type.
type | The type of the Atoms to search for. |
neighborhood | An array of Dirs representing the neighborhood around the central Atom. |
dirCount | The number of elements inside the neighborhood array. |
neighborhood
which are of type type
. u32 MFM::WindowScanner< CC >::CountMooreNeighbors | ( | const u32 | type | ) | const |
u32 MFM::WindowScanner< CC >::CountVonNeumannNeighbors | ( | const u32 | type | ) | const |
bool MFM::WindowScanner< CC >::FillIfEmpty | ( | const SPoint & | relative, |
const T & | atom | ||
) |
Examines the held EventWindow at a given point and fills the atom there with a specified Atom if it is occupied by an Atom representing Element_Empty.
relative | The loaction of the held EventWindow to examine. |
atom | The Atom to place in relative if it is occupied by an Element_Empty Atom. |
true
if the Atom at the relative
location represents Element_Empty and therefore will be replaced by atom
, else false
. bool MFM::WindowScanner< CC >::FillIfNotType | ( | const SPoint & | relative, |
const u32 | type, | ||
const T & | atom | ||
) |
Replaces the Atom at a specified relative location from the center Atom of the held EventWindow with another specified atom if the existing atom is not of a particular type.
relative | The location, relative to the center of the held EventWindow, of the Atom to inspect and perhaps replace. |
type | The type of the Atom supposed to be in the relative location. If the Atom in relative is not this type , it will be replaced with the specified Atom. |
atom | The Atom to write to relative if the existing Atom is not type type . |
true
if the atom at relative
was replaced by atom
, else false
. bool MFM::WindowScanner< CC >::FillIfType | ( | const SPoint & | relative, |
const u32 | type, | ||
const T & | atom | ||
) |
Replaces the Atom at a specified relative location from the center Atom of the held EventWindow with another specified atom if the existing atom is of a particular type.
relative | The location, relative to the center of the held EventWindow, of the Atom to inspect and perhaps replace. |
type | The type of the Atom supposed to be in the relative location. If the Atom in relative is this type , it will be replaced with the specified Atom. |
atom | The Atom to write to relative if the existing Atom is type type . |
true
if the atom at relative
was replaced by atom
, else false
. u32 MFM::WindowScanner< CC >::FindEmptyInMoore | ( | SPoint & | outPoint | ) | const |
Searches the Moore neighborhood around the center atom of the held EventWindow for an Atom representing Element_Empty , giving its location if found.
outPoint | an output parameter; The SPoint to fill with the coordinates of a randomly chosen atom if one representing Element_Empty is located. If this method returns 0 , the contents of this SPoint are undefined. |
u32 MFM::WindowScanner< CC >::FindEmptyInNeighborhood | ( | const Dir * | dirs, |
const u32 | dirCount, | ||
SPoint & | outPoint | ||
) | const |
Searches a specified neighborhood around the center atom of the held EventWindow for an Atom representing Element_Empty , giving its location if found.
dirs | An array of Dirs specifying the neighborhood to search around the center Atom. |
dirCount | The number of Dir elements inside of dirs . |
outPoint | an output parameter; The SPoint to fill with the coordinates of a randomly chosen atom if one representing Element_Empty is located. If this method returns false , the contents of this SPoint are undefined. |
u32 MFM::WindowScanner< CC >::FindEmptyInSubWindow | ( | const SPoint * | subWindow, |
const u32 | subCount, | ||
SPoint & | outPoint | ||
) | const |
Scans a subset of the held EventWindow, specified by a given set of relative Points, for an Atom representing Element_Empty, placing the location of a randomly chosen Atom in an output Point.
subWindow | The array of relative Points to search through. |
subCount | The length of the subWindow array. |
outPoint | An output parameter; The SPoint to fill with the coordinates of a randomly chosen atom if one of the correct type is located. If this method returns 0 , the contents of this SPoint are undefined. |
u32 MFM::WindowScanner< CC >::FindEmptyInVonNeumann | ( | SPoint & | outPoint | ) | const |
Searches the Von Neumann neighborhood around the center atom of the held EventWindow for an Atom representing Element_Empty , giving its location if found.
outPoint | an output parameter; The SPoint to fill with the coordinates of a randomly chosen atom if one representing Element_Empty is located. If this method returns 0 , the contents of this SPoint are undefined. |
void MFM::WindowScanner< CC >::FindRandomAtoms | ( | const u32 | radius, |
const u32 | count, | ||
... | |||
) | const |
Searches the held EventWindow under a specified radius for different types of Atoms, giving the number of Atoms found and the location of a randomly chosen one for each being searched for.
radius | The radius of the search over the held EventWindow in manhattan distance. The center Atom is never included in this search. |
count | The number of Atom - Type pairs being searched for. |
... | A variadic number of triplets specifying this particular search. Each triplet consists of three parts: |
void MFM::WindowScanner< CC >::FindRandomAtoms | ( | const u32 | count, |
... | |||
) | const |
Searches the held EventWindow for different types of Atoms, giving the number of Atoms found and the location of a randomly chosen one for each being searched for.
count | The number of Atom - Type pairs being searched for. |
... | A variadic number of triplets specifying this particular search. Each triplet consists of three parts: |
u32 MFM::WindowScanner< CC >::FindRandomInMoore | ( | const u32 | type, |
SPoint & | outPoint | ||
) | const |
Searches the Moore neighborhood around the center atom of the held EventWindow for an Atom of a specified type, giving its location if found.
type | The type of the Atom to search for. |
outPoint | an output parameter; The SPoint to fill with the coordinates of a randomly chosen atom if one of type type is located. If this method returns 0 , the contents of this SPoint are undefined. |
type
. u32 MFM::WindowScanner< CC >::FindRandomInNeighborhood | ( | const u32 | type, |
const Dir * | dirs, | ||
const u32 | dirCount, | ||
SPoint & | outPoint | ||
) | const |
Searches a specified neighborhood around the center atom of the held EventWindow for an Atom of a specified type, giving its location if found.
type | The type of the Atom to search for. |
dirs | An array of Dirs specifying the neighborhood to search around the center Atom. |
dirCount | The number of Dir elements inside of dirs . |
outPoint | an output parameter; The SPoint to fill with the coordinates of a randomly chosen atom if one of type type is located. If this method returns false , the contents of this SPoint are undefined. |
type
. u32 MFM::WindowScanner< CC >::FindRandomInSubWindow | ( | const u32 | type, |
const SPoint * | subWindow, | ||
const u32 | subCount, | ||
SPoint & | outPoint | ||
) | const |
Scans a subset of the held EventWindow, specified by a given set of relative Points, for an Atom of a particular type, placing the location of a randomly chosen Atom in an output Point.
type | The type of the Atom to search for in this subset. |
subWindow | The array of relative Points to search through. |
subCount | The length of the subWindow array. |
outPoint | An output parameter; The SPoint to fill with the coordinates of a randomly chosen atom if one of the correct type is located. If this method returns 0 , the contents of this SPoint are undefined. |
type
. u32 MFM::WindowScanner< CC >::FindRandomInVonNeumann | ( | const u32 | type, |
SPoint & | outPoint | ||
) | const |
Searches the Von Neumann neighborhood around the center atom of the held EventWindow for an Atom of a specified type, giving its location if found.
type | The type of the Atom to search for. |
outPoint | an output parameter; The SPoint to fill with the coordinates of a randomly chosen atom if one of type type is located. If this method returns 0 , the contents of this SPoint are undefined. |
type
. u32 MFM::WindowScanner< CC >::FindRandomLocationOfType | ( | const u32 | type, |
SPoint & | outPoint | ||
) | const |
Scans the held EventWindow (discluding the center atom) for all atoms of a specified type, filling a point with the location of a single randomly chosen one.
type | The type of the atoms to search for and potentially randomly pick. |
outPoint | An output parameter; The SPoint to fill with the coordinates of a randomly chosen atom if one of the correct type is located. If this method returns 0 , the contents of this SPoint are undefined. |
type
. u32 MFM::WindowScanner< CC >::FindRandomLocationOfType | ( | const u32 | type, |
const u32 | radius, | ||
SPoint & | outPoint | ||
) | const |
Scans a subset of the held EventWindow, up to a specified radius, discluding the center Atom, for all Atoms of a specified type, filling a given point with the location of a single randomly chosen Atom of the specified type.
type | The type of the atoms to search for and potentially randomly pick. |
radius | The maximum radius to search for atoms at. This must be greater than 0 and less than the radius of the held EventWindow, or this will FAIL with ILLEGAL_ARGUMENT . |
outPoint | An output parameter; The SPoint to fill with the coordinates of a randomly chosen atom if one of the correct type is located. If this method returns 0 , the contents of this SPoint are undefined. |
type
. bool MFM::WindowScanner< CC >::IsBorderingMoore | ( | const u32 | type | ) | const |
Scans the moore neighborhood (N, NE, E, SE, S, SW, W, NW) directly surrounding the center atom for an Atom of a specified type.
type | The type of the Atom to search for. |
true
if an Atom of type type
is within the moore neighborhood of the center Atom of the held EventWindow, else false
. bool MFM::WindowScanner< CC >::IsBorderingNeighborhood | ( | const u32 | type, |
const Dir * | neighborhood, | ||
const u32 | dirCount | ||
) | const |
Scans a specified neighborhood consisting of Dirs directly surrounding the center atom for an Atom of a specified type.
type | The type of the Atom to search for. |
neighborhood | An array of Dirs representing the neighborhood around the central Atom. |
dirCount | The number of elements inside the neighborhood array. |
true
if an Atom of type type
is within the specified neighborhood of the center Atom of this EventWindow, else false
.CountInNeighborhood()
>
0
except that it returns more quickly if an Atom is found. bool MFM::WindowScanner< CC >::IsBorderingVonNeumann | ( | const u32 | type | ) | const |
Scans the Von Neumann neighborhood (N, E, S, W) directly surrounding the center atom for an Atom of a specified type.
type | The type of the Atom to search for. |
true
if an Atom of type type
is within the Von Neumann neighborhood of the center Atom of the held EventWindow, else false
.