-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexperiment_01.py
More file actions
86 lines (78 loc) · 2.73 KB
/
experiment_01.py
File metadata and controls
86 lines (78 loc) · 2.73 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
"""
Simulate herbivore(500) population for 40 years, then add carnivore(50) population
and simulate for 60 years. After the simulation, a mp4 movie, gif and a pdf
are created for showing the simulation results.
Repeat for several seeds.
"""
__author__ = 'Mahrin Tasfe'
__email__ = 'mahrin.tasfe@nmbu.no'
import textwrap
import matplotlib.pyplot as plt
from biosim.simulation import BioSim
geogr = """\
WWWWWWWWWWW
WLHLLDDDDDW
WLHLLDDDDDW
WLHLLDDDDDW
WLHLLDDDDDW
WWWWWWWWWWW"""
geogr = textwrap.dedent(geogr)
ini_herbs = [{'loc': (2, 2),
'pop': [{'species': 'Herbivore',
'age': 2,
'weight': 40}
for _ in range(100)]},
{'loc': (2, 3),
'pop': [{'species': 'Herbivore',
'age': 2,
'weight': 200}
for _ in range(150)]},
{'loc': (3, 3),
'pop': [{'species': 'Herbivore',
'age': 5,
'weight': 50}
for _ in range(100)]},
{'loc': (4, 7),
'pop': [{'species': 'Herbivore',
'age': 5,
'weight': 50}
for _ in range(150)]}
]
ini_carns = [{'loc': (2, 2),
'pop': [{'species': 'Carnivore',
'age': 3,
'weight': 50}
for _ in range(10)]},
{'loc': (2, 3),
'pop': [{'species': 'Carnivore',
'age': 5,
'weight': 80}
for _ in range(10)]},
{'loc': (4, 7),
'pop': [{'species': 'Carnivore',
'age': 2,
'weight': 50}
for _ in range(10)]},
{'loc': (3, 3),
'pop': [{'species': 'Herbivore',
'age': 5,
'weight': 80}
for _ in range(20)]},
]
for seed in range(100, 101):
sim = BioSim(geogr, ini_herbs, seed=seed,
img_dir=r'experiment_01_result',
img_base=f'exp01_{seed:05d}',
img_years=5,
hist_specs={'fitness': {'max': 1.0, 'delta': 0.05},
'age': {'max': 75.0, 'delta': 2},
'weight': {'max': 100, 'delta': 2}},
vis_years=5,
log_file="experiment_01_log")
sim.simulate(40)
sim.add_population(ini_carns)
sim.simulate(30)
sim.simulate(30)
sim.make_movie('mp4')
sim.make_movie('gif')
plt.savefig('experiment01.pdf')