#include <Space3D.h>
Inherits srAlmende::Space.

Public Member Functions | |
| Space3D () | |
| virtual | ~Space3D () |
| Space3DUnit * | getSpace3DUnit (Location3D *loc) |
| getSpace3DUnit with a Location3D (+/- radius) | |
| Space3DUnit * | getSpace3DUnit (int x, int y, int z) |
| getSpace3DUnit takes coordinates (+/- radius) and returns units[>0,>0,>0]. | |
| void | Init (int ldim) |
| Initialises the Space3D object, creating for instance Space3DUnits. | |
| void | Tick () |
| Wrapper around all diffusion, normalisation, and decay routines. | |
| void | Generate () |
| Test function that generates a quantity somewhere at random. | |
| void | Diffuse () |
| Diffuses quantities to neighbouring cells. | |
| void | Normalise (bool error) |
| Enforces quantity maximum values of 100. | |
Public Attributes | |
| array3D | units |
| A three-dimensional structure of Space3DUnits. | |
| int | dimension |
| int | radius |
| The radius is half the amount of Space3DUnits on an edge (minus the centre unit). | |
| unsigned char | diffusion_rate |
The space is a 3D grid of cells. Each cell knows reciprocally where it is within the grid. In the 3D multi-agent system the inner core of this 3D grid is populated with sensing and controlling agents. The skin around this core is one layer thick and populated with the sensors, actuators and docking elements of one physical robot.
Definition at line 40 of file Space3D.h.
| srAlmende::Space3D::Space3D | ( | ) |
Each robot will have a virtual 3D world inside, with cells are occupying virtual space. A cell can in this sense be close to a docking unit. The subsequent translation of concentrations of entities in this cell to docking requests or events is trivial. This Space3D object contains a list of Space3DUnit objects.
Definition at line 33 of file Space3D.cpp.
References diffusion_rate.
| srAlmende::Space3D::~Space3D | ( | ) | [virtual] |
The destructor removes the 3D array of Space3DUnits.
Definition at line 43 of file Space3D.cpp.
References units.
| void srAlmende::Space3D::Diffuse | ( | ) |
Diffuses quantities to neighbouring cells.
In the envisioned simulations also decay will be implemented (decreased quantity of product without increase of the quantity somewhere else). It seems that it does not make sense to implement a diffusion engine that preserves conservation of those quantities. And that if the quantity is less than the neighbour count it will be disregarded. However, this would lead to artifacts at the corners, where suddenly products will propagate because the cells have less neighbours! The implementation of the diffusion algorithm does depend on the quantity of the product. For all products the same diffusion rate is implemented.
The chance that a product is going to another cell should be the same all over the 3D structure. This means that the chance of a product ending up in a particular cell is different at a rim or corner.
It is assumed that the diffusion percentage is 12%. A product in a cell with 6 neighbours, goes for 2% to every neighbour, 88% remains in the cell.
Definition at line 150 of file Space3D.cpp.
References diffusion_rate, srAlmende::Space3DUnit::products, and units.
Referenced by Tick().
| void srAlmende::Space3D::Generate | ( | ) |
Test function that generates a quantity somewhere at random.
Generate is a test function that generates gene products in a specific part in the Space3D environment. This should be replaced by a function that actually uses a genome to do so.
Definition at line 123 of file Space3D.cpp.
References dimension, and units.
Referenced by Tick().
| Space3DUnit * srAlmende::Space3D::getSpace3DUnit | ( | int | x, | |
| int | y, | |||
| int | z | |||
| ) |
getSpace3DUnit takes coordinates (+/- radius) and returns units[>0,>0,>0].
Not a trivial function because [x][y][z] in the array are not the same as the coordinates. In contrary the index numbers are from 0 till dimension. While the coordinates are shifted with the radius. So getSpace3DUnit(0,0,0) is a request for the origin, so it becomes units[1,1,1] if the radius is 1 (and the dimension 3).
| x | ||
| y | ||
| z |
Definition at line 96 of file Space3D.cpp.
| Space3DUnit * srAlmende::Space3D::getSpace3DUnit | ( | Location3D * | loc | ) |
getSpace3DUnit with a Location3D (+/- radius)
Get a Space3DUnit using a Location3D object. Most often the routine that takes the separate coordinates will turn out to be more useful.
Definition at line 82 of file Space3D.cpp.
Referenced by srAlmende::Space3DUnit::getNeighbours().
| void srAlmende::Space3D::Init | ( | int | ldim | ) |
Initialises the Space3D object, creating for instance Space3DUnits.
The initialisation of Space3D has to be done before any function is called. The given parameter ldim needs to be greater than zero and odd. The oddness makes it easy to define a symmetrical space around the origin [0,0,0]. Each Space3DUnit is initialised within a Location3D object. The radius lr is: (ldim - 1) / 2. So, Location3D coordinates range from [-lr, -lr, -lr] to [lr, lr, lr].
Definition at line 54 of file Space3D.cpp.
References dimension, radius, and units.
Referenced by srAlmende::RobotSpace3D::Initialize().
| void srAlmende::Space3D::Normalise | ( | bool | error | ) |
Enforces quantity maximum values of 100.
This routine can either be used to normalise or to make sure that a normalisation is indeed not required (because of conservation of mass). Even if a cell contains maximum quantity levels it will diffuse as much products as it gets input.
Product sources should not exceed the maximum quantity of course!
Definition at line 268 of file Space3D.cpp.
References units.
Referenced by Tick().
| void srAlmende::Space3D::Tick | ( | ) |
Wrapper around all diffusion, normalisation, and decay routines.
The Space3D component can get a tick from a simulation engine. Each time it gets a tick it diffuses the Space3DUnit::Product objects through the 3D space.
Definition at line 107 of file Space3D.cpp.
References Diffuse(), Generate(), and Normalise().
Referenced by srAlmende::RobotSpace3D::TickLocal().

| unsigned char srAlmende::Space3D::diffusion_rate |
The dimension is the edge length of the cubic Space3D entity. (multi_array wants signed integer)
Definition at line 50 of file Space3D.h.
Referenced by Generate(), and Init().
1.6.1