Author Topic: Simple mining bot restarter  (Read 28070 times)

Qon

  • Full Member
  • ***
  • Posts: 112
    • View Profile
Simple mining bot restarter
« on: October 06, 2013, 02:21:33 pm »
*Spoiler alert for those of you who haven't gotten a mining robot yet*


Place a atomiq qompressor on the ground and the qomputer voxel on top. The qomputer should qontain 4 xr1 mining bots.

I usually stand on the qomputer and go afk. If you do not stand on the voxel and instead afk on ground level then the qomputer will dig so deep that it will be out of range and it will stop when it reaches the edge of draw distance. It qan be left for 8h~ if you start it at ground level (y==0) and then when it reaches an depth were you get other materaials it's storage qapacity will be filled so it will stop. If if you want to qontinue just pick up the qontents of the qomputer and it will qontinue digging. Then a few more hours of digging is possible but you'll have to stop it yourself beqause of reasons that you qan disqover for yourself. I haven't gone much further down than about -640~ish myself. I'll do it when I'm finished with my sqripts :)

Make a water elevator (before mining) to get up again fast. And put some water at the bottom of the shaft so you qan jump down safely.
Code: [Select]
//Simple mining robot restarter

state <-0;
i <- 0;

function Voxel_Step()
{
    local q;
    switch (state)
    {
        case 0:
            if (!Move(5)) {
                state = 1;
            }
            break;
        case 1:
            while(PullVoxelFrom(5)) {} // Pull all voxels from the atomiq qompressor
            state = 2;
            break;
        case 2:
            if (GetQuantity(153)==4) { // If all mining robots are picked up then we are move to the next step
                state = 3;
                i=17;
            } else { // Else go back and qontinue pulling materials
                state = 1;
            }
            break;
        case 3: // The qompressor is empty and all mining bots are in storage so its safe to dig down.
            PickVoxel(5);
            Move(5);
            i--;
            if (i<=0) {
                state = 4;
            }
            break;
        case 4: // We are now at the bottom of our mining shaft, place the mining robots
            for(q=0;q<4;q++) {
                PlaceVoxel(q, 153);
            }
            Move(4);
            state = 5;
            break;
        case 5: // Place the atomiq qompressor between the mining bots
            PlaceVoxel(5, 49);
            state = 6;
            break;
        case 6:
            if(PullVoxelFrom(5)) {
                state = 7;
            }
            break;
        case 7:
            state = 0;
            break;
        case 9001:
            Display( "ROBOT AT " + GetX() + "," + GetY() + "," + GetZ() + " Err: " + error, 1000, 2, 0);
            break;
    }
}
So there's some useless lines (still works perfeqtly) there but I don't want to rip them out without testing and risk giving you some silly syntax error q:

This is a rather slow way of getting materials, I'll post some more useful qode later.
Leaving it over night still gives you a lot though q:

Edit: You qan save and restart at any time except while it is digging down to start over the cyqle. If you do it then it will sqrew up the "i" variable. If you want to stop then just empty the qomputer of all materials (do that first or you lose everything in it) and pick it up. Then just wait until all the XR1's are done.
« Last Edit: October 06, 2013, 02:36:25 pm by Qon »

olive

  • Administrator
  • Full Member
  • *****
  • Posts: 149
    • View Profile
Re: Simple mining bot restarter
« Reply #1 on: October 06, 2013, 07:58:25 pm »
Nice program and very good idea!

The Blackvoxel Team

Toupie

  • Jr. Member
  • **
  • Posts: 62
    • View Profile
Re: Simple mining bot restarter
« Reply #2 on: October 11, 2013, 08:15:27 pm »
Hey Qon. I liked your script so much that I improved it a bit.

You can now save and restart at any time now. No variable used to store how far down the computer should dig before placing the robots and the compressor. Instead it looks for the floor that the robots dug to before.
Configurable robot types: Just change Robot <- 153; to the value for the robot you want to use.
Optional: build a simple spiral staircase around the center while it digs down.
Optional: Limit how deep you want it to dig. MaxLevel <- -608;

Code: [Select]
//Simple mining robot restarter

state <- 0;
Time <- 0;
MaxLevel <- -608;     // Don't place robots deeper then this. There is nothing interesting below it.
ReturnLevel <- 0;     // Return to this level (0=The level the robot was started at.)
Robot <- 153;         // The VoxelType of our robots
Compressor <- 49;     // The VoxelType of the Atomic Compressor
BuildStairs <- 1;     // 0=Do not build stairs, 1=Build Stairs

