Quarrying with ComputerCraft Turtles

I just recently began playing with ComputerCraft, which is a very cool Minecraft mod that adds programmable computers.   There are also turtles, which are basically computers that can carry out tasks like mining, digging, attacking, etc.  Turtles are fully programmable using Lua and various APIs.  You can do lots of amazing things with turtles.

This is not something amazing, but just a simple modification I made to the turtle's excavate program that allows you to dig stepped quarries giving easier retrieval of the ores around the edges:

9x9 excavate:

excavate14x14x3 quarry:quarry

 Source. You can copy this script directly to your turtle using the turtle's pastebin program.

To dig a quarry, you specify the diameter and the number of blocks to dig down at each diameter, .

It's a fun exercise to work out some of the properties of the resulting quarries.  Given a and , you can dig a quarry that is blocks deep, where if is even and if is odd.  The total height of the quarry is related to the number of constant-diameter levels, by .

Given a and , the total number of blocks you mine in a quarry, , is found by simply adding up all the blocks at a given level and then adding all the levels.  Noting that decreases by two blocks each time you make the quarry square smaller,

where is related to .   Writing this in summation form,

where .  Now, the summation bit is straightforward to see, but the upper limit took some playing around in Mathematica for me to work it out.  This seems to work pretty well, but if anyone can derive this limit (or a better one) more "rigorously", please let me know!

The real goofy vs. regular: A look at skateboarders in the SPoT database

In board sports, riders are "goofy" stance if they lead with their right foot and "regular" stance if they lead with their left. These terms seem to imply that one way is more "correct" or common than the other. I'm goofy, so I'd like to know just how goofy it is to be goofy. It turns out, a little bit goofy.

I checked out the Skatepark of Tampa (SPoT) skateboarder database, which has been maintained for 12 years and is probably the most extensive and detailed online.  The database consists of professional and amateur skateboarders who've been to SPoT for some reason or another.  Given that SPoT has been host to two of the largest annual contests in skateboarding since the mid 90's (the Tampa Pro and the Tampa Am), you can bet that the best have been through the doors. Note that in skateboarding, the term amateur (or am) doesn't necessarily imply that the person is less skilled than a professional - it only implies that the person doesn't have their name on a product yet.

SPoT Database Statistics

Of the 6,047 profiles examined, 12.6% are pro.   4,030 of these profiles had stance data, of which only 44% are goofy.  I personally find this a bit surprising, as I assumed it would be closer to 50%.  To put it mathily, a chi-square test indicated that the difference from 50% is statistically significant,   (where is Cramer's ).

Age
Average 22.79
Median 23

Many of the database entries also included age, which is summarized in the table.  Now, this doesn't necessarily mean that the average age of a competing skateboarder is 23 (I think that may be a tad high). To speculate a bit, I'd guess that the database, which has been maintained for 12 years, adds skaters regularly without deleting older ones.  Assuming that most of the ages are updated over time, the database will accumulate ageing skateboarders who aren't actually active anymore.  For more information about skateboarder age, see this Nerdsday Thursday post.

Also, word clouds are really pretty to look at so, why not, here are the most common first and last names in the database:

SPoT DB Common First Names

SPoT_last_namesNothing surprising here, but it does confirm my previous suspicion about the importance of people named "Mike" in the skate industry.  (Or maybe it's just a common name? Who knows, it's a mystery that will never be solved.)

So there we have it, the archetype skateboarder from the SPoT database is Chris Smith, regular, am, 23.  A very interesting follow up would be to see if there is any link between skateboarding stance, footedness in other sports, and handedness.

If statistics gets you pumped up to go skate, you can leave now.  For the other all of you, here's my favorite winning run from the 2011 Tampa Pro, featuring the very goofy Dennis Busenitz:

Minecraft Calculus: River Crossing Escape

This is a classic introductory calculus problem, with a Minecraft theme.  This particular variation is inspired by example 4 in section 4.5 of Stewart's calculus.

I'll set the scene:  You're weaponless.  You have half a heart and you're being chased by a skeleton archer.  There's a river between you and your cabin.  You need to get to your cabin as quickly as possible!

In more "mathy" terms, you want to get from to .  There are three main ways you can do this:

  1. to directly, diagonally across the river
  2. to and then to
  3. At slight angle from to and then to

We know that swimming is slower than running, so option 1 isn't the best.  Option 2 involves the smallest time in the water, but also the longest distance traveled.

Option 3 is somewhere in between - you spend a bit more time in the water, but the total distance is decreased.  The travel time in this case depends on where exactly point is.  To find the optimal path, we must find the position of which minimizes the travel time.  This sounds like calculus!

Let be the distance between points and .  In math terms, .

We first need an expression for the total time traveled in terms of .  The basic equation for time traveled at constant speed is

.

The first part of the trip is in the water where we travel from to .  We can use Pythagorean's theorem to get this distance as .  Assuming that we can travel at a speed of in the water, the time for this part is

.

The land part of the trip involves traveling what's left over of after having already traveled , so .  Traveling at on land, the time for this part of the trip is

.

The total trip time, , is just the sum of these two.

     (1)

To optimize this function with respect to , we need to find where it is stationary and then verify that this point is a minimum.  This means we want to find a place where the function isn't changing with small changes in .  In other words, we want to find a spot where the derivative is zero.

Taking the derivative gives:

Setting this equal to zero, we can solve for :

     (2)

Let's plug in some numbers!  In Minecraft, you can swim at about 2.2 m/s and sprint at 5.6 m/s.  Let's take the river width to be 7 blocks (1 block = 1 meter).  Plugging in, we find that .  At this point, though, we can't tell if this is a maximum or a minimum.  One way to find out is to examine the curvature of the function at this point by using the 2nd derivative:

Plugging in , we see that which, being positive, means that is a minimum point for .  Visually:

crossing

 

So if you want to get to your cabin as quickly as possible, the fastest route is to swim across the river to a point that is 2.9 meters from point and then run the rest of the way.

This is actually a general problem.  Try replacing the speeds I used with speeds for soul sand, crouching and walking, a boat, etc. and see what happens!  Particularly, what happens to (2) if you can travel more quickly in the water than on land?

 

Scratch Work

Finding  First, rewrite the square root as a power, 

Differentiating, using the chain rule on the first term,  

Finding  Starting with , we differentiate with respect to x.  Note that the derivative of with respect to is 0, so we only have to deal with the first term.  Using the product rule and chain rule:

Cleaning up with some algebra: