Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
wolpertinger.jl 1.25 KiB
### 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
    popsize = Int(round(1/100000*reduce(*, size(model.landscape))))
    fecundity = 0.02
    mortality = 0.015
    maxspeed = 5
    crowding = maxspeed*2

    initialise! = initrandompopulation(popsize)

    """
    Wolpertingers are rather stupid creatures, all they do is move around randomly
    and occasionally reproduce by spontaneous parthogenesis...
    """
    @phase lifephase begin
        direction = Tuple(@rand([-1,1], 2))
        for i in 1:@rand(1:@trait(maxspeed))
            walk!(animal, direction, model; ifempty=false)
        end

        if @rand() < @trait(fecundity) &&
            @countanimals(species="Wolpertinger") < @trait(crowding)
            @reproduce(-1)
        end

        @kill @trait(mortality)
    end
end