We’re going to use the multiturtle mode and the primitive setturtle. setturtle followed by an integer allows us to
select the turtle whose identifier is the integer.
A good schema is better than a thousand explanations....
Each turtle whose integer is from 2 o 12 will forward one step, when the corresponding dice sum appears. For example,
if the two dice scores is 8, then turtle number 8 will forward one step. Between two turtle, there are 30 steps
horizontally.
We set all turtles using coordinates.
Better than writing 11 times the same command line, we’re going to use the primitive for. With this primitive, we
can give a variable a sequence of values. Here, we want that the variable :i to have succesive values 2, 3, 4, ... , 12.
We write:
for [i 2 12] [ list of instructions]
To set up all the turtles we create the procedure initialize
You must understand the expression -150+(:i-2)*30. We’re beginning from -150, and for each new turtle we
add 30. (Test with the different values for :i if you’re sceptic)
Finally this is the program:
Here is a more general program. We’ll ask the user the number of dice he wants and the number of tries to make.