Flower is Beautiful

Flower is beautiful... it really and truly is.


As a previous article may have hinted, I've been playing a lot of Uncharted. I finally got to the part where you start fighting mutated Nazi zombies in a poorly lit World Ward II era bunker and the game went from fun and adventurous to downright scary. I decided I needed a game that wasn't quite as... heavy, to break up the zombie Nazi killing marathons.s Having recently read the Ars Technica review of Flower I figured I would give it a shot.

I layed out my 11.29 USD, downloaded it from the PlayStation store and have been very happy with my purchase. All in all, Flower is beautiful, a joy to play and definately worth checking out. If you have a PS3, I would highly recommend giving it a shot and if you don't have a PS3... (I was going to make a joke about breaking and entering, but tha's going a little far just to play a video game).


... if three quarters of the way through Flower I have to start killing mutated Nazi zombies I'm going to frigging scream!

Guns, Bullets and Uncharted

I've been playing Uncharted: Drake's Fortune recently and so far it's a really fun game... but, the balance of the weapons has been really irking me.

You Start with a 9mm...

You start out with a generic 9mm pistol which seems to take 3-5 body shots to kill a bad guy with. Yikes! Meaning that instead of doing what actual people who shoot at people (cops, soldiers, etc.) are trained to do (center of mass shooting) you end up peering around corners trying to get head shots while your enemies shoot you in the face (thankfully your character appears to be even more nigh invulnerable than the bad guys).

Then You Get an AK-47

That iconic Soviet assault rifle, which holds more bullets than your 9mm, still takes 3-5 body shots to kill a bad guy and will run out of ammo a lot faster if you carelessly hold down the trigger.

For some insane reason, it's actually harder to get head shots with the AK than with the 9mm, so I found myself fighting with the pistol because I would at least have a chance of taking out a bad guy with a single shot rather than spraying bullets all over the place (that's right, the shoulder mounted rifle is less accurate than your pistol because... it's crappy and Soviet *shrug*).

... And Finally a One Shot Kill

... and it's a Desert Eagle .50AE (well actually the first one hit kill you come across a .44 Magnum but I have more rant material for the Desert Eagle and in terms of ballistics they are largely equivalent). This is the classic shooting game, hit them in the knee and they fly back a meter or two an fall the ground dead style of one-hit-kill weapon. Fun, but seriously, why a Desert Eagle?

Yes, I know that both Bullet Tooth Tony and The Agents use them, thus, they must be totally bad ass, but seriously they're hand guns.

I get that, when you're making a game, you want a power curve on your weapons so that as the game progresses your character gets progressively more kick-ass weapons; however, why on Earth is a pistol the first weapon you encounter that can reasonably knock someone on their ass the first time you shoot them.

... And Order is Restored... Sort Of

A little deeper in you get a SVD (Dragunova) which is a sniper rifle of Soviet origin, which also has the ability to deliver one-hit-kills. So at least one rifle is able to out perform the Desert Eagle, but neither the AK-47 nor the M4 (which is black, futuristic looking and American, thus, better than the Soviet piece of shit (... or the the AK at least)) manage to do so, each requiring multiple body shots to disable your opponents.

Pretty Graphs

I pulled together the ballistics data from the Wikipedia for the:

... and plotted muzzle energy, muzzle velocity and projectile mass.

The muzzle energy of various rounds.

The muzzle energy of (in Joules) 9mm, .50AE, 7.62x39mm and 7.62x54mmR rounds.

The muzzle velocity of various rounds.

The muzzle velocity (in meters per second) of 9mm, .50AE, 7.62x39mm and 7.62x54mmR rounds.

The projectile mass of various rounds.

The projectile mass (in grams) of 9mm, .50AE, 7.62x39mm and 7.62x54mmR rounds.


You'll notice that the SVD delivers substantially more energy (3939J) than the runner up, the AK-47 (2010J), 96% more in fact. The AK-47 in turn delivers 21% more energy than the next runner up, the Desert Eagle (1666J). Admittedly, the Desert Eagle has a massive round (massing in at 21.1 grams) which does endow it with favourable penetrative characteristics, but the only round which it clearly out performs is the 9mm.

Consequently, why the world of Uncharted seems to treat the Desert Eagle as largely the equal of the SVD and the AK-47 as the equivalent (... or lesser if you consider the fact that you can't hit a damn thing with it) of the 9mm is frankly mystifying. Further exacerbated by the fact that late in the game you begin to encounter "snipers" that use Desert Eagle with laser sights to one-shot-kill you if you stand in place too long whereas the guys will assault rifles can't seem to think of anything better to do than spray bullets randomly.

In Conclusion

My crazy mental model of guns, is that a body shot will pretty much disable anybody, regardless of what you use to shoot them. So seeing the bad guys limp around like I kicked them in the shins after pegging them 2-3 times with an AK, is just kind of crazy. Admittedly, having every gun dole out one-hit-kills could make the game too easy (if the one-hit-kills only apply to your enemies) or too hard (if it applies to your character as well), inject too much realism and make you resort to stealth when you just want to race in and kill people.

The FBI Handgun Wounding Factors and Effectiveness is an interesting read and discusses the use of handguns in combat from the perspective of people who actually rely on them (namely law enforcement officers). One of the interesting observations (when discussing the tactical realities of law enforcement) notes that due to the difficulty of making effective use of handguns in combat:

[...] no law enforcement officer should ever plan to meet an expected attack armed only with a handgun.

A world in which game designers read some Box O' Truth and therefore knew that "rifles are rifles and pistols are pistols" would be a scary place indeed, but at least the uber-weapons would stop being handguns.

Fun Fact

In the 2008-2009 skills competition, Zdeno Chára won the hardest shot competition with a shot registering 105.4 miles per hour. Given the mass of a hockey puck ranges between 156 and 170 grams, the winning puck had approx 173-189J of kinetic energy. Which is just 1 - 10% shy of the muzzle energy of a .22 Long Rifle. Which, I suppose, explains why NHL goal tenders wear so much equipment.

This Program Has Been Tested: It Works Perfectly!

... or at least that's what I was told when I found this implementation of Hello World in C++:

#include <iostream.h>

    cout << "Hello World!";
    return 0;

Stashed away at the bottom of the page in the section "Program Notes" is this helpful bit of information:

This program has been tested, it works perfectly without any errors or warnings.

... and Yet, GCC Complains

You may be wondering to yourself "What on Earth prompted them to include that little tidbit of information?". Even in C++ Hello world should not be too hard to get right:

aaron@athena:~/scratch$ g++ hello.cpp
In file included from /usr/include/c++/4.2/backward/iostream.h:31,
                 from hello.cpp:1:
/usr/include/c++/4.2/backward/backward_warning.h:32:2: warning:
    #warning This file includes at least one deprecated or antiquated
    header. Please consider using one of the 32 headers found in section of the C++ standard. Examples include substituting the <X>
    header for the <X.h> header for C++ includes, or <iostream> instead
    of the deprecated header <iostream.h>.
    To disable this warning use -Wno-deprecated.

... but GCC still complains. The specifics of what it's complaining about are euclidated nicely in this article but gist is that <iostream.h> references Bjarne Stroustrup's original implementation which is only included (if it's included) in modern compiler distributions for compatibility reasons whereas <iostream> is the standardized version which is better, faster, cheaper, more portable and should be used in preference to <iostream.h> whenever possible.

After switching to <iostream> and informing the compiler that we're using namespace std GCC will happily compile and run our simple program:

aaron@athena:~/scratch$ g++ hello.cpp
aaron@athena:~/scratch$ ./a.out
Hello World!aaron@athena:~/scratch$

For stylistic reasons, I'll add an endl at the end of the message, but that's not fatal. Unfortunately, I'm not quite done. As someone who thinks that my compiler might know a thing or two about code, I like to turn on all of the warnings that my compiler is able to give me. Anything that the compiler is worried enough to raise a warning over is probably worth looking into. Compiling with -Wall -pedantic shows us that GCC is still not happy:

aaron@athena:~/scratch$ g++ -Wall -pedantic hello.cpp
hello.cpp:5: error: ISO C++ forbids declaration of ‘main’ with no type

... easily enough fixed, just add an int return type to the main function.

All Fixed Up

After changing the iostream header, adding a namespace declaration, adding a return type and a newline (which is a surprising number of things for "Hello World!" when you think about it) we can now compile with -Wall and -pedantic and GCC won't emit so much as a peep:

#include <iostream>

using namespace std;

int main()
    cout << "Hello World!" << endl;
    return 0;
aaron@athena:~/scratch$ g++ -Wall -pedantic hello.cpp
aaron@athena:~/scratch$ ./a.out
Hello World!

The Moral of the Story

When your students send you email complaining about your implementation of "Hello World" emitting a slew of obscure errors when compiled, posting a note indicating that your program has been compiled and tested and is bug free is probably not the most productive thing you could do.

Learning Python

Here's a collection of free resources for learning python and programming.

Python for Software Development

Python for Software Development which was initially a port of How to Think Like a Computer Scientist from Java to Python. It is forthcoming from Cambridge University Press and will be published in the first quarter of 2009. The manuscript is available for free as a PDF under the title Think Python.

This book introduces computer science from first pricipals and introduces:

  • Variables
  • Functions
  • Recursion
  • Fundamental Data structures (Lists and Maps)

The Python Tutorial

Python has an excellent official tutorial. It covers:

  • The Python Interpreter
  • Python's Flow Control Statements
  • Python's Built-in Data Structures (Lists, Sets, Dictionaries)
  • Python's Modules
  • I/O
  • Errors, Exceptions, Classes, etc.

Dive Into Python

Dive Into Python is an excellent book for learning Python provided you already know how to program. It is published by Apress, but is also freely available online. It covers more advanced topics such as:

  • Introspection
  • Regular Expressions
  • HTML and XML Processing
  • HTTP and SOAP Web Services
  • Unit Testing and Test First Programming
  • Refactoring
  • Functional Programming

Reading Stack Overflow Makes Me Do Strange Things

When browsing Stack Overflow I occasionally find myself doing ridiculous (programming related) things just because some one says something that my insane mind interprets as a challenge.


For instance, after reading "There is no "one-to-one" mapping between XML and JSON..." I though to myself "Sure there is!"

JSON has much less meta-data (or baggage...) than XML generally rendering it more compact and, most importantly, much simpler. So:

<?xml version="1.0" ?>
<eveapi version="2">
  <currentTime>2009-01-25 15:03:27</currentTime>
    <rowset columns="name,characterID,corporationName,corporationID" key="characterID" name="characters">
      <row characterID="999999" corporationID="999999" corporationName="filler data" name="someName"/>
  <cachedUntil>2009-01-25 15:04:55</cachedUntil>

... could instead be written as:

    "time": "2009-01-25 15:03:27",
    "cachedUtil": "2009-01-25 15:04:55"
    "characters": [
            "characterID": "999999",
            "corporationID", "999999",
            "corporationName": "filler data",
            "name": "someName"

... it doesn't capture everything but it has all the data, it's easier to read and it is simple. Unfortunately, to achieve a 1-to-1 mapping from XML to JSON we need to store attributes, namespaces and other nasty XML stuff, but JSON nodes don't have metadata, they just have regular data.

You can; however, represent an Element Node (think DOM) using a JSON dictionary relatively easily. So:

<ant:property name="value" />

... becomes:

    "element": "property",
    "namespace-uri": "http://ant.apache.org/",
    "children" : []
    "attributes": [
        ["name", "value"]

Which means that our previous XML snippet could be represented as:

 "attributes": [["version", "2"]],
 "children": [{"attributes": [],
               "children": ["2009-01-25 15:03:27"],
               "name": "currentTime",
               "namespace-uri": ""},
              {"attributes": [],
               "children": [{"attributes": [["key", "characterID"],
                                            ["name", "characters"]],
                             "children": [{"attributes": [["corporationName",
                                                           "filler data"],
                                           "children": [],
                                           "name": "row",
                                           "namespace-uri": ""},
                             "name": "rowset",
                             "namespace-uri": ""},
               "name": "result",
               "namespace-uri": ""},
              {"attributes": [],
               "children": ["2009-01-25 15:04:55"],
               "name": "cachedUntil",
               "namespace-uri": ""},
 "name": "eveapi",
 "namespace-uri": ""

... and you though XML was verbose. So you can represent an XML document in JSON but you essentially have to store the parse tree. Welcome to Missed the Pointville, population you (or me as the case may be).

I guess the statement stands.