ayangd 0 Posted November 14, 2019 Share Posted November 14, 2019 Demo in video: https://youtu.be/p_ytIJhMRqc Minimum robot specs: Computer Case (Tier 2) CPU (Tier 1) Memory (Tier 1.5) EEPROM (LUA embedded) Graphics Card (Tier 1) Hard Disk Drive (Tier 1) or Disk Drive and (after assembly) Floppy Disk which the HDD or FD has LUA and mine.lua program in it Keyboard Screen (Tier 1) Inventory Upgrade Geolyzer Mining tool: Iron pickaxe Program usage: mine <facing> <depth> When the robot can't dig down anymore, the robot will ignore the depth and go up. Tips: When the robot is running, don't peek down. When the robot go up, you will block it. And charge it full before usage. Download: wget https://raw.githubusercontent.com/ayangd/oc-automate_everything/master/subprojects/mine.lua mine.lua Quote Link to post Share on other sites
Log 16 Posted November 16, 2019 Share Posted November 16, 2019 Robot can determine the facing using the geolizer. And you can scan 16x16 blocks at a time, as I did. Quote Link to post Share on other sites
ayangd 0 Posted November 16, 2019 Author Share Posted November 16, 2019 (edited) Yeah, I read your code, and I wish I can read russian cyrillic alphabets ._. So, you use the geolyzer to determine the robot facing, by testing scan and break, then scan again, isn't it? And you scan 16x16 blocks by scanning 4 times, isn't it? (Because, I see it's impossible to scan it all at one time as it will scan for 256 blocks, which it exceeds the limit of 64 blocks per scan) I was thinking about just scanning the ore near the robot as if you scan farther away, it will barely distinguish the ore and the stone's hardness, but I see it is +-0.5! Nice. Anyway, thanks for the input there! Edited November 16, 2019 by ayangd Quote Link to post Share on other sites
Log 16 Posted November 16, 2019 Share Posted November 16, 2019 local function compass() local sides = {2, 1, 3, 0} -- links of cardinal points, for raw data local D = nil for s = 1, #sides do if robot.detect(3) or robot.place(3) then -- check for block in front side local A = geolyzer.scan(-1, -1, 0, 3, 3, 1) -- scan blocks around the robot robot.swing(3) local B = geolyzer.scan(-1, -1, 0, 3, 3, 1) for n = 2, 8, 2 do if math.ceil(B[n])-math.ceil(A[n])<0 then -- check the difference between two scans D = sides[n/2] -- set the direction break end end else -- turn if there is no block robot.turn(true) end end return D -- return the direction end local min, max = 2.2, 40 -- minimum hardness selected to capture lead ore from IC2 local border = nil local X, Y, Z = 0, 0, 0 local function scan(xx, zz) -- 8x8 block scan local raw, index = geolyzer.scan(xx, zz, -1, 8, 8, 1), 1 for z = zz, zz+7 do for x = xx, xx+7 do if raw[index] >= min and raw[index] <= max then -- add ore coordinates to list -- coords of the geolyzer will be converted to local coords of robot table.insert(WORLD.x, X+x) table.insert(WORLD.y, Y-1) table.insert(WORLD.z, Z+z) elseif raw[index] < -0.31 then -- if a block with a negative hardness is detected, set the flag to end scanning border = Y end index = index + 1 end end end local quads = {{-7, -7}, {-7, 1}, {1, -7}, {1, 1}} while not border do if robot.move(0) then Y = Y - 1 end for q = 1, 4 do scan(table.unpack(quads[q])) end end Quote Link to post Share on other sites
ayangd 0 Posted November 16, 2019 Author Share Posted November 16, 2019 Well, thanks for translating them for me, tho.... I appreciate that. I will update my code after integrating it to my other code/module. Imagine starting the program again and again, they will always break blocks when starting I'll just pass the robot facing from the command line, or from another program calling this program. So, for now, let it be as simple as it is. Btw, when you scan for like 8 blocks away from the robot, wouldn't it catch some stone as ore? (Sometimes stone can go up to 2.2 hardness by +-0.5 noise.) Quote Link to post Share on other sites
Durex77 0 Posted November 17, 2019 Share Posted November 17, 2019 Ofter your robot do useless turns. For example he is going to break block below it but before doing it he turn left or right. Quote Link to post Share on other sites
ayangd 0 Posted November 17, 2019 Author Share Posted November 17, 2019 I assume that is from my funky code: -- Wrap function inside functions, so they will automatically go back to its initial state. function ru(fu, ar) robot.up(); fu(div(ar)); robot.down(); end function rd(fu, ar) robot.down(); fu(div(ar)); robot.up(); end function rl(fu, ar) robot.turnLeft(); fu(div(ar)); robot.turnRight(); end function rr(fu, ar) robot.turnRight(); fu(div(ar)); robot.turnLeft(); end -- Forward function moved below! function rb(fu, ar) robot.back(); fu(div(ar)); robot.forward(); end And also, I forget to put `local`s on every variables in the code. It's been a while since the last time I touch LUA. Well, I'll use other way to overcome this inefficiency.. Thanks for the input Quote Link to post Share on other sites