A Better Estimate for the Size of Bad Piggies
Clearly, I am now addicted to Bad Piggies. Well, I’m not actually obsessed with Bad Piggies, I am obsessed with the analysis of Bad Piggies. My first Bad Piggies post looked at the size of stuff. The basic method was to look at the acceleration of objects in the game and assume that the events take place on Earth where the vertical acceleration should be -9.8 m/s2. I don’t think I did the best job.
What did I do wrong? Here is my big problem – I used one block of TNT as the unit of scale. This causes a problem because it isn’t that large. When I go to other levels and draw a line that is the same length as a TNT box, a small error in measuring the length can lead to a much larger error in the accelerations. Let me try this again. Here is another experiment. Basically, I put a whole bunch of stuff on top of two boxes of TNT and then BLAMO. This is the video, in case you want to see it. Maybe this screen shot showing the trajectories of stuff will be good enough.
How did I track those objects? With the free and awesome Tracker video analysis tool, of course.
One of the first things you should do when you start the analysis of a video is to set the scale. In this case, I don’t know the scale. I will just choose something standard. For this level, you can put 10 boxes horizontally in the “build-space”. By putting a box at each end of the space, I can mark the width of this space and call it 10 units.
Now I just need to measure the vertical acceleration of some stuff. Here, the nice thing is that I have nine objects to track. Since they are all in the same video, I don’t have to worry about small variations in the scale. It should work nicely – shouldn’t it?
It seems simple, doesn’t it? Just plot the vertical position of objects and fit a parabolic function to find the acceleration. They said it would be simple. Or better yet, use Tracker and give me a numerical value for the vertical velocity. I can plot that and find the slope the velocity-versus-time graph – which would also give me the vertical acceleration.
Here is a plot of the vertical velocity for the wood-metal box combo that is shot almost straight up.
The velocity data looks very linear with a slope of -9.576 units/s2. Great, right? Actually, not so great. Here is the vertical velocity for one of those sandbags.
Clearly, the acceleration for this sand bag is not constant. To a first approximation, I could say it has a constant acceleration on the way up has a constant value of -16.978 units/s2 and about -2.149 units/s2 on the way down. If the acceleration is not constant, there must be some type of velocity-dependent drag force. Well, actually it could just be a constant drag force that just changes directions such that is always opposite the velocity.
So, it appears out of this whole explosion, I have two objects that appear to have good data for the vertical acceleration. One is a plain wood box and the other is a wood box connected to a metal box. Both seems to have a vertical acceleration around -9.5 units/s2. Here is the vertical velocity plot for these two.
The other objects didn’t give nice results. Either they were sandbags and had some type of air resistance, or they were going too horizontal so that I didn’t get enough vertical data to get a nice fit. Maybe I need some more data. In the previous video, I left the pig alone. Why? Well, when the pig moves, the “camera” moves. If the pig doesn’t move you don’t have to do too much with the changing the coordinate system. But let me try shooting the pig up anyway.
This is a pig that is shot much higher than the previous case. Just for kicks, I decided to plot this motion with python instead of tracker. Here is what you get.
I’m not sure why the fit isn’t a little bit better – but I will proceed anyway. The fit for this data gives a vertical acceleration of -9.642 units/s2. But what about even more data. I ran another explosion experiment in Bad Piggies – but this time I didn’t use any sandbags. I tracked the motion of blocks that went up and then back down. Some of the exploded blocks went off the screen or hit the side of a wall or something. After find these accelerations, I can combine them with my previous block accelerations (but not sandbags). Here is a distribution of the vertical acceleration values.
This data has a mean of -10.03 units/s2 with a standard deviation of 0.916 units/s2. OK. Enough messing around. How big is a box in Bad Piggies? Well, if this is on Earth then the vertical acceleration (without air resistance) would be -9.8 meters/s2. This means that 1 unit (the length of a box) would about 0.98 meters in width. However, if I dropped the two accelerations that gave a value over 11, then the mean of the accelerations would be -9.6 units/s2. This would mean that each block would have a width of 1.02 meters.
In the end, I am going to say that the length of a block is 1 meter. Maybe this is wrong (I suspect it is either 1 or that the game uses an acceleration of 10 m/s2 instead of 9.8 m/s2) but I am sticking with it.
What about these cases with some type of air resistance or something? They appear to have a horizontal acceleration. Let me show you two horizontal positions for two different objects. This is the x-position of a wood block (the blue data) and a sandbag (red).
The blue data is what you would expect for just plain projectile motion. In a classic projectile-motion situation, there is only an acceleration in the vertical direction so that you would have a constant horizontal velocity. Clearly, the sandbag doesn’t follow this rule. Let me show one more example. In the explosion, a wooden box and a sandbag are both thrown to the right at a nearly horizontal angle. Here is the x-position for both of these objects.
The blue data for representing the box seems to also have a constant horizontal velocity. This does not appear to be true for the sandbag. I know this won’t make you happy, but I am not going to look at air resistance just yet. I will try to figure this problem out later. Remember the purpose here is to get a better measure for the scale of things in Bad Piggies.
Energy Stored in TNT
For the very first explosion, I was able to get a “launch” speed for just about every object. This means that I can calculate the total kinetic energy of this Bad Piggies debris. Where did this energy come from? Well, it came from the TNT boxes – there were two in this example. Here is the data that I collected. I am going with the assumption that 1 distance unit = 1 meter.
Where I calculate the kinetic energy with:
What about the units? Here I have the velocity in m/s, but the mass is in units of “wb” or wooden blocks. That means the total energy would be in units of wb*m2/s2 which is not a Joule. I guess I could give a name for this unit. How about bJoules – where the “b” stands for Bad Piggies?
Here the total kinetic energy right after the explosion is about 2,100 bJoules. This would put the stored energy per box of TNT at about 1,050 bJoules. Actually, this would be a lower limit. There could be more energy stored in the TNT since the explosion could give energy to things other than the kinetic energy of the debris.
What about real TNT? Let me just make a rough approximation here. Suppose the box of TNT is actually a three-dimensional box with dimensions 1m x 1m x 1m. Maybe it is a wooden box filled with sticks of TNT. Let me just estimate the volume of TNT in the box at about 0.5 m3. Wikipedia lists the energy density of TNT at 4.6 MJoules per kilogram. If I use a density of 1,654 kg/m3, one wooden box would have 827 kg of TNT per box. That’s a lot of TNT. Of course, that density is the density of a pure TNT, not a stick of TNT.
Going back to Wikipedia, a stick of dynamite isn’t just TNT. But the box clearly says “TNT” on it. Let me just guess that the TNT box has a bunch of sticks of dynamite. If this is the case, the mass of explosive stuff might be as low as 250 kg. Yes, that is mostly a guess. How much energy would be stored in 250 kg of TNT? This would be 1.15 x 109 Joules.
Can I use this to get an estimate for the mass of stuff in Bad Piggies? Yes. So, let me set the two values of energy equal to each other.
That’s some pretty massive wood. What if this is a 3-D wooden box that is 1m x 1m x 1m with the sides on two ends taken off? That would imply that the box is made of four sheets of 1m x 1m wood. Let’s just say the thickness of this wood is 10 cm, just for fun. This would give an approximate wood-volume of:
With the mass and the volume of the wood, I can get an estimate for the density of wood in Bad Piggies.
This is crazy high for a density. If you think about wood, most wood floats in water (like ducks and witches) so that they would have a density less than 1,000 kg/m3.
But what if the box is actually made from real wood? Maybe something like a hard oak with a density of 900 kg/m3? In this case, the box could still have the huge mass that I calculated, but it wouldn’t be in a cubic shape. Let me say that the box is 1m x 1m x L where L is the “depth” of the box that you can’t see since it goes into the computer screen. Let me calculate L.
Just to be clear, a box that is 3 km long would be what we call in science “super long”. Oh, don’t forget that this is just an estimation for a videogame. If this was a better calculation, the length of the wooden box would actually be longer. Remember that I put a lower limit on the energy in a box of TNT.