function Voxel_Step()
{
    local i,j,v,q;
    local b;

  if (Time == 0) {
      Time = GetGameTime();
      if (ReturnLevel == 0)
        ReturnLevel = GetY();
  }

  if ( (GetGameTime() - Time) > 10 )
  {
    Time = GetGameTime();
  } else {
    return;
  }

    switch (state)
    {
        case 0: // Start up state. Try to figure out what to do
            if (Look(5)==Compressor) { // Are we on top of a atomic compressor, Start at the begining.
                state = 10;
                break;
            }
            if (GetQuantity(Robot)==4) { // We have all out robots.
                if (GetQuantity(Compressor)==1) { // and our compressor. Find a place to place them
                  state = 30;
                  break;
                }
            }
            Move(5); // Move down if we can
            log_err("Waiting for atomic compressor");
            Time = Time + 5000;
            break;

        case 10:  // Main state. Waiting for all the robots to finish there work.
            if (Look(5)==Compressor) {
                while(PullVoxelFrom(5)) {} // Pull all voxels from the atomic compressor
                if (GetQuantity(Robot)==4) { // If all mining robots are picked up then we are move to the next step
                    state = 11;
                }
            } else {
                // Something is wrong. Inform and restart
                log_err( "No Atomic compressor found. Restarting." );
                Time = Time + 5000;
                state = 0;
            }
            break;
        case 11:
            if(!PullVoxelFrom(5)) { // Make sure the atomic compressor is empty
                state = 12;
            } else {
                state = 10;
            }
            break;
        case 12:
            PickVoxel(5);
            if (GetQuantity(Compressor)==1) { // Make sure the atomic compressor is on board
                state = 30;
            } else {
                // Computer storage is probably full.
                log_err("Storage full?");
                Time = Time + 5000;
                state == 10;
            }
            break;

        case 30: // The compressor and all mining bots are in storage so its safe to dig down.
            if (GetY() < MaxLevel) {
              state = 100;
              break;
            }
            v = Look(5);
            b = GetVoxelProp(v,0)
            if (!b) { // If voxel below is solid, pick it.
                PickVoxel(5);
            }
            Move(5);
            state = 31;
            break;
        case 31:
            // Check if we have hit bottom
            i = 0;
            for (j=0; j<4; j++) { // Count the number of solid voxels on our sides
                v = Look(j);
                b = GetVoxelProp(v,0)
                if (!b) {
                    i++;
                }
            }
            if (i>2) { // We have hit bottom
                state = 35;
            } else {
                state = 30;
                if (BuildStairs == 1)
                  state = 32;
            }
            break;
        case 32: // Build stairs
            v = GetFirstNormalBlock();
            state = 30; // Next state is 30 unless we say otherwise
            if (v>0) {
                i = ((GetY() % 8) + 8) % 8;
                j = i / 2;
                if (i%2 == 0) {
                    PlaceVoxel(j,v);
                } else {
                    // Need to move to place the voxel. So deferre the placement to next step
                    if (Move(j)) {
                      state = 33;
                    } else {
                      if (Move((j+1)%4)) {
                        state = 34;
                      }
                    }
                }
            }
            break;
        case 33:
            v = GetFirstNormalBlock();
            i = ((GetY() % 8) + 8) % 8;
            j = i / 2;
            if (v>0)
                PlaceVoxel((j+1)%4, v);
            Move((j+2)%4); // Move Back
            state = 30;
            break;
        case 34:
            v = GetFirstNormalBlock();
            i = ((GetY() % 8) + 8) % 8;
            j = i / 2;
            if (v>0)
                PlaceVoxel(j, v);
            Move((j+3)%4); // Move Back
            state = 30;
            break;
        case 35:
            Move(4); // Move up one so we are above the bottom
            state = 40;
            break;

        case 40: // We are now at the bottom of our mining shaft, place the mining robots
            q = GetQuantity(Robot);
            if (q > 0) {
                q--;
                PickVoxel(q);
                PlaceVoxel(q, Robot);
            } else { // Mining bots placed
                Move(4);
                state = 50;
            }
            break;

        case 50: // Place the atomic compressor between the mining bots
            PlaceVoxel(5, Compressor);
            state = 60;
            break;
        case 60:
            if (Look(5)==Compressor) {
                state = 10;
            }
            break;

        case 100: // Done. Walk back up
            if (GetY() >= ReturnLevel) {
              state = 101;
              break;
            }
            v = Look(4);
            b = GetVoxelProp(v,0)
            if (!b) { // If voxel above is solid, pick it.
                PickVoxel(4);
            }
            Move(4);
            break;
        case 101: // Inform that we are done.
          log_err("ALL WORK DONE!");
          Time = Time + 15000; // only spam once every 15 seconds
          break;
    }
}


