Colin Minder
Colin Minder

Reputation: 1

Turtles must not cross the "world" boarder

In my Netlogo project the turtles (circles, that simulate tables in a restaurant) are not allowed to cross the worlds boarder, since there is the wall of the restaurant. Before setup the user can choose the tables diameter. I tried the following:

if xcor < (size / 2) or xcor > (32 - (size / 2)) [ find_new_spot ]

if ycor < (size / 2) or ycor > (32 - (size / 2)) [ find_new_spot ]

The idea was that if the xcor is smaler than the radius of the table, it has to find a new spot. Same goes with the ycor. But this does not work. Is there anything missing?

My Netlogo world is set up like the following:

Upvotes: 0

Views: 41

Answers (1)

JenB
JenB

Reputation: 17678

It's possible that they did find a new spot, but the new spot was also too close to the wall. You can debug that by putting a line into your find_new_spot procedure that tells you the location at the beginning of the procedure and then again at the end of the procedure. If that is your problem, then you need it to keep moving until it find an allowed spot, so you need a while loop.

Upvotes: 1

Related Questions