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

Autonomous Turtle : Charcoal generation

Started by Eyo, 29 November 2013 - 05:16 PM
Eyo #1
Posted 29 November 2013 - 06:16 PM
Hey,

I'm sharing my very first turtle, which is obviously the one that can bring me infinite fuel. It is supposed to feed my upcoming next turtles.

Don't hesitate to ask me any question, or live demo on your server.

I apologize if the topic is wrongly located, I can't managed to find some space to share my program here.

Features

The turtle :
-is meant to be autonomous : it will gather mode wood (then charcoal) than it consumes
-is automatically replanting the tree roots
-works with a chest and a furnace, which is loaded by the turtle.
-works only with a single type of wood. Trees can't have branches.
-gather the tree roots, apples or rubber during its trip, but it won't make extra moves to collect everything (charcoal is the priority)
-should work with any rectangular sized forrest size.
-The program is parametrable with a few variables at the start of the program.
-The setup is doable very early in survival mode. The hardest point being the 3 diamonds to craft the turtle axe.

Prerequisite

It is mandatory to respect a few guidelines to make it work :
-Slot 16 : Fuel. a few Charcoal items are necessary for the first start. Lava bucket won't work and Coal will slow the turtle down.
-Slot 15 : Tree roots.
-Slot 14 : One block sample used to detect the edges of the forest.
-Slot 1 : a wood block sample of the type that will be cut.
-Torches : put a torch so that every tree is two blocks close to at least one torch.
-Trees have to be put every 4 blocks.

First start

I'd advise to put a halfstack of charcoal and 2 times more tree roots than the turtle has to plant. Put two blocks on the edge to avoid intruders in the field.

Problems encountered

-the turtle is not able to compare a tree root block in its inventory and a growing root : compare fails. It obliges me to add an extra item in the inventory
-There is no algorithm to cut branches : the turtle digs frop top to bottom only. For some wood type i'd recommand put a roof to avoid big branchy trees. Bad news is that it slows the growth down.
-Until now the rubber tree seem to be the most efficient (qucik growth in a single trunk and extra loot)
-The variable choice is quite arbitrary. The turtle might no be profitable in some situations.

Possible improvements

-it might be very useful to dope the production with bone meal.
-find which wood type is the most optimised.
-the turtle might wait for each tree to grow completely before moving (instead of avoinding the root). It might save a lot of useless fuel consuming. It works only if a tree always grows (is it sure?).
-Try to reduce the prerequisites.
-The turtle should be able to build the forrest completely.
-Maybe a system with water to concentrate the tree root drops but it doesn't seem so interesting.
-Detect tree growth with redstone to move only when the trees are all grown. It might be too expensive.
-Find a way to evaluate the necessary fuel and wait time better between each run.

Code

Charcoal Generator turtle
http://pastebin.com/s1eyyMDG

Plan

Here is a plan of a working tree farm.


E E E E E E E E E E E E E E E E E
E							   E empty : anything works
E   A	   A	   A	   A   E E = Edge : any block
E							   E A = Tree (with dirt under)
E	   L			   L	   E L = Light (torch)
E							   E T = Turtle (initial position)
E   A	   A	   A	   A   E C = Chest
E							   E   F = Furnace
E	   L					   E Block T and F need an empty block underneath, and an empty block above F
E							   E One block is necessary between the trees and the edge
E   A	   A	   A	   A   E
E							   E
E	   L			   L	   E
E							   E
E   A	   A	   A	   A   E
E C T						   E
E E F E E E E E E E E E E E E E E

I'm taking any suggestion, questions, improvements, commentaries.

@Eyolfur
Poilot #2
Posted 01 December 2013 - 03:03 PM
Hi!
I’m very new to ComputerCarft so this will most likely sound like a noob question/issue.
I setup the farm just as you suggest and I’m running into something.
When the turtle reaches the edge, it doesn’t turn around and start the second row but throws the error message "Unexpected block during AvoidRoot operation" and stops moving.
I tried using different types of edge block and increasing the space between the trees and the edge with the same result.
Can you look into it?
Let me know if you need more details to debug.
Thanks.

My bad, I used the wrong inventory slot. It works like a charm now.
Eyo #3
Posted 02 December 2013 - 03:09 PM
I just realized it didn't seem to work with dirt when the turtle as a brown dirt in the inventory and the actual edge has grass on it. It can fail that way.

Now my main problem is collecting new tree roots when they fall down. If I let my turtle work all night, it ends up with no more roots in the inventory. And indeed I think I should at least let one tree root block always in the inventory (the turtle might store the new blocks in another slot than slot 15).

Any solutions ? Digging the leafs ? make another lap only to collect the leafs ?
Bomb Bloke #4
Posted 02 December 2013 - 05:01 PM
Dunno about a complete solution, but you may be able to mitigate the issue by doing something like this in your digTree() function:

        while turtle.compareUp() do
                turtle.digUp()
                turtle.up()
                ups=ups+1
                for i=1,4 do
                        turtle.dig()
                        turtle.turnRight()
                end
        end

You could also consider channels of water, or perhaps make use of Thaumcraft golems, in order to collect other falling saplings.
Eyo #5
Posted 02 December 2013 - 05:36 PM
By the way I think I worked it out with a close solution :
-digging in the base wood block in front and place the sapling.
-dig up (so it's digging a leaf)
-go up and break left, right and front block (which are either wood or a leaf
-when there is no block in front, go forward and break left-right, go forward and break again the left, right, front leafs while going back to level 0. Digging behind is causing problem in somes cases and most of the time it is empty.
On a 5 blocks tall tree, it breaks about 20 leafs and it seems the probability is still 1/16 so the turtle seem to recollect quite well. A stack of sapling is still advised to start on good basis.

=>all this extra work make the turtle slower than before so you can almost remove the Waiting time.
Eyo #6
Posted 07 December 2013 - 08:43 AM
I posted a V2 on pastebin with the features I've talked before :
The turtle V2 is collecting enough sapling to survive and loop infinitely. It makes it totally autonomous.

There is a new error message to ask for more saplings in the base inventory, and a parameter to ask if the turtle should make a single run or loop infinitely. I'm still very annoyed by animals or mobs entering in the forrest. Lights and tall borders are necessary to ensure a safe run.

Another problem that i don't think i'm going to fix is that the turtle is cooking very few charcoals at the end. You end up collecting 80% of wood, 10% of charcoals and 10% of saplings and apples. I won't fix it because i'm planning to program another turtle which role is to collect the wood in the chest and bring it to a furnace room, that is going to cook everything. It will then bring charcoal back to the wood turtle.
And guess what, it will be server driven with wifi turtles !