Sun  Mon  Tue  Wed  Thu  Fri  Sat 

1  2  3  4  5  6  7 
8  9  10  11  12  13  14 
15  16  17  18  19  20  21 
22  23  24  25  26  27  28 
29  30 
Calendar
Upcoming eventsCookbook 
Putting Turtles in BoxesHow do you start turtles off in a confined space, like a room or a box? Solution:
First draw your box. You can do this through the Edit Terrain button at the bottom right corner of Spaceland. You'll also need to find the x and y coordinates of your box's corners. When you're in Edit Terrain mode, the x and y coordinates of your mouse are displayed at the bottom left of the window. Hover over any patch you'd like to see the position of. To force a position for a turtle, you can use set xy. To figure out what we want to put in the values for xcor and ycor, first we'll describe the size of the box by finding the difference between the minimum and maximum coordinates of the box for both x and y. This means we subtract the smaller x coordinate from the larger, and the same with the y coordinate. My smaller x coordinate is 39 and my larger is 11. This will make the agents arrange themselves with a positive xcor and ycor. My box's coordinates are all negative. We need to align the corner that's automatically at 0,0 (the bottom left corner) to the bottom left corner of the box where we want the turtles to be. We do this by subtracting the absolute value of lowest x coordinate of our box from the random number in the xcor slot, and the same for the y coordinate. (An Absolute Value is the distance a number is from 0.) If our coordinates were positive, we'd be adding to the random numbers instead of subtracting. You can call this from anywhere in your code. This example I put in the Setup code of an epidemic model. Of course, this doesn't stop agents from leaping over walls.
See also:
Submitted by talaya on 15. January 2009  22:12

Login (optional)Navigation 