I blogged about my first real attempt at programming something in Julia. I’d love to hear your thoughts.
This is awesome! Can you put this on github somewhere?
One thing you could try doing with this is to have two structs:
mutable struct Hawk health::Int end mutable struct Dove health::Int end
and then implement the various interactions using multiple dispatch instead of having a big if/else statement. This would allow you to add a third type of bird without having to change the code of
Also, I wonder this could be turned into a proper agent-based model with @kris-brown’s stuff.
ok, I put it on GitHub:
I like the multiple dispatch idea. I’ll do that today.
Can you point me to the agent-based stuff you’re talking about?
Ok, I just did your multiple dispatch idea.
Neat! Two more trivial pieces of feedback.
- It’s good practice to include types of function arguments, even if you don’t technically need to, for documentation’s sake.
- Generally, functions are lowercase: see the Julia style guide for more details.