-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflam.bzz
62 lines (51 loc) · 1.27 KB
/
flam.bzz
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
include "vec2.bzz"
include "string.bzz"
include "table.bzz"
include "queue.bzz"
include "includes/move.bzz"
include "includes/constants.bzz"
include "includes/failure.bzz"
include "includes/radiation_sensor.bzz"
include "includes/radiation.bzz"
include "includes/comm.bzz"
include "includes/stigmergy.bzz"
include "includes/voting.bzz"
include "includes/consensus.bzz"
function init() {
current_step = 3
math.rng.setseed(907998 + id)
sources = { .0 = radiation_source.new(9.5, -9.5, 1.0)}
sensor = radiation_sensor.new(sources)
set_leds(0, 255, 0)
init_random_search()
init_comm()
init_stigmergy()
}
# Executed every time step
function step() {
if (current_step >= EXPERIMENT_LENGTH or is_failed()) {
return
}
update_comm()
stage = current_step % FLAM_OBSERVATION_WINDOW
if (stage == 0) {
update_stigmergy()
} else if (stage == 1) {
update_voting()
reset_comm()
} else if (stage == 2) {
update_consensus()
}
# Stop robots when experiment is over
if (current_step == EXPERIMENT_LENGTH) {
log("Experiment terminated")
set_wheels(0.0, 0.0)
set_leds(255, 0, 0)
}
random_search()
current_step = current_step + 1
}
function reset() {
}
function destroy() {
}