Serendip is an independent site partnering with faculty at multiple colleges and universities around the world. Happy exploring!

Reply to comment

Paul Grobstein's picture

Learning

Learning code

 

turtles-own [ health ]

to setup
ca
crt 1
ask turtles [ set health 1 set color green]
ask patches [if pycor > 0 and pycor < 20 and pxcor = 0 [ set pcolor red ]]
end

to go
ask turtles [ ifelse health = 0 [ go2 ] [ set heading random 360 fd 1 if pcolor = red [set health 0 set color yellow ]]]
end

to go2
set heading random 360
if [pcolor] of patch-ahead 1 = red [ set heading heading + 180]
fd 1
end

Reply

The content of this field is kept private and will not be shown publicly.
To prevent automated spam submissions leave this field empty.
1 + 0 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.