This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Buho's profile picture

What happens when a turtle moves to the edge of a loaded chunk?

Started by Buho, 29 December 2013 - 07:46 PM
Buho #1
Posted 29 December 2013 - 08:46 PM
I don't know, so I wrote this simple program to find out:


local i = 0
while turtle.forward() do
    i = i + 1
end
print("Traveled "..i.." blocks.")
for x = 1, i do
    turtle.back()
end

My working assumption was that it would attempt to move into an unloaded chunk but fail, so return. It seemed safe enough but apparently I was too naiive. I launched my turtle from y=153 (above the clouds), nothing obstructing it. I had Render Distance set to the shortest. My turtle left and didn't come back after 3 minutes, so in case it was still going forward, I entered a portal and came back to cause the turtle to reboot and halt. I then built a platform out to retrieve it but after 400 blocks I found nothing. My turtle is gone! (And yes, the startup program doesn't move him. And it had over 100,000 fuel.)

What happened? Can you recommend another program for testing the chunk edge?
Buho #2
Posted 29 December 2013 - 11:07 PM
Okay, this is really weird.

I built another turtle, fueled it up, and tried again, this time in my kilometer-long straight-shot nether tunnel. I placed an obstruction 420 blocks out just so the tests wouldn't run so long. Render distance set to shortest (32 blocks radius). Wiki says max render distance is 256 blocks radius. The turtle wirelessly reports the distance traveled but my receiver is at y=114 and can only hear out to about 100 blocks, so I lose contact with the turtle at that point. By the way, that is already past the minimum render distance, meaning the turtle is using rednet in an unloaded chunk!

My turtle returned, having traveled 420 blocks. That means the turtle can move around in unloaded chunks, even feeling the terrain of unloaded chunks!!

A second test had the turtle place and destroy a block every step forward. If it fails to place, it reports the distance and returns. It went 420 blocks, never failing to place or break, meaning the turtle can modify the world far beyond the loaded area.

A third test had me wait until the turtle was beyond render distance, then I moved in the opposite direction 300 blocks and returned before the turtle would return. The turtle returned no problem, meaning it operated fine with no player in sight. A minor variation had me leave the area while it was traveling in the loaded chunks. It still worked no problem.

Is there anything a turtle cannot do infinitely anywhere in the world if the player sits in one spot?

This is so weird!
Lyqyd #3
Posted 29 December 2013 - 11:38 PM
Render distance has nothing to do with loaded chunks. The same number of chunks are always loaded around a player regardless of the client's render distance.
Buho #4
Posted 30 December 2013 - 12:27 AM
Render distance has nothing to do with loaded chunks. The same number of chunks are always loaded around a player regardless of the client's render distance.
So, on shortest render distance, F3 shows 62/400 chunks loaded. 400 total loaded chunks centered around the player. If it were a square, that's 20x20 chunks, or 320 blocks radius. That doesn't explain why my turtle traveled 420 blocks.

For S&Gs, I removed the obstacle in my tunnel, relogged, and let the turtle go. It returned reporting a travel distance of 1072 blocks. How many chunks are loaded, again?

FYI, I ran a couple more tests. The turtle seems to reboot if you leave the area and it is within 120 blocks, but you are free to go as you please if it is beyond that: it operates without rebooting and returns as if you never left.

One test I left the area (300 blocks in the opposite direction) for an extended period. The turtle was at the starting position with its display still intact. Paradoxically, a computer right next to the turtle's starting/ending position had rebooted.

