OOP in C with Function Pointers and Structs

In the beginning PyGame book (google around for it) the author presents a text-based Tank Game in Chapter 2 where you select which tanks to shoot and stats accordingly change. It is used as an introduction to object oriented programming. My team at school has to use C to make a video game, but we really want to use OOP-like idioms, and classes really are just glorified structs. However, googling around for how to use function pointers, I never saw a clear way of doing what I wanted: classes in separate source files with static functions. So after a morning of hacking away at it, I figured it out. Here's the source code for the three files:

/* tank.h, the definition for the Tank class */
typedef struct Tank {
/* attributes */
char *name;
int alive;
int ammo;
int armor;

/* methods */
void (*stats)(const struct Tank *);
void (*fire_at)(struct Tank *, struct Tank *);
void (*hit)(struct Tank *);
void (*explode)(struct Tank *);



A small retraction

I have previously said "90% of philosophy is bullshit". I stand by that, but only because there is just so much bad philosophy!

The 10%, though, is pretty good, and it's not necessarily "easy" (as I generalized). Analytical philosophy, the kind that uses, you know, real propositional logic, is pretty decent. The professional philosophers, the good professors, they are formidable people on the intelligence scale (though I wish they'd do work on more important issues like FAI, but that's another issue).

My distaste for philosophy most certainly comes from my over-exposure to simply bad philosophy, with Rand at the head. I've discovered some interesting stuff, though, and I will try to remain faithful to the good brand if I delve more into the topic myself. (As you may notice I use the 'philosophy' tag kind of loosely; I think most people do.) Where I am likely to have issues with individuals is when they have embraced a philosophy as a religion (like I see with Objectivism: it's called a cult for a reason). Where I'm unlikely to have issues is with individuals who have read lots and lots of professional philosophy, understand the (admittedly simple) propositional logic syntax, and don't shrug me off as insignificant and may desire to enlighten me. I seek truth, but I don't pretend to be well-trained and I'm certain I've made many amateur mistakes.

Utility

I'll admit: I'm a utilitarian. But what does that mean, exactly, and why would I advocate others to follow along as well? Why have a morality anyway?

As I mentioned in my previous post, thanks to several areas of science it is painfully clear that we are not masters in our own homes: much of our decisions, much of our actions, function like clockwork. We've pinned down a number of chemicals in the brain that make you feel a certain way, or make you do certain things. We understand how these feelings got there, too, and it's not a flattering picture. All our "noble" feelings are, in the end, products of evolution: a process which only "wants" copies of genes in the next generation. The selfishness lies at the gene level, and looking around at the world we can see evolution doesn't care beyond that, in fact it doesn't even care about happiness or pain or cruelty. It's a "blind idiot god", whose indifference I would also call cruelty through negligence.

The Darwinian view has been around for some time, and it has been befriended by other forces that combine to "biological determinism" (though really, the word "biological" is unnecessary). It's increasingly difficult to actually blame and punish people for their actions, when it's clear why those actions were undertaken and why there wasn't any other choice for that person. It's like blaming a radio for playing bad music, and smashing it to bits when it plays especially bad music. Basically, it has become increasingly clear that humans are machines, and like machines can be controlled with certain forces.

Nosce te ipsum

Know thyself. I don't think any greater piece of wisdom was ever uttered. (And yes, I know the original is in Greek not Latin.)

In its naive form, it means to simply be more introspective and keep track of how you change as the years go by. Acknowledge when you are wrong and when you are right, know how you would react under various conditions, learn to predict yourself.

There is a more profound depth to this, though. Start writing all the things you know about yourself, and you'll sooner or later come upon the phrase "I am a human." Note the phrase is "Know thyself", not simply "Know stuff about thyself", and what better way to know yourself than to know how "you" think? How "you" function? And since you are human, you have other humans to study as well. Not just yourself.