aboutsummaryrefslogtreecommitdiff
path: root/include/evolver.h
blob: 26c7d6a418ec9a2b1a3e9826175f8aa7db35c348 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/**
* @file evolver.h
* @author Paul Oliver
*
* This module controls all random events in Salis. At its heart lies a
* XOR-Shift pseudo-random number generator with 128 bits of state. It controls
* cosmic rays and slowly rises simulation entropy.
*/

#ifndef SALIS_EVOLVER_H
#define SALIS_EVOLVER_H

/**
* Get address where the last cosmic ray landed.
* @return Last address changed by a cosmic ray
*/
SALIS_API uint32 sal_evo_get_last_changed_address(void);

/**
* Get amount of random numbers generated during the last simulation cycle.
* @return Number of calls to the random number generator during the last cycle
*/
SALIS_API uint32 sal_evo_get_calls_on_last_cycle(void);

/**
* Access the internal state of the XOR-Shift random number generator.
* @param state_index Index of one of the 32 bit state-blocks [0-4]
* @return State of the 32 bit block
*/
SALIS_API uint32 sal_evo_get_state(uint8 state_index);


/*******************************
* PRIVATES                     *
*******************************/

void _sal_evo_init(void);
void _sal_evo_quit(void);
void _sal_evo_load_from(FILE *file);
void _sal_evo_save_into(FILE *file);
void _sal_evo_randomize_at(uint32 address);
void _sal_evo_cycle(void);

#endif