Worm Farm Model

Posted October 23, 2017 by sircollins88

Hello, 

My students are very excited about the new version of SLNova and are looking forward to creating a virtual worm farm (in conjunction with their science/math/humanities unit). 

One characteristic they would like to include is the ability for a 'worm' to grow in length (similar to the old snake game) after it has 'eaten' some food. Is there an efficient way to create an agent that will behave like this?

Any help would be greatly appreciated. 

Thank you, 

Kevin

Comments

Submitted by sgibbs on Tue, 10/24/2017 - 13:17 · Permalink

Hi Kevin --- thanks for your question.  It is very simple to have any agent increase in size when it "eats" (collides with food).  Just put a block inside the collision code that sets size to size +1 (or whatever decimal you'd like).  If you want to be more sophisticated, create a custom trait for the agent (like "food" or "energy") that increases on collision, and a procedure with a conditional logic block that if the food >= whatever number, the size increases (see the ecosystems rabbits and grass model for an example of this, where the collision increases energy and if the energy is high enough, the rabbit reproduces).  If I can think of a way to have an agent just increase its length, rather than its overall size, I'll let you know.  Happy coding!