### Persefone.jl - a model of agricultural landscapes and ecosystems in Europe.
###
### This file holds the code for the Wolpertinger (https://en.wikipedia.org/wiki/Wolpertinger).
### NOT FOR ACTUAL USE! This is of course only a test species ;-)
### Although I dare say the Wolpertinger is probably rather endangered...
###

"""
The wolpertinger is a mysterious beast, found in the hills and alps of Bavaria.
It is purported to have the body of a hare, the wings of a bird, and the antlers
of a deer.
"""
@species Wolpertinger begin
    fecundity = 0.02
    mortality = 0.015
    maxspeed = 5
    crowding = 10
end

"""
Wolpertingers are rather stupid creatures, all they do is move around randomly
and occasionally reproduce by spontaneous parthenogenesis...
"""
@phase Wolpertinger lifephase begin
    for i in 1:@rand(1:self.maxspeed)
        @walk("random")
        #walk!(animal, direction, model; ifempty=false)
    end
    
    if @rand() < self.fecundity && length(@neighbours(100m)) < self.crowding
        @reproduce()
    end

    @kill self.mortality
end

"""
Wolpertingers are mythical creatures that require no special initialisation.
"""
@create Wolpertinger begin
    @debug "$(animalid(self)) created."
    #TODO
end

"""
Population densities of the endangered Wolpertinger are down to 1 animal per km².
"""
@populate Wolpertinger begin
    asexual = true
    initphase = lifephase
    birthphase = lifephase
    indarea = 1km²
end