diff --git a/src/bin/turtle/CircleMinePlan.hx b/src/bin/turtle/CircleMinePlan.hx new file mode 100644 index 0000000..7449f7c --- /dev/null +++ b/src/bin/turtle/CircleMinePlan.hx @@ -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]); + } +}