Tools (xentica.tools)¶
The package with different tools serving as helpers in other modules.
-
xentica.tools.
xmath
¶ alias of
xentica.tools.xmath.Xmath
Color Manipulation Functions (xentica.tools.color)¶
The collection of color conversion helpers.
-
class
xentica.tools.color.
GenomeColor
¶ Bases:
object
Different approaches for rendering the genome’s color.
-
static
modular
(genome, divider)¶ Convert genome bit value to RGB color using modular division.
This algorithm simply divides the genome value by some modulo, normalize it and use as a hue with maximum saturation/value.
As a result, you could check by eye how genomes behave inside each group, since similar genomes most likely will have distinctive colors.
Parameters: - genome – Genome as integer (bit) sequence.
- divider – Divider for the modular division.
Returns: tuple (red, green, blue)
-
static
positional
(genome, num_genes)¶ Convert genome bit value to RGB color using ones’ positions.
This algorithm treats positions of ‘1’ in binary genome representation as a hue with maximum saturation/value (as in HSV model), then blends them together to produce the final RGB color. Genome length (second argument) is essential to calculate genes’ positions in [0, 1] range.
As a result, two genomes will look similar visually if they have a little difference in genes. That could help in the quick detection of genome groups by eye.
Parameters: - genome – Genome as integer (bit) sequence.
- num_genes – Genome length in bits.
Returns: tuple (red, green, blue)
-
static
-
xentica.tools.color.
hsv2rgb
(hue, saturation, value)¶ Convert HSV color to RGB format.
Parameters: - hue – Hue value [0, 1]
- saturation – Saturation value [0, 1]
- value – Brightness value [0, 1]
Returns: tuple (red, green, blue)
Genetics Functions (xentica.tools.genetics)¶
The collection of functions for genetics manipulations.
-
xentica.tools.genetics.
genome_crossover
(state, num_genes, *genomes, max_genes=None, mutation_prob=0, rng_name='rng')¶ Crossover given genomes in stochastic way.
Parameters: - state – A container holding model’s properties.
- num_genes – Genome length, assuming all genomes has the same number of genes.
- genomes – A list of genomes (integers) to crossover
- max_genes – Upper limit for ‘1’ genes in the resulting genome.
- mutation_prob – Probability of a single gene’s mutation.
- rng_name – Name of
RandomProperty
.
Returns: Single integer, a resulting genome.
CA Rules Functions (xentica.tools.rules)¶
The module with different helpers for CA rules.
-
class
xentica.tools.rules.
LifeLike
¶ Bases:
object
Life-like rules helpers.
-
static
golly2int
(golly_str)¶ Convert a string in the Golly format to inner rule representation.
Parameters: golly_str – Rule in the Golly format (e.g. B3/S23) Returns: Integer representation of the rule for inner use.
-
static
int2golly
(rule)¶ Convert inner rule representation to string in the Golly format.
Parameters: rule – Integer representation of the rule. Returns: Golly-formatted rule (e.g. B3/S23).
-
static
Math Functions (xentica.tools.xmath)¶
The module with bindings to CUDA math functions.
-
class
xentica.tools.xmath.
Xmath
¶ Bases:
object
Static class holding all math functions.
-
static
float
(val)¶ Cast a value to float.
-
static
int
(val)¶ Cast a value to int.
-
static
max
(*args)¶ Calculate the maximum over list of args.
-
static
min
(*args)¶ Calculate the minimum over list of args.
-
static
popc
(val)¶ Count the number of bits that are set to ‘1’ in a 32 bit integer.
-
static