Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Persefone.jl
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Persefone
Persefone.jl
Commits
5d3cb400
Commit
5d3cb400
authored
11 months ago
by
xo30xoqa
Browse files
Options
Downloads
Patches
Plain Diff
Wrote Skylark matesearch phase
parent
4e876a09
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/nature/species/skylark.jl
+35
-30
35 additions, 30 deletions
src/nature/species/skylark.jl
with
35 additions
and
30 deletions
src/nature/species/skylark.jl
+
35
−
30
View file @
5d3cb400
...
@@ -52,7 +52,8 @@ At the moment, this implementation is still in development.
...
@@ -52,7 +52,8 @@ At the moment, this implementation is still in development.
const
maxforagecover
=
0.7
# maximum preferred vegetation cover for foraging
const
maxforagecover
=
0.7
# maximum preferred vegetation cover for foraging
const
nestingheight
=
(
15
cm
,
25
cm
)
# min and max preferred vegetation height for nesting
const
nestingheight
=
(
15
cm
,
25
cm
)
# min and max preferred vegetation height for nesting
const
nestingcover
=
(
0.2
,
0.5
)
# min and max preferred vegetation cover for nesting
const
nestingcover
=
(
0.2
,
0.5
)
# min and max preferred vegetation cover for nesting
const
matefaithfulness
=
0.5
# chance of a female retaining her previous partner
const
nestingbegin
::
Tuple
{
Int64
,
Int64
}
=
(
April
,
10
)
# begin nesting in the middle of April
const
nestingbegin
::
Tuple
{
Int64
,
Int64
}
=
(
April
,
10
)
# begin nesting in the middle of April
const
nestbuildingtime
::
UnitRange
{
Int64
}
=
4
:
5
# 4-5 days needed to build a nest (doubled for first nest)
const
nestbuildingtime
::
UnitRange
{
Int64
}
=
4
:
5
# 4-5 days needed to build a nest (doubled for first nest)
const
eggsperclutch
::
UnitRange
{
Int64
}
=
2
:
5
# eggs laid per clutch
const
eggsperclutch
::
UnitRange
{
Int64
}
=
2
:
5
# eggs laid per clutch
...
@@ -85,16 +86,13 @@ Non-breeding adults move around with other individuals and check for migration.
...
@@ -85,16 +86,13 @@ Non-breeding adults move around with other individuals and check for migration.
@follow
(
@rand
(
neighbours
),
30
m
)
#XXX magic number
@follow
(
@rand
(
neighbours
),
30
m
)
#XXX magic number
# check if the bird migrates
# check if the bird migrates
leave
,
arrive
=
self
.
migrationdates
leave
,
arrive
=
self
.
migrationdates
month
,
day
=
monthday
(
model
.
date
)
if
leave
<=
model
.
date
<
arrive
migrate
=
(((
month
<
arrive
[
1
])
||
(
month
==
arrive
[
1
]
&&
day
<
arrive
[
2
]))
||
((
month
>
leave
[
1
])
||
(
month
==
leave
[
1
]
&&
day
>=
leave
[
2
])))
if
migrate
@kill
(
self
.
migrationmortality
,
"migration"
)
@kill
(
self
.
migrationmortality
,
"migration"
)
returndate
=
Date
(
year
(
model
.
date
)
+
1
,
arrive
[
1
],
arrive
[
2
])
self
.
sex
==
male
?
self
.
sex
==
male
?
@setphase
(
territorysearch
)
:
@setphase
(
territorysearch
)
:
@setphase
(
matesearch
)
@setphase
(
matesearch
)
@migrate
(
returndate
)
@migrate
(
arrive
)
self
.
migrationdates
=
self
.
migrationdates
.+
Year
(
1
)
end
end
end
end
...
@@ -136,22 +134,35 @@ end
...
@@ -136,22 +134,35 @@ end
Females returning from migration move around to look for a suitable partner with a territory.
Females returning from migration move around to look for a suitable partner with a territory.
"""
"""
@phase
Skylark
matesearch
begin
@phase
Skylark
matesearch
begin
#TODO move around, looking for a male with an established territory
if
self
.
mate
!=
-
1
# if the female already had a partner last year...
#TODO teilweise Partnertreue
if
isalive
(
@animal
(
self
.
mate
))
if
@chance
(
self
.
matefaithfulness
)
# ...check if he is still alive and the female wants to stay with him
#XXX is mate-faithfulness decided by the female when she returns,
# or by the male taking whichever female comes to him first?
@debug
"
$
(animalid(self)) and
$
(animalid(n)) have mated again."
@setphase
(
nesting
)
return
else
self
.
mate
=
-
1
@animal
(
self
.
mate
)
.
mate
=
-
1
end
else
self
.
mate
=
-
1
end
end
# look for a mate among the neighbouring birds, or move randomly
# look for a mate among the neighbouring birds, or move randomly
for
n
in
@neighbours
(
self
.
visionrange
)
for
n
in
@neighbours
(
self
.
visionrange
)
if
n
.
sex
==
male
&&
n
.
mate
==
-
1
&&
n
.
phase
==
occupation
if
n
.
sex
==
male
&&
n
.
mate
==
-
1
&&
n
.
phase
==
occupation
self
.
mate
=
n
.
id
self
.
mate
=
n
.
id
#XXX may be the old partner again by chance
n
.
mate
=
self
.
id
n
.
mate
=
self
.
id
@setphase
(
nesting
)
@debug
"
$
(animalid(self)) and
$
(animalid(n)) have mated."
@debug
"
$
(animalid(self)) and
$
(animalid(n)) have mated."
b
re
ak
re
turn
end
end
end
end
#@debug("$(animalid(self)) didn't find a mate.")
#@debug("$(animalid(self)) didn't find a mate.")
if
self
.
mate
!=
-
1
if
month
(
model
.
date
)
>
self
.
nestingend
# stop trying to find a mate if it's too late
@setphase
(
nesting
)
elseif
month
(
model
.
date
)
>
self
.
nestingend
# stop trying to find a mate if it's too late
@setphase
(
nonbreeding
)
@setphase
(
nonbreeding
)
else
else
@walk
(
"random"
,
self
.
movementrange
)
@walk
(
"random"
,
self
.
movementrange
)
...
@@ -225,8 +236,8 @@ function migrationdates(skylark::Skylark, model::SimulationModel)
...
@@ -225,8 +236,8 @@ function migrationdates(skylark::Skylark, model::SimulationModel)
minarrive
=
skylark
.
sex
==
male
?
(
February
,
15
)
:
(
March
,
1
)
minarrive
=
skylark
.
sex
==
male
?
(
February
,
15
)
:
(
March
,
1
)
deltaleave
=
@rand
(
0
:
45
)
#XXX ought to be normally distributed
deltaleave
=
@rand
(
0
:
45
)
#XXX ought to be normally distributed
deltaarrive
=
@rand
(
0
:
15
)
#XXX ought to be normally distributed
deltaarrive
=
@rand
(
0
:
15
)
#XXX ought to be normally distributed
leave
=
monthday
(
Date
(
2001
,
minleave
[
1
],
minleave
[
2
])
+
Day
(
deltaleave
))
leave
=
Date
(
year
(
model
.
date
)
,
minleave
[
1
],
minleave
[
2
])
+
Day
(
deltaleave
))
arrive
=
monthday
(
Date
(
200
1
,
minarrive
[
1
],
minarrive
[
2
])
+
Day
(
deltaarrive
))
arrive
=
Date
(
year
(
model
.
date
)
+
1
,
minarrive
[
1
],
minarrive
[
2
])
+
Day
(
deltaarrive
))
(
leave
,
arrive
)
(
leave
,
arrive
)
end
end
...
@@ -266,13 +277,11 @@ function findterritory(skylark::Skylark, model::SimulationModel)
...
@@ -266,13 +277,11 @@ function findterritory(skylark::Skylark, model::SimulationModel)
for
c
in
coords
# ...then inspect them
for
c
in
coords
# ...then inspect them
(
c
[
1
]
<=
0
||
c
[
2
]
<=
0
||
c
[
1
]
>
msize
[
1
]
||
c
[
2
]
>
msize
[
2
])
&&
continue
(
c
[
1
]
<=
0
||
c
[
2
]
<=
0
||
c
[
1
]
>
msize
[
1
]
||
c
[
2
]
>
msize
[
2
])
&&
continue
(
isoccupied
(
model
,
"Skylark"
,
c
))
&&
continue
(
isoccupied
(
model
,
"Skylark"
,
c
))
&&
continue
push!
(
territory
,
c
)
quality
=
foragequality
(
skylark
,
model
,
c
)
quality
=
foragequality
(
skylark
,
model
,
c
)
effectivesize
+=
@param
(
world
.
mapresolution
)
^
2
*
quality
(
quality
>
0
)
&&
(
constrained
=
false
)
#XXX check for nesting habitats?
#XXX check for nesting habitats?
if
quality
>
0
constrained
=
false
push!
(
territory
,
c
)
effectivesize
+=
@param
(
world
.
mapresolution
)
^
2
*
quality
end
end
end
radius
+=
1
radius
+=
1
end
end
...
@@ -329,18 +338,14 @@ should currently be on migration. Also sets other individual-specific variables.
...
@@ -329,18 +338,14 @@ should currently be on migration. Also sets other individual-specific variables.
"""
"""
@create
Skylark
begin
@create
Skylark
begin
@debug
"Added
$
(animalid(self)) at
$
(self.pos)"
@debug
"Added
$
(animalid(self)) at
$
(self.pos)"
self
.
migrationdates
=
migrationdates
(
self
,
model
)
#XXX should be dynamic
self
.
migrationdates
=
migrationdates
(
self
,
model
)
.-
Year
(
1
)
#XXX should be dynamic
leave
,
arrive
=
self
.
migrationdates
leave
,
arrive
=
self
.
migrationdates
mon
,
day
=
monthday
(
model
.
date
)
if
leave
<=
model
.
date
<
arrive
migrate
=
(((
mon
<
arrive
[
1
])
||
(
mon
==
arrive
[
1
]
&&
day
<
arrive
[
2
]))
||
((
mon
>
leave
[
1
])
||
(
mon
==
leave
[
1
]
&&
day
>=
leave
[
2
])))
if
migrate
returndate
=
Date
(
year
(
model
.
date
),
arrive
[
1
],
arrive
[
2
])
model
.
date
!=
@param
(
core
.
startdate
)
&&
(
returndate
+=
Year
(
1
))
self
.
sex
==
male
?
self
.
sex
==
male
?
@setphase
(
territorysearch
)
:
@setphase
(
territorysearch
)
:
@setphase
(
matesearch
)
@setphase
(
matesearch
)
@migrate
(
returndate
)
@migrate
(
arrive
)
self
.
migrationdates
=
self
.
migrationdates
.+
Year
(
1
))
end
end
end
end
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment