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

[DEV] AutoMiner

Started by GeorgeK, 18 September 2012 - 05:21 PM
GeorgeK #1
Posted 18 September 2012 - 07:21 PM


Hey! A while ago, when I had a server and was playing Minecraft I wrote this little script in about an hour out of necessity. At the time there wasn't a script like this out there. I'm not sure if that's still the case but I thought I'd share the idea. It still has a couple of unexplained bugs and there are still some features to be added, but if there turns out to be a need for such a script I might get around to finishing it.

Check out the video bellow, cheers! ;p


<iframe width="560" height="315" src="http://www.youtube.com/embed/8PxwyPGUMos" frameborder="0" allowfullscreen></iframe>
KinoftheFlames #2
Posted 19 September 2012 - 06:42 AM
He seems terribly inefficient, with all that turning. Besides fixing that you could have him just dig in two tunnels (one to destination and one back) and he wouldn't have to turn to detect. Also I don't understand why he digs out the spot above him if he doesn't move up to detect.
PROdotes #3
Posted 19 September 2012 - 09:38 AM
you should check out my shaft miner… you might find something useful in it's code :)/>/>

as for the turning… sadly there's no way around it… my miner digs a 1 wide shaft so it has to turn 360 to detect what's around him… unless we get a turtle.detectLeft() and turtle.detectRight() command :D/>/>
KaoS #4
Posted 19 September 2012 - 10:21 AM
you should check out my shaft miner… you might find something useful in it's code :)/>/>

as for the turning… sadly there's no way around it… my miner digs a 1 wide shaft so it has to turn 360 to detect what's around him… unless we get a turtle.detectLeft() and turtle.detectRight() command :D/>/>

a piece of advice for you: don't turn around every time, dig all the way down and detect front on the way, then turn and go all the way up, time it and you may find that it is a lot faster
GeorgeK #5
Posted 19 September 2012 - 12:27 PM
He seems terribly inefficient, with all that turning.

It has to turn since the only functions for "detecting" the ores it's supposed to dig up are .compare(), .compareUp() and .compareDown(). It also might seem a lot slower than it really is, because there's like 20-30 ores in a 10 block long tunnel, a quite unlikely scenario.

Also I don't understand why he digs out the spot above him if he doesn't move up to detect.

When I added that feature I was unsure whether or not it worked correctly which is why I made it dig up the layer above, so I could inspect the tunnel. I guess that when it's complete and when I know for certain it digs up a 100% of what it's supposed to, that bit could be removed.

don't turn around every time, dig all the way down and detect front on the way, then turn and go all the way up, time it and you may find that it is a lot faster

I'm not sure what you mean by that.. Are you suggesting it digs vertically?

Cheers,
George
KaoS #6
Posted 19 September 2012 - 12:31 PM
I was referring to ProDotes shaft miner, it digs down 1 and spins around checking all sides for ores, it will probably be faster to dig straight down, checking in front, when it gets to the bottom turn once and go up again checking for ores and loop it to check all 4 sides
GeorgeK #7
Posted 19 September 2012 - 12:54 PM
I was referring to ProDotes shaft miner, it digs down 1 and spins around checking all sides for ores, it will probably be faster to dig straight down, checking in front, when it gets to the bottom turn once and go up again checking for ores and loop it to check all 4 sides

I guess I could add vertical digging to it.. That'd just be one recursive backtracking function.. Turning is the main problem. It takes a lot of time for it to turn. I guess I could make it so it just digs a straight line forward, checking for ores, and then comes back the same way. A lot of them could then be set up, but I'm not sure what's most efficient. Adding .compareLeft() and .compareRight() would make work a lot better. :)/>/>

Cheers,
George
GopherAtl #8
Posted 19 September 2012 - 04:01 PM
If you're playing with fuel on, the turning approach is far more efficient regardless of which is faster, as it only uses 1 fuel for every 5 blocks (shaft + the four surrounding). Going down and only checking forward would be 1:2, 2.5 times as much. Forward and checking up and down would be a bit better at 1:3, but that's still 1.67 times as much. Fuel-wise nothing beats turning to check all 4.
KaoS #9
Posted 19 September 2012 - 04:33 PM
that is correct. I do not use fuel so I guess it's up to the user
GopherAtl #10
Posted 19 September 2012 - 04:42 PM
I prefer playing with fuel, tho I don't know of any smp servers that actually require fuel. They all seem to use the full cheater settings (no fuel, rednet range 10000+)
KaoS #11
Posted 19 September 2012 - 05:19 PM
I have range cheating, it's realistic the way it is
PROdotes #12
Posted 20 September 2012 - 07:02 AM
you should check out my shaft miner… you might find something useful in it's code :)/>/>

as for the turning… sadly there's no way around it… my miner digs a 1 wide shaft so it has to turn 360 to detect what's around him… unless we get a turtle.detectLeft() and turtle.detectRight() command :D/>/>

a piece of advice for you: don't turn around every time, dig all the way down and detect front on the way, then turn and go all the way up, time it and you may find that it is a lot faster

it actually diggs a shaft now… X long, Y high
so it does this…
dig forward 1, check around you for odes… then y times, dig 1 up, check for ores, then go down y t times and reapeat this X times… place a torch every 8… if you find ore, dig it and after digging, move where it was and check again… all the time remembering your path and checking if inventory is full and if you have enough fuel… if either of that is not true, go back to the chest, empty your inventory and wait for fuel (or torches)…

too lazy to expand it to do branch mining… but tested it on a 3x3 chunk area yesterday, starting from bedrock digging 10 high shafts and got 40 diamonds :)/>/>
BigSHinyToys #13
Posted 20 September 2012 - 08:38 AM
I have one suggestion. Instead of looking for a specific mineral tell it what not to collect.

example
if not dirt or gravel or sand or stone then
mine block
end
it would take up more inventory space but would collect a wider range or minerals

other than that looks like a nice script
GeorgeK #14
Posted 20 September 2012 - 07:33 PM
I have one suggestion. Instead of looking for a specific mineral tell it what not to collect.

example
if not dirt or gravel or sand or stone then
mine block
end
it would take up more inventory space but would collect a wider range or minerals

Oh, my bad. The video only shows it searching for one ore, gold. In the vid the command "autominer 10 1" is run. The one signifies the number of slots it's supposed to use for comparison.

other than that looks like a nice script

Thanks :)/>/>

Cheers,
George