The std://grids module is for supporting problems where elements are placed on a rectangular bounded grid.
If your problem uses this module, you will want to add to the problem a config setting called grid_size which is a list with 2 numbers containing the grid with and height. Most functions in this module use that information in their computations. You can also pass an explicit grid_size to the function (if the size is dynamic, or if there is more than 1 grid)
This module does not export procedures
The most important type defined in this module is
type Point(x: Number, y: Number)
which represents bidimensional coordinates, with the x axis going from west to east, and the y axis going from north to south. So Point(0,0) is typically the northwest corner of the grid.
In addition to this, the module documentations sometimes refers to Spatial which is not a type (the name is not actually in the module code), but a set of types following one of these conventions:
In the definition belows, any time that a Spatial type is specified, actually we are referring to any type satisfying the conditions above. The “position” of a spatial object s is
The grids module provides the following functions
Details for each function can be found below
Type: cells(): Number Type: cells(grid_size: [Number]): Number
Returns the number of cells of the grid (width × height). It uses the grid size specified in the configuration unless explicitly specified. If provided, the grid size must have 2 elements.
Type: find(items: [Spatial], position: Spatial): Boolean
Returns True if any of the given items is at the given position, False otherwise.
Type: has_row(items: [Spatial], count: Number): Boolean
Returns True if there are count items with their positions aligned in a row inside items. Aligned in a row means that they form a horizontal, vertical, or diagonal line, with no interposed positions.
The count argument must be a non-negative integer.
Type: in_bounds(point: Spatial): Boolean Type: in_bounds(point: Spatial, grid_size: [Number]): Boolean
Returns True if the given point is inside the bounds of the grid. It uses the grid size specified in the configuration unless another size is explicitly specified.
This module provides a random number generator and tools to add random noise to values. It does not provide types.
The random seed is intialized from system noise, unless explicitly set by setting a value to the random_seed configuration variable.