Skip to content
Snippets Groups Projects
Commit 29b34c93 authored by xo30xoqa's avatar xo30xoqa
Browse files

Fixed the Wyvern test species

parent 61cf5aa6
No related branches found
No related tags found
No related merge requests found
...@@ -35,7 +35,7 @@ and occasionally reproduce by spontaneous parthenogenesis... ...@@ -35,7 +35,7 @@ and occasionally reproduce by spontaneous parthenogenesis...
end end
""" """
Wolpertingers are ephemeral creatures that require no special initialisation. Wolpertingers are mythical creatures that require no special initialisation.
""" """
@create Wolpertinger begin @create Wolpertinger begin
@debug "$(animalid(self)) created." @debug "$(animalid(self)) created."
......
...@@ -10,71 +10,80 @@ Beware the wyvern! This evolutionary cousin of the dragon may only have two ...@@ -10,71 +10,80 @@ Beware the wyvern! This evolutionary cousin of the dragon may only have two
legs, but that doesn't make it any less dangerous... legs, but that doesn't make it any less dangerous...
""" """
@species Wyvern begin @species Wyvern begin
popsize = 10
fecundity = 0.02 fecundity = 0.02
maxage = 365 maxage = 365
speed = 20 speed = 20
vision = 50 vision = 50
aggression = 0.2 aggression = 0.2
huntsuccess = 0.8 huntsuccess = 0.8
end
@initialise(winter, """
habitat=@habitat(@landcover() in (grass, soil, agriculture, builtup)), Wyverns are mythical creatures that require no special initialisation.
popsize=popsize) """
@create Wyvern begin
@debug "$(animalid(self)) created."
end end
""" """
Wyverns are ferocious hunters, scouring the landscape for their favourite Wyverns are ferocious hunters, scouring the landscape for their favourite
prey: wolpertingers... prey: wolpertingers...
""" """
@phase Wyvern.summer begin @phase Wyvern summer begin
for a in @neighbours(self.speed) for a in @neighbours(self.speed, false)
# check if a wolpertinger is in pouncing distance # check if a wolpertinger is in pouncing distance
if typeof(a) == Wolpertinger if typeof(a) == Wolpertinger
move_agent!(self, a.pos, model) @move(a.pos)
if @rand() < self.huntsuccess if @rand() < self.huntsuccess
@debug "$(animalid(self)) killed $(animalid(a))." @debug "$(animalid(self)) killed $(animalid(a))."
kill!(a, model) @killother(a, 1.0, "predation")
@goto reproduce @goto reproduce
else
@debug "$(animalid(self)) failed to kill $(animalid(a))."
end end
elseif typeof(a) == Wyvern && @rand() < self.aggression elseif typeof(a) == Wyvern && @rand() < self.aggression
# wyverns also fight against each other if they get too close # wyverns also fight against each other if they get too close
move_agent!(self, a.pos, model) @move(a.pos)
outcome = @rand() outcome = @rand()
if outcome < 0.4 if outcome < 0.4
@debug "$(animalid(self)) killed $(animalid(a)) in a fight." @debug "$(animalid(self)) killed $(animalid(a)) in a fight."
kill_agent!(a, model) @killother(a, 1.0, "fighting")
elseif outcome < 0.8 elseif outcome < 0.8
@kill 1.0 "wounds sustained in a fight" @kill(1.0, "wounds sustained in a fight")
end end
@goto reproduce @goto reproduce
end end
end end
# check if a wolpertinger is in seeing distance, or walk in a random direction # check if a wolpertinger is in seeing distance, or walk in a random direction
direction = Tuple(@rand([-1,1], 2)) direction = @randomdirection(self.speed)
for a in @neighbours(self.vision) for a in @neighbours(self.vision)
if typeof(a) == Wolpertinger if typeof(a) == Wolpertinger
direction = get_direction(self.pos, a.pos, model) direction = @directionto(a)
break break
end end
end
for i in 1:self.speed
walk!(animal, direction, model; ifempty=false)
end end
@walk(direction, self.speed)
# reproduce every once in a blue moon # reproduce every once in a blue moon
@label reproduce @label reproduce
(@rand() < self.fecundity) && @reproduce(-1) (@rand() < self.fecundity) && @reproduce()
# hibernate from November to March # hibernate from November to March
month(model.date) >= 11 && (@setphase(winter)) month(model.date) >= 11 && (@setphase(winter))
(self.age == maxage) && @kill(1.0, "old age") (self.age == self.maxage) && @kill(1.0, "old age")
end end
""" """
Fortunately, wyverns hibernate in winter. Fortunately, wyverns hibernate in winter.
""" """
@phase Wyvern.winter begin @phase Wyvern winter begin
# hibernate from November to March # hibernate from November to March
if month(model.date) >= 3 if month(model.date) >= 3
@setphase(summer) @setphase(summer)
end end
end end
@populate Wyvern begin
asexual = true
popsize = 20
phase = winter
habitat = @habitat(@landcover() in (grass, soil, agriculture, builtup))
end
...@@ -30,7 +30,7 @@ weatherfile = "data/regions/jena-small/weather.csv" # location of the weather da ...@@ -30,7 +30,7 @@ weatherfile = "data/regions/jena-small/weather.csv" # location of the weather da
farmmodel = "FieldManager" # which version of the farm model to use (not yet implemented) farmmodel = "FieldManager" # which version of the farm model to use (not yet implemented)
[nature] [nature]
targetspecies = ["Wolpertinger"]#, "Wyvern"]#["Skylark"] # list of target species to simulate targetspecies = ["Wolpertinger", "Wyvern"]#["Skylark"] # list of target species to simulate
popoutfreq = "daily" # output frequency population-level data, daily/monthly/yearly/end/never popoutfreq = "daily" # output frequency population-level data, daily/monthly/yearly/end/never
indoutfreq = "end" # output frequency individual-level data, daily/monthly/yearly/end/never indoutfreq = "end" # output frequency individual-level data, daily/monthly/yearly/end/never
insectmodel = ["season", "habitat", "pesticides", "weather"] # factors affecting insect growth insectmodel = ["season", "habitat", "pesticides", "weather"] # factors affecting insect growth
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment