Turtle graphics and world boundaries

While cleaning up old code in Python, I found some examples using turtle graphics.

Naturally, I thought I could redo these in NetLogo.
It turns out that NetLogo is orders of magnitude faster than Pythons turtle module.
However, there is a problem with boundaries of the drawing.

When turtle graphics in Python (and other languages) moves out of the visible area, it just does not draw as long as the turtle is outside boundaries.
I would like to see the same – or similar – behavior in NetLogo. However, with world wrapping on, the drawing wraps (what else?). When world wrapping is off, the turtle bumps into the world boundaries and any structure of the drawing is lost.

See this small example, converted from a Python example.

koch-curve.nlogox (3.9 KB)

Now the question is: how could we let NetLogo turtles draw only when (non-wrapped) in the visible area?
Probably, we would need world wrapping on and suppress drawing (penup) while its coordinates are wrapped.
Any ideas, even ignoring special cases, are welcome.

I agree that this functionality could be useful. I can think of a way to do this currently, although it’s a bit hacky. If you keep track of each turtle’s “real” unwrapped coordinates by manually calculating turtle positions, you can then have a check like this each tick:

The problem with this method is that you would need to manually replicate the behavior of primitives like fd and bk to ensure that your real-x and real-y values are properly synced with the turtle’s wrapped coordinates. I would definitely be in favor of a built-in unwrapped and unbounded world mode, but we’ll see what other people think. It would probably make the logic for drawing trails a bit more complex, but I don’t think it would be undoable.

I think this extension could be used for this, but would need to look further and it probably needs to be updated for NetLogo 7: GitHub - qiemem/inf-extension: An infinite topology extension for NetLogo · GitHub

@mrkramer_wageningen I updated the Inf extension mentioned above to work with the latest version of NetLogo, and it appears to solve your problem very effectively! It will be available in the extension manager along with the upcoming release of NetLogo 7.1. You can also download the alpha release of 7.1 here, which should give you access to the extension now.

Well, this is more than I expected. I am going to check it.

Thank you Jacob and Isaac!

Marvelous!

Just a few changes and it works!
Even regardless of world wrapping.

koch-curve-inf.nlogox (3.8 KB)

Thank you