Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+11 votes
to move-planets
  ask planets [
    facexyz random-xcor random-ycor random-zcor
    fd 2]

currently this is my code I have, so I want my turtles to move different directions, but once they are set facing a certain way I only want them to move that way but not sure how to do this.

asked in CSC 150 January201920 by (1 point)
+1

Good question!

4 Answers

+6 votes

I would create a global variable called something like "orient-planets" and set it to be 0 in your setup method.

globals [ orient-planet ]

to setup
let orient-planets 0
end

Then in this part of your code you can make an if statement to check if this number is 0.

if orient-planets = 0 [ ]

Inside of the brackets you would then just have to set orient-planets to be a number other than 0, and they will only change their direction one time.

to move-planets

ask planets [

if orient-planets = 0 [
      facexyz random-xcor random-ycor random-zcor
      set orient-planets 1
     ]
fd 2
]
answered by (1 point)
+2

Thanks !

+5 votes

Using if statements would work in this case!

answered by (1 point)
+5 votes

I think you should categorize them somehow with if statements as kashav said and set different directions for each.

answered by (1 point)
+1 vote

I think you should add set heading

answered by (1 point)
...