-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexperiment_02.py
More file actions
68 lines (61 loc) · 2.14 KB
/
experiment_02.py
File metadata and controls
68 lines (61 loc) · 2.14 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
"""
Simulate herbivore population on a new island called "Desert-Low-Island" for 20 years.
Then add carnivore population and simulate for 40 years.
Repeat for several(3) seeds.
"""
__author__ = 'Mahrin Tasfe'
__email__ = 'mahrin.tasfe@nmbu.no'
import textwrap
import matplotlib.pyplot as plt
from biosim.simulation import BioSim
geogr = """\
WWWWWWWWWWWWWWWWW
WLLLLLLLLLLLLLLLW
WLLLLLLLLLLLLLLLW
WLLLLLLLLHHHHLLLW
WLLLLLLLLHHHHLLLW
WLLLLLLHHHHHHLLLW
WWWWWWWWWWWWWWWWW"""
geogr = textwrap.dedent(geogr)
ini_herbs = [{'loc': (2, 2),
'pop': [{'species': 'Herbivore',
'age': 5,
'weight': 20}
for _ in range(30)]},
{'loc': (5, 13),
'pop': [{'species': 'Herbivore',
'age': 2,
'weight': 2}
for _ in range(40)]},
{'loc': (2, 13),
'pop': [{'species': 'Herbivore',
'age': 5,
'weight': 25}
for _ in range(50)]}]
ini_carns = [{'loc': (2, 2),
'pop': [{'species': 'Carnivore',
'age': 10,
'weight': 20}
for _ in range(7)]},
{'loc': (5, 13),
'pop': [{'species': 'Carnivore',
'age': 5,
'weight': 80}
for _ in range(3)]}]
for seed in range(100, 103):
sim = BioSim(geogr, ini_herbs, seed=seed,
img_dir=r'experiment_02_result',
img_base=f'exp02_{seed:05d}',
img_years=4,
hist_specs={'fitness': {'max': 1.0, 'delta': 0.05},
'age': {'max': 50.0, 'delta': 2},
'weight': {'max': 100, 'delta': 2}},
vis_years=4,
log_file="experiment_02_log")
sim.set_animal_parameters('Herbivore', {'gamma': 0.8}) # Making the baby probability high
sim.simulate(20)
sim.add_population(ini_carns)
sim.simulate(40)
sim.make_movie('mp4')
sim.make_movie('gif')
plt.savefig('experiment02.pdf')