function GetFirstNormalBlock()
{
  local a;
  for (a=1; a<=10; a++)
  {
      if(GetQuantity(a)>0)
      {
          return a;
      }
  }
  return 0;
}

function log_info(msg)
{
    Display( "Robot at " + GetX() + "," + GetY() + "," + GetZ() + " Info: " + msg, 1000, 4, 0);
}

function log_err(msg)
{
    Display( "ROBOT AT " + GetX() + "," + GetY() + "," + GetZ() + " Err: " + msg, 2000, 4, 2000);
    Time = Time + 2000;
}

I have tested this script pretty extensively, so it should be fairly stable.
I'm currently working on a version where one computer will handle 4 (or more) compressors with 4 diggers each.

Qon

  • Full Member
  • ***
  • Posts: 112
    • View Profile
Re: Simple mining bot restarter
« Reply #3 on: October 11, 2013, 09:45:29 pm »
Thank you for the improved qode, I'll try it out!
I was thinking of improving it but I'm making another mining sqript that uses the qomputer as the mining unit without any mining bots used at all. The reason is that it's faster and I qan also build fraqtals at the same time with the same qode :)

Though if you want real efficiency and speed mining then the ability to keep track of many atomiq qompressors with mining bots beats that. Please post it when it's done! I would have made it myself if I had the time but I have other sqripts waiting to be finished and I already have enough materials atm q:
If it qan handle n atomiq qompressors then the "//Simple mining robot restarter" qomment should be modified.

Nice touch with the spiral stairqase, I did not think of that. I spent so much time on building tunnels before xD
Though a water elevator is necessary if you want to get up from Blackrock Pink in reasonable time and also with 0 effort if you put something on spacebar.

And there's more below -608 ;)

Toupie

  • Jr. Member
  • **
  • Posts: 62
    • View Profile
Re: Simple mining bot restarter
« Reply #4 on: October 11, 2013, 09:55:42 pm »
Yea, when and if it will handle more then one compressor and 4 robots I agree "simple" is probably not correct anymore :)
The staircase this script builds is pretty much useless. I just posted another script that builds much more useful stairs. But the water elevator is by far the fastest way to get back up. (thou I have had problems with it becoming empty all of a sudden for some levels).
Yea, I know there is more below -608, but from a point of just mining for resources I haven't found anything that you need to go below for. But it's configurable so you can just make it go how far as you want.
I haven't done much building of shapes yet. Just been exploring and gathering resources to be able to craft the more advanced robots and the airplane. The amount of resources the are needed to be able to make the more advanced stuff is really high. I have only build ONE programmable computer yet. Takes forever to make one.

Qon

  • Full Member
  • ***
  • Posts: 112
    • View Profile
Re: Simple mining bot restarter
« Reply #5 on: October 11, 2013, 10:18:10 pm »
To be able to mine down to y==-608 you need to handle when the storage of the qomputer is full. It will fill up if you aren't there to pick up the blackrock qolors and qopper ore that you've passed and then it will stop in an endless loop. Well, another feature to look forward to ;)

Qon

  • Full Member
  • ***
  • Posts: 112
    • View Profile
Re: Simple mining bot restarter
« Reply #6 on: October 12, 2013, 01:38:13 am »
Why -608? There's nothing in the white blackrocks and if you use high level extraqtion bots (XRZ digs 64 voxels deep) you will go through the floor. I use -575 instead. Thinking of going deeper. And if you need qopper, lead ore and x-material you will get them below -640 again (and qopper is rare since it only exist in the top layer).
Took some sqreenies of my experiment:

Toupie

  • Jr. Member
  • **
  • Posts: 62
    • View Profile
Re: Simple mining bot restarter
« Reply #7 on: October 12, 2013, 03:56:02 am »
Doh. I totally missed that there was no ore in the BlackRock White starting at -577. I'm still using the first Dig Robots since the more advanced takes so long to craft. I haven't left it alone long enough to fill it's inventory yet. Got plenty of copper from the top BlackRock Blue layers.

