Net Logo Turtle disappears inside of Patch - netlogo

In Net Logo is there a value for a turtles Z coordinate, or its height in the 3D View? I have white patches in my simulation, when my turtles go into those patches they are not visible until they emerge from the other side of the patch.
In the screen shot, you can see edges of turtles inside of my white patches, I want to display them on top of the patch.
How can I do this?

I found the issue, simply use
set zcor 2
will place the turtles on top of the patches as I had hoped.

Related

What is the difference between turtle size, patch size and frame rate in netlogo?

I want to know the Relationship between turtle size and patch size in Netlogo. Also I want to make those sizes in a way such that any turtle moves from one patch to another at every tick.
Patch size is measured in pixels. It is configurable in the "Model Settings" dialog.
You can think of turtle size as measured in "patches". A turtle of size 1 should appear to be the size of one patch. (Note, however, that turtle size is a "display only" property. Conceptually, turtles are just points. They don't really occupy space in the NetLogo world even if they appear to do so.)
Changing the xcor or the ycor of a turtle by 1 should move it by exactly one patch. If you want them to move diagonally, things are a bit more messy. You might be better off targeting destination patches directly, e.g.:
; move to the patch north-east of current position:
ask one-of turtles [ move-to patch-at 1 1 ]
; move to an adjacent patch at random:
ask one-of turtles [ move-to one-of neighbors ]
Those are just examples, of course. The code to use will depend on what exactly you are trying to do. If you tell us more in a separate question, we might be able to help you.

Netlogo: Creating a square area of patches in the center of the grid

I am trying to create a square of brown patches centered at the origin of my grid. Previously, I had a slider on the interface called "sink-patch-radius" that goes from 0 to 20. Then in my code, I created a circular set of patches centered at the origin that were colored brown + 2 and had a radius of "sink-patch-radius", and the surrounding patches were green. Here is the code that worked for that (thank you to JenB for this!):
;;create the 'sink'
let sink-centre patch 0 0
set sink-patches [patches in-radius sink-patch-radius] of sink-centre
ask sink-patches [ set pcolor brown + 2 ]
;; create the 'source'
set source-patches patches with [pcolor != brown + 2]
ask source-patches [ set pcolor green ]
So now, I want that idea to stay the same, but instead of a circular "sink area", I want it to be a square. I know the above code will have to change, maybe even quite a bit, because you cannot use "in-radius" to make a square. I'm thinking of maybe changing the slider to be "sink-patch-length" so that it adjusts the length of the sides of the square. My question would then be: how do I incorporate that into my code, so that I get a square of brown patches centered at the origin? For example, if "sink-patch-length" is set to 20, then I would want a 20x20 square (400 cells) centered at the origin to have a pcolor of brown + 2.
Any help is greatly appreciated! Thank you.
Use the inbuilt coordinate system. So you want (something like) patches with [abs(pxcor) <= sink-patch-length and abs(pycor) <= sink-patch-length]. If you want it centred somewhere other than the middle, you will need to do some fiddling to make the boundaries correct.

how to hide an image over patches in netlogo

I have imported an image over patches by using netlogo command "import-pcolors "abc.png" ".
Now i am trying to hide an image so that turtles interact with the hidden image as only by following those patches of the hidden image.
thanks in advance.
first make an extra patch variable for storing the color information:
patches-own [invisible-pcolor]
(calling it whatever you want)
then after import-pcolors do:
ask patches [
set invisible-pcolor pcolor
set pcolor black
]
and then have your turtles interact with invisible-pcolor instead of pcolor.
another solution would be to fill the drawing layer with black (or any color), e.g. by making a giant turtle of the color you want and having it do stamp then die

How can I simulate a moving patch?

I'm trying to make a Frogger-like game where the patches move around and the turtle can only move onto a safe patch. If I have a few patches that are red, how can I 'move' them around as if they were turtles? I currently have this, but it seems to move more than 1 patch at a time occasionally and as a result, some red patches will be destroyed if there are more than one that is red:
if pcolor = red
[ ask patch-at 0 1
[ set pcolor red]
set pcolor black ]
You could ask the neighbor patch (left or right) to be painted red and the actual patch to be painted back to black or whatever the default color is.
For this you'll want to get the actual patch coordinates. Using patch-at asks the patch at 0,1 relative to the whole world.

Direct to move turtle to a specific spot

I have enclosed turtles in between walls and obstacles and want them to move to a specific goal spot. Each tick I forward turtle only a specific amount. How do I implement this in terms to variating the turtle heading?
Explaining more
In the above figure:
1. Consider all turtles inside the box at the start
2. You want turtles to reach goal spot above,(where turtles present currently in figure)
3. You have obstacles that is, walls in between which 1 opening that is the rectangle in the figure with the gap. Turtles have to pass this gap only.
How I tried
I make turtles face the goal spot using facexy and bounce back after colliding with wall but in doing so the turtles on extreme left and right of box keep colliding with wall since after each collision they again have the direction from facexy
Please help. Thanks in advance.
An easy fix (according to what I read about making the turtles bounce).
goal-xcor is the x-coordinate of goal.
goal-ycor is the y-coordinate
of goal.
random-number is a random number between 1 and 10(?).
`If COLLISION: `
if they're in the left make them facexy goal-xcor + random-number goal-ycor
if they're in the right make them facexy goal-xcor - random-number goal-ycor
If there is not any collision it means they're in the right way and they should keep going the goal direction.
It's important that you facexy goal-xcor goal-ycor every time you make them turn around. To be more clear: Pseudo-code:
1 setup-turtles-inside-box
loop:
2 ask all turtles to face goal.
3 ask all turtles to go forward.
4 if collision
5 if turtle-in-left
6 ask turtle to face goal-xcor + random-number goal-ycor
else
ask turtle to face goal-xcor - random-number goal-ycor
7 loop until all turtles are in goal.
Let us know of any doubt!
Here is another approach:
http://rur-ple.sourceforge.net/en/random.htm