05 Programming thoughts to eat each other and be eaten in StarLogo TNG
As thoughts move around spaces they sometimes collide.
It is useful to be able to program them to change in some way when they do this.
This guide shows how to change thoughts when they collide in StarLogo TNG.
You can use this to make thoughts eat and be eaten by one another, by killing them and making them grow.
When two thoughts collide you can change any of their traits, e.g. size, altitude, shape, heading etc..
Before you start this you should have a look at..
Getting Started with StarLogo TNG
Setting up a Room of Flunstellas with StarLogo TNG
Programming Thoughts to Wander using StarLogo TNG
In the Blocks Window
– Start a new project bringing in at least 2 different breeds of Flunstellas.
See Setting up a Room of Flunstellas with StarLogo TNG to find out how to import 3D Flunstella models.
– Drag out a red ‘Setup’ block from the ‘Setup and Run’ drawer and place it on the Setup page of the Canvas.
– Drag out a red ‘Clear All’ block from the ‘SetUp and Run’ drawer and place it inside the ‘Setup’ block.
– At the top of the Blocks Factory, click on the blue ‘My Blocks’ arrow, to open the ‘My Blocks’ drawers.
– Open the drawers for each of the Flunstellas breeds you have created and drag out a red ‘Setup Do’ block for each breed.
– Drag out a ‘Scatter Breed’ block out for each breed and place them inside the ‘SetUp’ block, underneath the ‘Clear All’ block.
– At the top of the ‘My Blocks’ drawers click on the blue ‘Factory’ arrow to return to the ‘Blocks Factory’.
– Set the size of the Flunstellas to a random size by dragging out a blue ‘Set Size’ block from the Traits drawer and connecting it to the Do hook of each Create Do block. Then drag out a blue Random block from the ‘Maths’ drawer and drag it into the number block of the ‘Size’ block. Change the number block of the ‘Random’ blocks.
– Set the Altitude by dragging out blue ‘Altitude’ blocks and placing them inside the Do hook of each breeds ‘Create Do’ block. Set both breeds to have the same altitude.
In the SpaceLand window
-Click on the Setup blocks at the bottom of the SpaceLand window, you should see Flunstellas of different sizes scattered around SpaceLand.
Program the thoughts to move
In the Blocks Window
– Drag out a red ‘Forever’ block and place it on the Runtime page of the Canvas.
– Create a movement program for each breed.
– This example shows the ‘Red and Black’ moving forwards in a straight line and the ‘Creative Idea’ wandering randomly. For more on programming how to program random wandering behaviours see this guide.
– Open the My Blocks drawer again by clicking on the blue ‘My Blocks’ arrow at the top of the ‘Blocks Factory’.
Program the thoughts to change when they collide
– Open the ‘Collisions’ drawer, drag out the grey ‘Collision’ block that features both of your Flunstella breeds and place it in the Collisions page of the Canvas.
– Drag an orange ‘Die’ block from the Logic drawer and place it in the hook of one of the breeds in the collision block to make agents of that breed die (or disappear) if they come into contact with agents of the other breed.
– You can change any trait that can be found in the trait drawer, size, shape, breed, altitude, transparency etc. To make the Flunstella grow, drag a blue ‘Set Size’ from the trait drawer and place it in the hook of the Flunstella that you want to grow. Drag out a blue ‘+’ block from the ‘Maths’ drawer and place a ‘Size’ block and a number block of the amount that you want it to grow.
– Set a thought to change shape when it collides with another, by dragging out a blue ‘Set shape’ block from the traits drawer and a ‘Shape’ block from the shapes drawer.
– Set a thought to make a noise when it collides with another by dragging out a green ‘Play Sound’ block and placing it in that breeds hook in the ‘Collision’ block.
Experiment by changing different traits as different thoughts collide with each other.
One thought on “05 Programming thoughts to eat each other and be eaten in StarLogo TNG”
Pingback: » Programming thoughts to follow or avoid each other in StarLogo TNGMaking Flunstellas
Comments are closed.