user3731312
user3731312

Reputation: 19

Move diagonally in netlogo

I want move to a specific diagonal direction in netlogo.

I can move the turtle with the fd command but I don't know what condition (if-else) put in the code

    to go
     ask turtle 2 
       [ move ] 

  tick
      end

   to move 
    if( (pxcor = -15) and (pycor = -15 ))
 [fd  5     ]
    end

Upvotes: 0

Views: 459

Answers (1)

Alan
Alan

Reputation: 9620

Your question is still unclear. You say you "want turtle with id 2 ,first move to right and then move to up". But how far in each direction? I'll assume 5, based on your question. Here is what seems to be the best overall match to your question.

to go
  ask turtle 2 [move1]
end
to move1
  set heading 45
  fd 5
end

But if you really want to move right and then move up

to move2
  set heading 90
  fd (5 / sqrt 2)
  set heading 0
  fd (5 / sqrt 2)
end

Upvotes: 1

Related Questions