/
simulations.jl
54 lines (42 loc) · 1.5 KB
/
simulations.jl
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
"""
The basic algorithm where on every step of the iteration
there is a new item applying to the registry that is being
collectively judged by agents during the majority voting
"""
function simSimple(num_of_steps, agents, benchmarks)
registry = []
history = []
for round in 1:num_of_steps
application(registry, history, agents, simpleVote)
end
[b(registry, agents) for b in benchmarks]
end
"""
Apart from voting on a new appliations, a random agent challenges
the item that he consider the worst in the registry
"""
function simChallenge(num_of_steps, agents, benchmarks)
registry = []
history = []
for round in 1:num_of_steps
application(registry, history, agents, simpleVote)
challenge(registry, agents, 0, simpleVote, noneRedistribution)
end
[b(registry, agents) for b in benchmarks]
end
"""
This mode introduces a token as a mean to reward well-performing agents.
During the challenge phase an agent needs to stake some tokens and depending
on the results he can either earn more tokens or loose the initial deposit.
The exact logic for token redistribution is encoded as a parameter passed
to the challenge method.
"""
function simToken(num_of_steps, agents, redistribution, benchmarks)
registry = []
history = []
for round in 1:num_of_steps
application(registry, history, agents, proRataTokenVote)
challenge(registry, agents, 10, proRataTokenVote, redistribution)
end
[b(registry, agents) for b in benchmarks]
end