Argggh. I hit -1345 and lost my computer.  :(

Qon

  • Full Member
  • ***
  • Posts: 112
    • View Profile
Re: Simple mining bot restarter
« Reply #8 on: October 12, 2013, 11:04:42 am »
Ouch! Well, next time don't save after you destroy it.
Just kill the process or qlose the BV terminal window q:

Toupie

  • Jr. Member
  • **
  • Posts: 62
    • View Profile
Re: Simple mining bot restarter
« Reply #9 on: October 15, 2013, 12:54:19 am »
The Not so Simple Mining Bot Script is starting to take shape.

Maybe this is to powerful!!! The only limit to how many compressors+Robots it can handle is the limit of how large area of the world the game has loaded at any one time.

This is it running with 17 Atomic Compressors and 64 XR-1 Robots.

Toupie

  • Jr. Member
  • **
  • Posts: 62
    • View Profile
Re: Simple mining bot restarter
« Reply #10 on: October 15, 2013, 01:01:23 am »
30 minutes of running the script and I have some stuff in the Atomic Compressor at the edge on top.

Qon

  • Full Member
  • ***
  • Posts: 112
    • View Profile
Re: Simple mining bot restarter
« Reply #11 on: October 15, 2013, 01:06:17 am »
That is awesome! When is it ready for release? :D

Have you tried it with the XRZ? xD

Toupie

  • Jr. Member
  • **
  • Posts: 62
    • View Profile
Re: Simple mining bot restarter
« Reply #12 on: October 15, 2013, 02:08:54 am »
Yes, I have tried it with XRZ, but I didn't know they where mining 16 blocks wide instead of 8 as the XR-1 and XR-2 do.
But the XRZ is to fast the the script to keep up with.
I also tried how many compressors and robots it can handle. I tried 257 Compressors and 1024 robots. But it ran outside the loaded area already after 8 compressors in one direction. So I need to be standing in the middle for it to work with my 16*16 (256) compressors. Oh, and it also ran outside the Central Blue Plain, so the entire dig site was flooded with water.
I also noticed that digging a hole at location 0,0,0 is a very bad idea. If you die you end up in an infinite death loop.

The script builds in +X and +Z direction from where it start. Maybe I need to modify it so it builds equally in both + and - direction so your starting point is the center. Otherwise 8*8 is the practical limit. But even that is an impressive 64 compressors and 256 Robots.

For when it's done. Well, the complexity of a script always increases exponentially as factor of the number of lines it is. And I have still not found a way for it to save it's state. So it will not work after a load.

Qon

  • Full Member
  • ***
  • Posts: 112
    • View Profile
Re: Simple mining bot restarter
« Reply #13 on: October 15, 2013, 02:37:34 am »
How qan it be too fast? The XRZ takes like 2 mining and 2 min pushing to storage. That is 4 minutes that the qomputer have to pull material and restart the mining bot 64 blocks down. It's only 16 blocks to the next qompressor and the qomputer moves at speed that is decent enough for this, right? Also the qmoputer voxel qan pull all 64 000 voxels from the storage qompressor in 1 frame so it has 4 whole minutes to restart and move to the next. The XRZ is like 80 times (!) as fast as the XR1 so even if it qant qeep up with as many XRZs as XR1s it isn't really a problem, right?

Toupie

  • Jr. Member
  • **
  • Posts: 62
    • View Profile
Re: Simple mining bot restarter
« Reply #14 on: October 15, 2013, 07:20:52 pm »
I did my test with 16*16 compressors and 1024 XR-Z, and the Computer have to move 33 voxels (+32 X and +1 Z) between placing every robots/compressors since the XR-Z mines an area of 16*64*16. The Computer also needs to move back up to empty it self into what I call a Master Compressor, and that will take longer and longer the further down you go. I've implemented a feature for it to place new Master Compressor every X levels (configurable). But it was able to place around 25-30 compressors before the first robots had finished.

Seems on Windows the game has 3*64 levels loaded below the player. Didn't really understand what Olive talked about changing how much is loaded, but he said that on windows you couldn't load any more then default. (But my BlackVoxel app only uses 1,5 GB of memory, so it still has room for another 2 GB if it is Large Address Aware.)
So if you don't go down with the computer, it will only mine down 3*64 levels. But you could just stand inside the area that is mined and you will follow it down.

I'm seriously beginning to think this script is to powerful. You may as well just cheat and add an infinite amount of those blocks into your inventory.

My script in action with 64 compressors and 256 XR-1 Robots.