rewrote circle mine to use plans
This commit is contained in:
parent
8546659ae0
commit
5f5e899f6e
56
src/bin/turtle/CircleMinePlan.hx
Normal file
56
src/bin/turtle/CircleMinePlan.hx
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
package bin.turtle;
|
||||||
|
|
||||||
|
import lib.turtle.planner.Plan;
|
||||||
|
import kernel.ps.ProcessHandle;
|
||||||
|
import kernel.ps.IProcess;
|
||||||
|
|
||||||
|
@:build(macros.Binstore.includeBin("Circle Mine Plan", ["cmp"]))
|
||||||
|
class CircleMinePlan implements IProcess {
|
||||||
|
public function new() {}
|
||||||
|
|
||||||
|
public function run(handle:ProcessHandle) {
|
||||||
|
var rings:Int = 3;
|
||||||
|
var skip:Int = 0;
|
||||||
|
|
||||||
|
var p = Plan.newPlan();
|
||||||
|
|
||||||
|
p = p.repeat([Forward], (skip * 3) - 1); // Move to outer ring or stay if none skiped
|
||||||
|
|
||||||
|
for (i in skip...(rings + skip)) {
|
||||||
|
if (i == 0) {
|
||||||
|
p = p.act([Clear(Down), Down, Clear(Down)]) // Move down a layer
|
||||||
|
.subplan(center());
|
||||||
|
} else {
|
||||||
|
p = p.subplan(circle(i * 3 + 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
p.repeat([Back], (rings + skip) * 3 - 1);
|
||||||
|
|
||||||
|
p.begin(handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function circle(radius:Int):Plan {
|
||||||
|
return Plan.newPlan()
|
||||||
|
.act([FullTunnel, FullTunnel, HalfTunnel])
|
||||||
|
.act([TurnRight])
|
||||||
|
.repeat([FullTunnel], radius)
|
||||||
|
.repateSubplan(Plan.newPlan().act([TurnRight]).repeat([FullTunnel], radius).act([
|
||||||
|
TurnRight, Clear(Front), Down, Clear(Front), TurnLeft, TurnLeft, Clear(Front), Up, Clear(Front), TurnRight
|
||||||
|
]).repeat([FullTunnel], radius), 3)
|
||||||
|
.act([TurnRight])
|
||||||
|
.repeat([FullTunnel], radius)
|
||||||
|
.act([TurnLeft, Forward]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function center():Plan {
|
||||||
|
return Plan.newPlan()
|
||||||
|
.act([Clear(Down)])
|
||||||
|
.act([FullTunnel])
|
||||||
|
.act([Clear(Front), Down, Clear(Front), Up])
|
||||||
|
.act([TurnRight])
|
||||||
|
.repeat([FullTunnel, TurnRight, FullTunnel, TurnLeft, HalfTunnel, TurnRight], 3)
|
||||||
|
.act([FullTunnel])
|
||||||
|
.act([TurnRight, Forward, TurnLeft, Forward]);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user