-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathautominer
More file actions
188 lines (174 loc) · 2.66 KB
/
autominer
File metadata and controls
188 lines (174 loc) · 2.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
if not turtle then
print("This program only run in turtle")
return
end
local digit = 80
local slotNum = 16 - 5 + 1
function forward()
while not turtle.forward() do
turtle.dig()
end
end
function up()
while not turtle.up() do
turtle.digUp()
end
end
function down()
while not turtle.down() do
turtle.digDown()
end
end
function back()
if not turtle.back() then
turtle.turnRight()
turtle.turnRight()
while not turtle.forward() do
turtle.dig()
end
turtle.turnRight()
turtle.turnRight()
end
end
function compare()
if turtle.forward() then
turtle.back()
return true
end
for i = slotNum, 16 do
turtle.select(i)
if turtle.compare() then
return true
end
end
return false
end
function compareUp()
if turtle.up() then
turtle.down()
return true
end
for i = slotNum, 16 do
turtle.select(i)
if turtle.compareUp() then
return true
end
end
return false
end
function compareDown()
if turtle.down() then
turtle.up()
return true
end
for i = slotNum, 16 do
turtle.select(i)
if turtle.compareDown() then
return true
end
end
return false
end
function dfsForward()
turtle.turnLeft()
if(not compare()) then
turtle.dig()
forward()
dfsForward()
back()
end
for i = 1, 2 do
turtle.turnRight()
if(not compare()) then
turtle.dig()
forward()
dfsForward()
back()
end
end
turtle.turnLeft()
if(not compareUp()) then
turtle.digUp()
up()
dfsUp()
down()
end
if(not compareDown()) then
turtle.digDown()
down()
dfsDown()
up()
end
end
function dfsUp()
for i = 1, 4 do
if(not compare()) then
turtle.dig()
forward()
dfsForward()
back()
end
turtle.turnRight()
end
if(not compareUp()) then
turtle.digUp()
up()
dfsUp()
down()
end
end
function dfsDown()
for i = 1, 4 do
if(not compare()) then
turtle.dig()
forward()
dfsForward()
back()
end
turtle.turnRight()
end
if(not compareDown()) then
turtle.digDown()
down()
dfsDown()
up()
end
end
print("start...")
for i = 1, digit do
turtle.dig()
forward()
turtle.turnLeft()
if(not compare()) then
turtle.dig()
forward()
dfsForward()
back()
end
turtle.turnRight()
turtle.turnRight()
if(not compare()) then
turtle.dig()
forward()
dfsForward()
back()
end
turtle.turnLeft()
if(not compareUp()) then
turtle.digUp()
up()
dfsUp()
down()
end
if(not compareDown()) then
turtle.digDown()
down()
dfsDown()
up()
end
end
turtle.turnRight()
turtle.turnRight()
for i = 1, digit do
forward()
end