I'm still not sure why this works; I'm still focusing on practical applications.
Bomb Bloke #5
Posted 30 December 2013 - 12:51 AM
If it were a square, that's 20x20 chunks, or 320 blocks radius.
You mean diameter. The radius would be 160 blocks. (Edit: Well, putting aside the point that squares don't have a radius nor a diameter, I suppose.)

For S&Gs, I removed the obstacle in my tunnel, relogged, and let the turtle go. It returned reporting a travel distance of 1072 blocks. How many chunks are loaded, again?
Sounds a bit like something else is loading those chunks. Assuming you haven't planted a chunk loader a hundred blocks or so away from your test zone and forgotten about it (which I'm not considering likely), my guess is that any unloaded chunk the turtle attempts to move into becomes loaded as it does so (most likely so the server can see whether or not the turtle's about to move into a wall).

If you move away from an area, then the chunks you leave behind you are unloaded - but these chunks the turtle is activating are outside the range of those that your character has loaded, hence the game doesn't check to see whether they should be unloaded as your player moves. Hence why the turtle stops if your character leaves before it makes it a certain distance away, but not if it gets further then that point.

I would be curious to know what happens if you use a computer as your obstacle - plant it in the middle of a chunk, and set it to run a startup script that saves a counter value to its drive each time it boots. Maybe plant a couple of other such computers along the turtle's path, not so as to block it, just to see how many times they boot as you perform your tests.
Edited on 29 December 2013 - 11:57 PM
Buho #6
Posted 30 December 2013 - 12:58 AM
Yes, I meant diameter ;)/>

Yes, no chunk loaders are present. I'm running vanilla Minecraft + CC.

I was watching the F3, it doesn't change from 400. Maybe other chunks are unloaded and new chunks are loaded as the turtle enters them. But it's not a full load: items on the ground do not despawn.

I think my conclusion from these tests is that I have less to worry about when running my swarm mining program. Previously I restricted them to a 160x160 block area centered on me. I'm going to try expanding it considerably.
Bomb Bloke #7
Posted 30 December 2013 - 01:02 AM
But it's not a full load: items on the ground do not despawn.
Items take five minutes to despawn, assuming the chunk they're in is loaded the whole time. Assuming chunks are unloading as the turtle leaves them, its passage through them may well have very little influence on despawning.


Dunno if you caught the edit of my previous post, but I'd suggested setting up some extra computers along your route with "reboot counters". This'd tell you whether the chunks are loading and unloading as the turtle goes forwards and backwards through them.
OReezy #8
Posted 30 December 2013 - 04:52 AM
EDIT: I completely misread one of your statements.
Edited on 30 December 2013 - 03:54 AM
TurtleHunter #9
Posted 30 December 2013 - 05:30 PM
Are you on the spawn?

An area of 12x12 chunks in the spawn area is always loaded except when you are in other dimension. http://minecraft.gamepedia.com/Spawn_chunk

Try moving your turtle to another place far away from spawn or set the spawnpoint somewhere else
Buho #10
Posted 31 December 2013 - 08:51 AM
Items take five minutes to despawn, assuming the chunk they're in is loaded the whole time. Assuming chunks are unloading as the turtle leaves them, its passage through them may well have very little influence on despawning.

Dunno if you caught the edit of my previous post, but I'd suggested setting up some extra computers along your route with "reboot counters". This'd tell you whether the chunks are loading and unloading as the turtle goes forwards and backwards through them.
Yeah, that could be. I could do a turtle.dropDown() os.sleep(5*60) turtle.suckDown() experiment.

Aye, I missed your edit. I'll try that out.

Are you on the spawn?

An area of 12x12 chunks in the spawn area is always loaded except when you are in other dimension. http://minecraft.gam...com/Spawn_chunk

Try moving your turtle to another place far away from spawn or set the spawnpoint somewhere else
My experiments were done in the nether and the turtle traveled over 1000 blocks starting at around z=-100. My first experiment was done in the overworld at z=500 and was last seen heading toward spawn but was not found anywhere. (That's still a mystery: where in the world is my turtle? I couldn't find it even with MCEdit!)

I recommend you all give it a try and see for yourself. Let your turtles run wild! Ever since I began working with turtles, I've had a low-level paranoia about turtles rebooting if they got too far away. I think that fear is largely a non-issue now, but more testing is in order.
Buho #11
Posted 15 January 2014 - 10:07 AM
Just thought I'd mention, I've written a program that exploits this effect. At my skeleton spawner, I have a turtle load up its inventory with bones, then travel ~300 blocks west and ~1200 blocks south to dump them at my tree farm, and then return. It's not the fastest mode of transport, but it's the easiest, and it's plenty fast to keep up with the bone generator.