Before you start:
Create a folder in your ICT folder called ‘Games’
Open Programming / Star Logo / NEW
Save As ‘Mario’ in your Games folder
Change the Turtle into a Mario
Click edit breeds
Select the people menu
Select Mario
Rename Mario
Create a setup procedure:

Create a movement procedure in a Forever block:

Complete the procedure so that Mario can move forward, back, left and right. How many degrees should Mario turn left or right?
The next steps
Rename the procedure from forever to movement
Create a new breed called Luigi
In the setup procedure add and scatter a Luigi
Under the Luigi tab of the Movement procedure create instructions to control the movement of Luigi
Hint: You will have to use the ‘a’, ‘s’, ‘d’, and ‘e’ keys instead of ‘up’, ‘down’, ‘left’ and ‘right’.
Extensions
Easy: Alter the terrain to create a more interesting landscape;
a racetrack?
Medium: Change the speed and turning properties so each character is different
Hard: Make the characters jump
The aim this time is to create weapons for Mario and Luigi that are executed by new keys.
The statements to produce the balls is tacked onto the end of the existing code block:
Adding a Fire Button
Add a new if..test..then block after the keyboard right arrow if block. Test a new key press e.g. space: this will be the Fire button.
New Breed
The new if block will ‘hatch’ a new breed called ‘ball’ which is a simple sphere. Note that you can change the colour of simple shapes like the sphere. Accept the default green for now.
Hatch
When the new key is pressed the Hatch procedure will be triggered – this produces a new copy of the specified breed. Hatch is in the Logic section of the Factory.
In the Hatch do section you will need to move the character 2 steps forward and then breed a new ball. To do this you will need a Set Breed block and a Breed. The Set Breed block is under Traits while the required breed block is in My Blocks under the breed specified (ball). Finally add a set size block with a value appropriate to the game (experiment).
Luigi
Repeat the hatch code you have created for Luigi (if, key press, hatch, set breed, breed).
Finally, you will need to add a single instruction to the ball section of the Movement block. What does the ball do when released?
Extensions
Change the colour of the balls produced by Luigi so you can tell them apart from those of Mario.
Experiment with different sizes of ball.
We now need to add routines to determine what happens when collisions take place between the three characters (Mario, Luigi, balls).
Three collisions are possible: Ball/Mario, Ball/Luigi, Mario/Luigi (we ignore ball/ball, though we could add something later).
The collision blocks can be found in My Blocks under each character.
Mario-Luigi
When Mario and Luigi collide you could make them retreat 10 steps and make a suitable sound. To do something 10 times use a Repeat block.
Ball-Mario and Ball-Luigi
When a ball collides with either character they should die.
Mario-Ball and Luigi-Ball
The collisions between Mario, Luigi and balls are simple: the characters die. The balls can die too.
Further Activities
Most of the balls don’t die, they just hang around and clutter up the playing area. Can you think of a way to make them go away?
Add new characters to interact with the existing objects in the game. How many players can you fit in?
Monitor the effectiveness of the ball killing routine by counting them. Add a line chart and set it to count the number of balls in the game.
See here.
Factory: Setup block
Setup & Run: Clear Everyone.
MyBlocks/Turtle: Create Turtles (500).
Set Color (green).
MyBlocks/Turtle: Scatter Everyone
Make sure breed is set to sphere.
Setup & Run: Run Once block. Call it 'infect'.
Add an if/then block from Logic.
Set the test under if (from Math) to Random (100) <= 10.
Set the result (then) to Set Color red (from Traits).
New Setup & Run block. Change name to 'Run'.
Add forward, left and right from Movement. Set forward to 1 step. Set the turns to random 10.
MyBlocks/Turtles: drag out collision block for Turtles/Turtles (we only have one breed on the board).
Add an if/then block to the first part of the collision block. Set the 'if' part to color of collidee = red. Set the 'then' part to set color red.
Repeat this for the second part of the Turtles collision block.
Add a slider from Setup and Run.
Add a shared number (variable) from the Variables area. Call it 'recovery'. Drag it into the slider. In Spaceland click on the number in the bottom right corner of the slider and set it to 100 so it can be a percentage value.
In the Turtles section of the canvas add a procedure block from Procedures. Call it recover.
Add an if/then block to the procedure. Set the test to random 100 <= recovery (the variable created above).
For the 'then' part add set color green from Traits.
MyBlocks/Turtles: add a copy of the recover procedure block to the Run block (under the left block).
Drag an Agent Boolean variable from Variables onto the Turtles area of the canvas. Call it 'immune'.
MyBlocks/Turtles: new blocks available.
Move to Setup area. Under Create Turtles add an if/else block (under set color green). Set the test to random 100 <= 10.
Set the 'then' part to Set immune true (from MyBlocks/Turtles and Logic).
Set the 'else' part to Set immune false (from MyBlocks/Turtles and Logic).
In the Turtles area add a new procedure block and call it 'check for immunity'.
Add an if/then block. Set the test to turtles immune (from MyBlocks/Turtles) = false (from Logic).
Set the Then part to set color red.
In the Collisions area change the set color red blocks to check for immunity (procedure calls).
Setup area: drag a Monitor block from Setup & Run. Rename it infections.
From MyBlocks/Turtles drag out a Count Turtles With block and slot it into the Monitor.
Add condition color = red to the Count Turtle With block.
From Setup & Run drag out a line graph.
Add 'count turtles with color = red' and 'count turtles with color = green'.
Now a line graph will show changes in the populations of healthy and infected turtles.
How realistic is the model? What happens in real infections? How do infection rates vary between, say, influenza, measles and Ebola?
In this first program we shall create a model of infection where one 'breed' infects another.
Star Logo includes a large number of pre-defined characters which can be chosen to populate a game or simulation.
Choose Edit Breeds to see what creatures you can create. For this simulation we could choose any two breeds, for example a ninja turtle and Homer Simpson. We will use Turtles and Penguins.

