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

Turtle suddenly restarts while running the program

Started by KakarotoCm, 02 August 2015 - 08:33 PM
KakarotoCm #1
Posted 02 August 2015 - 10:33 PM
Hello, I am working in this Artificial Intelligence for about three months, and today I managed to finish the last bits of it. The main purpose of it is to be a mining turtle that instead of just mining in a straight line or in a pattern, checks for ores around it and if so use that information to mine the entire vein.

The programs works just fine, but after it has run for a while the turtle just suddenly restarts. At first I thought the problem was related to the common "Too long without yielding" problem, but when I checked the turtle Interface there were no errors. After that I checked if I used os.shutdown() or os.restart() at any point of the code, and I didn't.

Finally after searching for similar problems in the internet I found that that might happens due to memory overflow, so I thought it might be a problem with the computercraft mod itself.

The code is a little bit too big, so I uploaded it to pastebin here: http://pastebin.com/tbhJUD0c

I'm currently using ComputerCraft 1.73 in the direwolf20 1.7.10 pack, and I also would like to know if I can change something in the config files to fix it.
Lyqyd #2
Posted 02 August 2015 - 11:54 PM
Is the turtle's working area chunkloaded? How far away do you move while it is working?
Bomb Bloke #3
Posted 03 August 2015 - 01:07 AM
after it has run for a while the turtle just suddenly restarts.

"Restarts" or "shutsdown"?

Setting a basic timer display script to run on startup would tell you, if you're not sure.

At first I thought the problem was related to the common "Too long without yielding" problem, but when I checked the turtle Interface there were no errors. After that I checked if I used os.shutdown() or os.restart() at any point of the code, and I didn't.

Scripts that fai to yield do often shut systems down instead of displaying errors.

Finally after searching for similar problems in the internet I found that that might happens due to memory overflow, so I thought it might be a problem with the computercraft mod itself.

If you were triggering a memory-related problem, then I would expect to see an error.

I reckon Lyqyd's probably got it right, though - odds are you're moving too far away from the turtle's chunk, causing it to unload and therefore shutting the turtle down until you return to the area.
KakarotoCm #4
Posted 03 August 2015 - 01:58 AM
The area where the turtle was running was loaded, actually it was right in front of me, It runned for like 10 blocks and mined a vein or less before stopped.

after it has run for a while the turtle just suddenly restarts.

"Restarts" or "shutsdown"?

It restarts.
Edited on 04 August 2015 - 07:25 PM
safetyscissors #5
Posted 06 August 2015 - 04:24 AM
Bug reproduced.
If you watch the program while it bugs, it shuts down. NOT a restart.
Happens when
a) its mining a vein.
B)/> at least after it checks a location and sees nothing.
c) before it heads back to its last known position.

Pretty sure its code. I'll hopefully get to debug later tonight if noone else sees it.
safetyscissors #6
Posted 06 August 2015 - 05:25 PM
the bug
The loop on line 310, inside headTo is getting caught in an infinite loop. which secretly throws a "Too long wihtout yielding" before shutting down.
printing the coords shows me the target coords match the numbers of the current coords
printing conditionals shows that the zcoord is failing

the conjecture
one of your zcoords is a string in that object. I think a function is hard setting either the targetZ or z with a string.
Either find that statement, or wrap your while loop checks with tonumber()
KakarotoCm #7
Posted 08 August 2015 - 03:22 AM
Thanks man! Now the program is working properly, I'll do some optimizations on it and will probably be posting it soon :D/>