Skip to content
Snippets Groups Projects
Select Git revision
  • 5cd61c32a3fb5a1c654d9c398058869d2b6dd385
  • master default protected
  • beta
  • dev
  • andrewssobral-patch-1
  • update
  • thomas-fork
  • 2.0
  • v3.2.0
  • v3.1.0
  • v3.0
  • bgslib_py27_ocv3_win64
  • bgslib_java_2.0.0
  • bgslib_console_2.0.0
  • bgslib_matlab_win64_2.0.0
  • bgslib_qtgui_2.0.0
  • 2.0.0
  • bgs_console_2.0.0
  • bgs_matlab_win64_2.0.0
  • bgs_qtgui_2.0.0
  • v1.9.2_x86_mfc_gui
  • v1.9.2_x64_java_gui
  • v1.9.2_x86_java_gui
23 results

.properties

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    wolpertinger.jl 1.46 KiB
    ### Persephone - a socio-economic-ecological model of European agricultural landscapes.
    ###
    ### 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...
    ###
    
    """
        initwolpertinger!(model)
    
    Initialise a population of Wolpertingers in random locations around the landscape.
    """
    function initwolpertinger!(model::AgentBasedModel)
        species = getspecies("Wolpertinger")
        x, y = size(model.landcover)
        popsize = Int(round((x*y)/10000))
        for i in 1:popsize
            add_agent!(Animal, model, species, hermaphrodite, 0, 100)
        end
        @debug "Hid $(popsize) Wolpertingers for gullible tourists to find."
    end
    
    """
        updatewolpertinger(animal, model)
    
    Wolpertingers are rather stupid creatures, all they do is move around randomly
    and occasionally reproduce by spontaneous parthogenesis...
    """
    function updatewolpertinger!(w::Animal, model::AgentBasedModel)
        # walk in a random direction
        direction = Tuple(rand([-1,1], 2))
        walk!(w, direction, model; ifempty=false)
        w.energy -= rand([1, 10])*5
        # reproduce every once in a blue moon
        if rand() < 0.01
            @debug "Wolpertinger $(w.id) has reproduced."
            add_agent!(w.pos, Animal, model, getspecies("Wolpertinger"), hermaphrodite, 0, 100)
        end
    end
    
    registerspecies(Species("Wolpertinger", initwolpertinger!, updatewolpertinger!))