The basic breed is 'Turtles'. Be aware that simple shapes can change their colour but the more complex characters cannot.
Click on 'My Blocks' and you will see a Turtles section. Create a new breed such as 'Penguin' and you will also see a Penguins section:

These areas include the program blocks you need to add penguins to 'SpaceLand', the place where your breeds come to life.
Add the code block shown above to the Setup part of the program area. Extend it to include a new breed such as 'Penguin'. Set the number of turtles and penguins to 50.
To make your creatures move around go to the Factory area and drag a Forever block onto the Turtle part of the program area. Rename the block 'movement'. Build a code block from the 'movement' section to make the turtles move forward, turn left and turn right. Use a Random block from the 'Math' section to introduce random values into the left and right movements (remember your lessons in classic Logo?). A reasonable value for the Random function is 10.
The Movement block should include a turtles section and a penguins section. When you add a new breed its name will appear in the Forever/Movement block so you can add the code to control it. Add similar movements to the second breed.
Now switch to SpaceLand, click on Setup to create the turtles and penguins and then click on Forever to make them move around. Click Forever again to make them stop.
So far so good. What if they run into each other?
Drag a Collision block from the Turtles area of My Blocks. Drag an if..then block from the Logic part of The Factory and complete the first part with an = block from Math, a 'Breed of' and a Collidee from Other Agents and a breed from My Blocks/Penguins.
Complete the Penguin part of the Collision block as shown below.

Now run the model again and observe what happens. You will see that the action in the if..then block is 'Die'.
We would like to count the number of penguins left in the world. To do this add a global number by dragging a block from the Variables area; rename it 'penguins'. Now place a Monitor block from the Setup area and set it up to count the number of penguins remaining. Drag a division block from Math. Drag a Count Everyone With block from Setup and Run and an = block from Maths. Drag a Breed:Turtles block from My Blocks Turtles and complete the monitor with a count everyone block as the divisor.
The monitor divides the number of turtles by the count of everyone. To begin with this is 50/100 as we set up 50 of each type of breed. As the penguins die the calculation becomes 40/90, 30/80 and eventuall 1/51 and 0/50.
Drag a Line Graph block from the Setup area and set it to display the number of turtles and penguins - drag the count of blocks from the respective areas in My Blocks.

Now when you run your model you will see a display of the number of penguins as a proportion of the total. You will also see a graph of the populations; double click the chart to enlarge it.
An alternative to a character dying would be for a new character to replace it. To make a penguin change into a turtle in the code above replace 'die' with a 'hatch' block. To do this the 'hatch' block is needed from Logic section. The action in the hatch block is to set the breed with a 'Set Breed' block from Traits and the actual breed from the My Blocks section.
Another alternative is to change the breed of the affected breed into a new one, as if it had been infected and turned into something else. In the model supplied with the program and described in the Star Logo tutorial (Epidemic) the program objects are spheres whose colour can be changed during the program. More complex objects like the Turtle and Homer cannot change colour.
In the model so far we have watched passively while the characters wandered around Spaceland, colliding and dying. With some more programming we can control the characters and create an interactive, competitive game. In this model we will have just one copy of each of two characters and they will try to kill each other.
The characters can be set up in the same way as before: clear everyone, create the characters, scatter the characters.
To provide user controls we need to add some if..then..do blocks to the movement block. A character will move forward, back, left and right so we need a keyboard character for each one. Add an if..then..do block for each character. In the if part add a keyboard block from the Controls section and choose the key press that you want from the list on the block. In the 'then' part of the if block add the movement that you want e.g. forward 1 or left random 10.
To add a weapon to the character you will first need to add a suitable breed. In Edit Breeds choose New and select a sphere from the Basic shapes section. Call this 'ball' or anything else that you want. Add a fifth 'if' block and select a suitable key press for the weapon. For the 'then' part add a hatch block and set the breed to 'ball'. You may also need to add a small movement to the character to prevent it being killed by its own weapon.
There is now a ball section to the movement block and you need to make sure that the ball keeps moving forward.
There are also new Collision blocks in the My Blocks area and you need to add one of these for each potential collision. One collision is between the two main characters. Here neither should be killed but you could add a sound or a speech bubble (Ouch!) and move them back a few steps.
The other collisions are between the characters and the balls. The simple option is simply that both the character and the ball die.
One final possible collision is between ball and ball. In this case it would probably help the game if they both die so that the number of balls is kept down. If the balls don't die then the playing area fills up with them. Can you think of other ways to reduce the number of balls? A sweeper character, perhaps?