Skip to content

A world modelling carrots growing, rabbits populations and wolf populations

Notifications You must be signed in to change notification settings

joshcrews/carrot-rabbit-wolf-world

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Carrot, Rabbit, Wolf World in Elixir

Background

I listened to a couple different podcasts where Francesco Cesarini talked about a college programing class covering Erlang where the students were assigned a project to model a world where

  1. Carrots grow on the board
  2. Rabbits travel around the board, eating carrots, and reproducing
  3. Wolves travel around eating rabbits and reproducing

I don't know if this is part of the story, but I also have

  1. Rabbits move towards carrots nearby
  2. Wolves move towards rabbits nearby

What it looks like

Carrot World

How to run

  1. Clone the repo
  2. iex -S mix
  3. CarrotWorldServer.sip

And the world starts printing to the terminal.

Changing the world settings

carrot_patch.ex, rabbit.ex, wolf.ex all have settings you can change like

rabbit.ex

@carrots_in_belly_before_reproduce 1
@day_can_live_without_carrots 10

wolf.ex

@rabbits_in_belly_before_reproduce 5
@day_can_live_without_rabbits 50

carrot_patch.ex

@carrot_growth_points_required 100

Change the board size

Look for start_in_production and you can set the board_size

License

This software is released under the MIT Licence

About

A world modelling carrots growing, rabbits populations and wolf populations

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages