More thoughts on the Escapist

I’ve talked about the Escapist before. Specifically, when I mentioned I would no longer be visiting their website. My reasons then were essentially practical – they had simply made viewing content more annoying than it was worth.

Recent events, however, are making me re-evaluate that post. In that post, I didn’t really analyze why the Escapist had such awful ads. But now I think it’s worth doing. The most obvious explanation, which was more or less implicit in my earlier angry rant, is that the annoying, screen-filling, content-swamping ads didn’t show up because of incompetent programming or oversight, but rather through a complete disregard for the consumer.

The Escapist (well, Themis Media) is a company. Companies exist to make money. Basic economics. Themis media makes money by selling advertisements; the more advertisements they can get to viewers, the more their advertisements will be worth to advertisers, the more advertisements they can sell, and the more money they make. Again, nothing ground-breaking here, just basic mathematics.

There are two basic ways to get these ads to the eyes of more viewers (and thus up their potential value, increasing profits): show more or larger ads per page, or attract more viewers (to create more page views). As a company that wants to Maximize Profits™, ideally they want to do a whole lot of both of these things.

The problem is that these two goals are counter to each other. The more (or more obvious) ads you display, the more people will start to say ‘too many ads, see you later’. Like I did in my previous post on the subject. The trick, and the thing that most websites eventually figure out, is that there is an equilibrium – a quantity and size of advertisements that will not produce a significant hit on the number of viewers you attract.

Now, the way to actually attract more viewers is to have content that people want to view. And the Escapist has been damn good at this. They have a great deal of very good content, much of which is very popular. They have attracted a lot of grade A talent to work for them. And that may be the problem – they’ve got such good content, their equilibrium point has tipped so far that they can pull off obnoxious full-screen ads without driving away a significant number of users.

However, at some point, the volume of ads you display becomes anti-consumer. There’s a point where you are failing your customers, where suggesting that what you are asking is a ‘reasonable price to pay’ for the content is farcical. Many modern magazines have fallen prey to this: I flipped through a fashion magazine recently, for instance, and counted 12 pages of ads before reaching the table of contents. That’s patently absurd, and what it shows is that the company that produces the product cares more about money than they do about the consumer’s experience.

But all of that was an overly long prelude to what I really want to talk about: Themis is now being accused of being anti-creator as well. Extra Credits, one of the Escapist’s video features, has left the Escapist, with some very troubling accusations about Themis’ payment practices. Basically, the Extra Credits crew says they haven’t been paid for a long time, and that Themis is claiming that Extra Credits owes *them* money from a fund raiser that they ran to keep the show alive (and to finance surgery for their artist).

Now, in fairness, Themis has some counter-claims, which are enumerated at the second link above. However, given Themis’ anti-consumer ad practices, I don’t have much difficulty believing that they might be willing to cheat their creative people as well. Of course, this doesn’t constitute proof of wrongdoing on their part, but it is certainly useful to observe that they already have a pattern of preferring money to delivering a good experience.

Of course, the upshot of all this, for us consumers, is that Extra Credits is no longer encumbered by the horrible pit of a website that is The Escapist. So I watched the most recent episode. Based on this one episode, it seems like a pretty good show: smart and engaging, with enough humour scattered throughout to keep it from feeling dry. They point out a lot of things that may be obvious to (some) people in the industry, but that many individual gamers are unlikely to have ever had reason to consider.

I’ll probably watch it regularly now that I don’t have to risk a stress headache just to watch it.

Leave a Comment

Doctor Who: Night Terrors

As usual with these posts, Spoiler Warning.

Oh, Mark Gatiss, you’ve done it again. You got my hopes up, and then dashed them against the rocky shore of poor plotting.

Let’s start with a recap of Gatiss’ contributions to (televised) Doctor Who: The Unquiet Dead, The Idiot’s Lantern, Victory of the Daleks, and now Night Terrors. So, out of his previous contributions we have one very, very good (and fairly creepy) episode, one that is, for my money, an absolute dud, and one that is a fairly clever idea with a weak execution. Although, to be fair, a Dalek asking “WOULD YOU CARE FOR SOME TEA?” might be one of the greatest single moments in Doctor Who history, and if Victory of the Daleks was conceived around that image, then I forgive it for everything else.

Looking at his track record, I get the impression that Gatiss is at his best when he tries to write creepy stories. The problem is that, with Night Terrors, he is trying to write a creepy story. But try as it might, this story absolutely fails to be creepy. The wooden dolls just aren’t compellingly scary, and the dollhouse doesn’t have the atmosphere of ‘creepy haunted house’ that it needs to make them so. The only time the dolls are ever creepy is the first time we see one – that is, when it is inanimate and standing alone in a closet. The monster is less scary when we can look it in the face, and the longer we hear creepy noises and get suggestions of scary things, the more suspense and tension is built. Here, though, Gatiss fails to build suspense for the monster, so its reveal feels about as frightening as the Slitheen in Aliens of London. Even the build-up to the Silurian reveal in The Hungry Earth was creepier than this episode.

With scary out the window, let’s look at the rest of the episode. This is the first episode since The Doctor’s Wife that isn’t heavily invested in the story arc (even if we didn’t know how tied to the story The Rebel Flesh / The Almost People was, in retrospect we have to count them as fundamentally ‘part of the ongoing arc’ episodes), so I had high hopes for a nice, self-contained, Doctor-to-the-rescue story.

And the opening let me keep hoping. Gatiss writes the Doctor brilliantly. The sequence in which the Doctor and company wander about the tenement has some fantastic dialogue. And every scene with the Doctor interacting with George and Alex is brilliant as well.

But these scenes are interspersed with the dollhouse. And the way the dollhouse is used destroys the pacing and tension of the episode. At the end of the episode, it felt like not very much had happened, and what had happened was inconsequential. The big runaround gets resolved, essentially, by actors coming on stage at the last minute. It’s trying to be a clever twist, but it ends up being an anticlimax.

And the story arc tie-in at the end felt a bit weak, too. I mean, we get some creepy child-like singing that is, presumably, supposed to evoke the monsters that were just defeated. But even if we set aside the fact that they are, y’know, defeated, they have absolutely no apparent reason to know or care about the Doctor’s death. They’re figments of an alien child’s imagination. It felt like that was added just for the sake of having some reminder of the overall story arc. Whether that was added by Moffat or Gatiss, it is a weak bit of storytelling.

One thing it does do is tell us that the storyline surrounding the Doctor’s death will probably be dealt with in series 6, and not carried over to series 7. At least, assuming Moffat is following the contemporary format of series-spanning story arcs; dropping repeated hints about the same plot element almost always means that element will be dealt with in the series finale. Unless, of course, the series finale ends on a cliffhanger. But Doctor Who is uniquely ill-suited to the Dallas-style inter-series cliffhanger, because the Christmas Specials interrupt the dramatic tension period.

There is one other thing I do want to praise about the episode, though: George has a dollhouse, and no one thinks this is odd, or makes disparaging remarks about it. That struck me as a nice nod to gender-neutral parenting.

Next week, we have The Girl Who Waited, which I will admit now I’m not looking forward to, given that the plot appears to be ‘Amy is captured and’. After A Good Man Goes To War, I had really hoped we would be able to stop putting the girl in the fridge quite so often. But it looks like the writers still can’t seem to work that out of their system, so here we go again…

Leave a Comment

Doctor Who: Let’s Kill Hitler

We interrupt our month-long, unannounced, unplanned hiatus to bring you: another post on Doctor Who. That’s right! Because Doctor Who can motivate me to write when nothing else can. So, here we go!

Oh, and Spoiler Warning!. I’ll be discussing the details of Let’s Kill Hitler in this post, as well as speculating on the next plot reveals / bits of continuity that have only been hinted at / etc. So, if you haven’t seen Let’s Kill Hitler and you hate spoilers, or if you prefer to speculate without letting other people’s ideas influence you, then don’t read this post. Otherwise, read on! It’s sure to be fun…

Review

I’ll lead with the most obvious point: this episode was good. Really good. But that’s just what I’ve come to expect from Moffat, so let’s talk about what makes this episode really shine: Moffat repeatedly uses juxtaposition and playing with the audience’s expectations in order to heighten the emotional impact of the story.

There is some really impressive cinematography here. My favourite is that the recap is actively used to set the tone. We start the episode with a pretty intense recap, and then drop into the first shot: a dramatic, colourful, and completely still row of wheat. It flips from reminding you how exciting the show can be to giving you an image that, while visually striking, is also very sedate. It’s effective – it gives the viewer an adrenaline rush, then asks them to reconcile that with wheat. It makes the wheat somehow exciting, all on its own. It takes the image from striking and cranks it up to breathtaking. But we can’t get away from that for long, so we switch to high-speed crop circle off-roading, so the excitement stays in place.

Another trick Moffat uses is turning the episode into a completely different story halfway through. They build this framework: a fun-loving early River incarnation wants to take the TARDIS on a past-wrecking joy ride. Even if you spot that Mels is River, it looks like the rest of the episode is going to involve the Doctor dealing with Mels, and the robot filled with tiny people, and trying not to change the past too much. Instead, the show turns into River Song (the one we know and love) actively trying to kill the Doctor. And succeeding. What starts out feeling like a fun-filled romp of an episode becomes very heavy, and dramatic, and suspenseful. It’s brilliant, and the emotions are, again, heightened by using the audience’s expectations against them.

One more interesting technique: Mels’ introduction. Here we have a new character that Amy and Rory have known all their lives, tossed into the story mid-stream. This is a very interesting sudden interjection, and it feels jarring. As a bit of backstory, it is perfectly reasonable; after all, there are plenty of good friends in my past that don’t really come up in conversation, and I imagine this would be more true if my conversations tended to revolve around temporal paradoxes and saving the world from Daleks. But still, from the viewer’s perspective this seems to come out of nowhere, and I suspect that’s intentional; it has the effect of unbalancing the viewer, giving you a vague sense that something is just slightly out of place, which pays off when Mels is revealed to be Melody.

Reveals / Plot Analysis

So, let’s talk about the reveals, and what they could mean in terms of the ongoing story. First, the Timehead (i.e., the little girl in the spacesuit) is River Song. That’s pretty clearly established at this point: Mels stated that her previous regeneration had been in an alleyway in New York, and had involved becoming a toddler. This lets us establish a loose chronology of events for the life of River Song, which I’ll elaborate on in a bit.

Another thing is the sudden introduction of Mels – as I mentioned above, this seems to be a narrative technique to off-balance us as viewers. However, it could also (simultaneously) be a hint that someone is Meddling with Time*.

On the subject of The Eventual Untimely Death of Rory Williams, this episode gives us another misdirection, “I’m looking for a good man”. I still think that Rory is doomed, however, and my newest bit of evidence is from outside the show itself: the title of the series finale has been announced, and it is “The Wedding of River Song”. Recall that in Flesh and Stone, River said that she killed “A good man, the best man I’ve ever known”. If Rory ends up being best man at River’s wedding (after all, Rory isn’t just her father, he’s also a dear friend she’s known for years. They grew up together!), well, wouldn’t that be interesting?**

Also, we have some very interesting unanswered questions at this point, both new and old. A few that occur to me, and some possible thoughts on them:

  • The most obvious one: What is the question (that will cause silence to fall)? The first thing that popped into my head here was The Question, i.e. “Will you Marry Me?” (or, alternately, “Do you take this man…”). Just like the above theory, it’s a little far-fetched, perhaps. But it would fit interestingly with the wedding theme we’ve had throughout Moffat’s run. I mean, he used “Something old, Something new” as a crucial plot element, so I think it’s a fair possibility here.
  • What is the relationship between the Silence (that is, the creepy faceless aliens) and Kovarian’s alliance? They seem to be working toward the same goal, and it’s easy to assume the Silence (the organization as opposed to the species, unless they are more tightly coupled than we know, a la the Headless Monks) are manipulating Kovarian, but does she know that? Is she working with them intentionally?
  • Why did the Silence kidnap FleshAmy in Day of the Moon? I would have plenty of good theories if it had been the real Amy, but they presumably knew that the Amy they kidnapped was flesh, so why do it? What did they stand to gain from that?
  • Who was in the spacesuit on the beach? It seems less and less sensible that it should be River. Everyone believes the Doctor dies on that beach. It’s even a fixed point in time according to the tiny men inside the time-travelling robot. However, Mels clearly thinks she still needs to kill the Doctor – surely she would remember doing it on the beach, and assume his death was inevitable, right? So why does she try to kill him in Let’s Kill Hitler? Is that an adult River, her kill-the-Doctor programming becoming impossible to resist? Or is it someone else entirely?
  • How long does it take Alex Kingston to get her hair looking that fantastic? I’m cursed with the unmanageable nightmare that is curly hair, and I really wish I could make it look half that good.

Timeline of a Timehead

There’s decent evidence that River only regenerates twice, i.e. has three incarnations. The evidence is as follows: We can surmise that the little girl in the spacesuit is Melody (the first body of River Song), because, well, she seems really childish. She is clearly very scared and confused; she doesn’t seem to be any older than she actually appears here. I’m taking this as evidence that this is her first incarnation. We know that incarnation turns into Mels, because of the line “last time I did this, I ended up a toddler in the middle of New York”. And, well, in Let’s Kill Hitler she regenerates into the River we know and love, and we know that is her last incarnation, because we’ve seen her die.

So, with that evidence in hand, here’s an outline of the Timehead’s life in chronological order. There may easily be gaps where all sorts of interesting and story-relevant things happen in between many of these points, and some of the ordering and events are admittedly speculative:

  1. Melody Pond is born on Demon’s Run.
  2. Madame Kovarian secrets Melody away to an unknown location.
  3. Melody comes to live in Graystark Hall Orphanage, which is infested with Silence.
  4. Melody is put into a spacesuit in which she may or may not kill the Doctor. She definitely has the encounter in the warehouse though.
  5. Melody sneaks away from the orphanage, going to New York (somehow) at this point.
  6. Melody regenerates into Mels, possibly as the result of a bullet wound inflicted by Amy.
  7. Mels comes to live near Amy and Rory, grows up with them, gets into lots trouble, and is obsessed with the Doctor.
  8. Mels meets the Doctor, and the events of Let’s Kill Hitler occur. She regenerates into River, and gives the Doctor the rest of her life essence.
  9. River becomes a doctor of archaeology.
  10. River and the Doctor get married.
  11. River Song kills her father, Rory Williams.
  12. River is imprisoned at the Stormcage Containment Facility.
  13. At the end of the battle of Demon’s Run, River shows up and reveals her identity to the Doctor, Rory, and Amy.
  14. The Impossible Astronaut / Day of the Moon.
  15. The Pandorica Opens / The Big Bang.
  16. The Time of Angels / Flesh and Stone.
  17. The Doctor takes River to the Singing Towers of of Darillium, gives her the sonic screwdriver.
  18. River Song dies on the library planet.

If anyone sees any obvious, provable errors, please let me know, and I’ll edit the post!

* note that I am not claiming The Monk is involved in this story arc. It simply amused me to link to that story when using that phrase.

** This theory is somewhat tongue-in-cheek; as evidence goes, I realize it’s pretty weak. But that quote came back to me when I read the title of the final episode, and I couldn’t help but speculate.

Comments (2)

Project TreeWars: How Anna got her Title Screen back

In my last post, I re-implemented all of my rendering code to take advantage of Shaders. After doing this, nothing rendered. Despite the fact that I was following a tutorial, more or less. I have been modifying it to fit my project, which has a lot of code around the rendering code already and is in C++ instead of C, and also modifying it to do something that will actually be useful for me down the line.

But, at any rate, I’ve checked every function call I make against the ones used in the tutorial. They all match. Everything is exactly the sa…

Oh. Wait.

One of the things you create when using shaders is an index buffer (also called an element buffer); a list of what order the vertices of your polygon should be drawn in. From the tutorial:

static const GLushort g_element_buffer_data[] = { 0, 1, 2, 3 };

And the equivalent line from my code:

GLfloat Renderer::rect_elements[] = {0, 1, 2, 3};

I got so used to things being GLfloat type that I made my index buffer floats, even though that doesn’t make any sense (you can’t have vertex number 0.5, after all). Not only does it not make sense, OpenGL requires that the element buffer be composed of integers. Even better, if your element buffer is of the wrong type, OpenGL fails silently: no error message, no crash. The rendering simply doesn’t happen.

So, a couple hours of debugging, down to one simple line of code. I really wish GLSL had a way to report meaningful errors back to the program using it. At any rate, after I fix the line:

I’m back to where I was several days ago. But this time, I’m using shaders, which are both less deprecated and more flexible; I’ve set up a framework that will allow me to do more interesting things later on.

Now, on to the next challenge: rendering text. In SDL this was fairly easy; the SDL_ttf library made it pretty simple to render text to the screen. In OpenGL, however, rendering text is a bit trickier. There are a few libraries out there that do it (FTGL seemingly the best option), but they all use the fixed-pipeline functions. I’d even be willing to settle for that, and worry about ripping the code out later and putting in something more shader-friendly, except switching back and forth between Shaders and the fixed pipeline seems to be a bit tricky.

So, my options are:

  1. Figure out how to switch ‘out’ of the Shading pipeline properly and render text with FTGL, or
  2. Use freetype2 directly and implement my own font loading, render the text to a Framebuffer Object, then blit that to the backbuffer (the buffer that represents the next visual frame).

The first option might be easier in the short term, but the latter sounds more robust, all things considered. The problem is that stopping to get font rendering working without any deprecated functions could take quite a while (I’m not even sure on a good estimate for the time). So, I hack FTGL into working and move on.

Now, I’m ready to get things back to the way they looked before I decided GLSL was something that needed to happen. I just need to figure out the best way to draw a circle with GLSL…

Comments (3)

Puzzle Log: Dante Shepherd’s twitter puzzle

Puzzling – that is, solving puzzles recreationally – is a hobby of mine. I enjoy it immensely, although I enjoy some puzzles much more than others. I enjoy the sorts of puzzles that involve both intuitive leaps and a combination of generalized and specialized knowledge. The sorts of puzzles that happen at the MIT Mystery Hunt are probably the best examples of puzzles I really enjoy (and, indeed, I had a lot of fun at my first Puzzle Hunt this year).

So, in the tradition of Solving Really Hard Puzzles, I’ve decided to post logs of some of my puzzling efforts here. These may only be of interest to a very few people; feel free to ignore them if this is not up your alley.

Today’s puzzle is one that Dante Shepherd posted on twitter in this tweet. Puzzles that are simply an encoded string of characters always intrigue me, so I dived right in. It took me about half an hour to solve, and it was a lot of fun. I created a log of the process by simply periodically noting the time and writing down my thoughts, especially when I got somewhere new, such as the aha moment at 15:00. In the future, I may look for (or create) some software that will make logging a bit easier.

Also, here is the original puzzle, for the link-averse:

L 45, R 270 L 225, R 270 L 225, R 180, L 90, R 270 L 225, R 270 L 90, R 225 L 90, R 270 L 225, R 225 L 135.

Spoiler Warning: if you want to solve this puzzle yourself, don’t read my log. It contains spoilers for the intuitive leaps as well as the solution.

14:45
Okay, puzzle is gridded. What do we have here? These are obviously rotations; L and R for ‘left’ and ‘right’, and the numbers are all < 360.

14:50
Oh, they’re all multiples of 45 degrees. So, they’re all nice, even angles, and they are paired off.

15:00
Aha! It’s Semaphore. For the two that are missing part of the pair, I’m assuming the angle is 0. Let me just look up a semaphore chart…

15:01
Oh crap. Is 0 at the top or bottom? Is L the sender’s left or the receiver’s left? Now I have to work out the coordinate system Dante used. At least we know that the low numbers map to the L side, and the high numbers map to the R side.

15:10
Tried 3 coordinate systems – 0 at top with L == left arm, 0 at top with L == viewer’s left, and 0 == right, coordinates going counter-clockwise (trig coordinates). All that’s left for reasonable systems is 0 on the bottom.

15:13
And solved. The solution is GOODFORYOU. It was the last coordinate system I tried, of course – moved 0 to the bottom, but got L and R backwards the first try.

Leave a Comment

Project TreeWars: When is an OpenGL not an OpenGL?

So, I was playing around with the ‘sparks’ feature on Google+. Since I’ve been working with OpenGL lately, I made a spark for it. On that spark, I came across this thread, which gave me this advice:

A general rule of thumb is that if a tutorial contains calls to glBegin, glEnd and/or any of the glTexEnv functions then it’s old and you should avoid it.

Now, I wouldn’t generally trust a single person on the Internet with nothing to recommend them, but I’m seeing this advice repeated in several places now that I know to look.

So, all the tutorials I’ve been working with are for very, very old versions of the OpenGL spec, and the functions I’m calling are pretty deprecated; I’ve been learning obsolete tools. To that end, I recommend anyone following this series not use my last post as a jumping-off point for working with OpenGL, or at least know what you’re getting into. Those functions and methods still work, but they’ve been deprecated and eventually graphics cards will probably stop shipping with support for them.

Instead, I found some more modern tutorials and documentation. Luckily, I’m not terribly invested in the way I’m doing things yet; I have maybe 100 lines of OpenGL-related code in my project, and the vast majority of it (that is, all the stuff that isn’t needed for initialization and gamestate changes) is factored into a single file. It should be pretty straightforward to replace it with something better, once I’ve got a handle on the “new way” of doing things.

This exposes a deeper issue, too. There are several different versions of OpenGL: best denoted by their major version numbers (1-4). The most current iterations of each are OpenGL 1.5, 2.1, 3.3, and 4.0. There seem to be tutorials available for all of them. Now, there’s a tradeoff to using one version of OpenGL over the other; newer versions will have less support from other libraries (Linux doesn’t even seem to have OpenGL 3 headers yet). On the other hand, older versions will eventually be deprecated and phased out. Newer versions can also do things older versions couldn’t, although right now I’d be happy just learning the basics.

So, after looking around on the web for a while, I settled on learning OpenGL 2.1 (and the corresponding GLSL 1.2, which we’ll talk about in a moment), while avoiding all of the functions in OpenGL 2 that are deprecated in OpenGL 3. This is the approach that Joe takes in this tutorial series, so what I’m learning will line up well with at least one tutorial on the web. It is also nice because this version is well supported in Linux, while OpenGL 3 support (especially in SDL) is still under development.

Now, there is a huge change between OpenGL 1 and 2. A change so massive that the difference between 1 and 2 dwarfs the differences between 2 and later versions. This change is the move from having a “fixed-function graphics pipeline” to using GLSL, the OpenGL Shader Language. So, what does this mean? Well, in OpenGL 1.5, you tell the graphics card what you want to draw, and some parameters about how you want to draw it, but the details of that process – the functions on the graphics card that handles doing the actual drawing – are hard-coded and unchangeable. With shaders, you get to program those functions yourself, and then your application can send them to the graphics card, compile them, and use them. GLSL is the language the shaders are written in – it looks a lot like C, but it has neat built-in functions for matrix and vector math, and a ton of built-in variables that I haven’t quite worked out yet.

So, I rewrote my rendering engine to use shaders. I followed the tutorial closely, modifying it to fit into my object-oriented C++ code and to fit all the other code I had already painstakingly written. I refactored large sections of my program. This took several hours, during which I couldn’t even compile the program all at once, because so many changes were being made. When I finally got it to compile and run without immediately crashing, this is what I had produced:

I appear to be doing it wrong, as they say around these parts. I have simplified my program so that all it should be doing is displaying a single texture on a simple rectangle. I have no idea what’s wrong here. Is my coordinate system somehow incompatible with my shaders? I don’t think so – I reworked the coordinates to match the tutorial I’ve been using. Are my shaders for drawing a texture simply wrong? Maybe, but there’s not a great way that I can find to get debugging info out of the shaders. Is SDL 1.2 not compatible with GLSL? That’s a decent possibility; testing it will take some time, though.

This is the biggest setback I’ve encountered so far, though, so that’s a pretty good sign. Hopefully, by my next post, we’ll have something better than a black screen to work with.

Leave a Comment

Project TreeWars: the road to OpenGL

Over on Shamus Young’s blog, he recently said this when talking about a programming project of his:

One of the things I like about this project is that it is uncluttered by goofy, awkwardly-designed libraries.

Shamus is working on a procedurally-generated 3D world using OpenGL. Now, I know what he means. He is trying to avoid relying on things like graphics and physics engines, or 3D model importers, or any of a number of other tools that often have asinine and byzantine APIs. I am, in fact, trying to do the same thing in my project (in my case, it is because I am using this project to learn graphics programming).

However, I have to object. libgl is a goofy, awkwardly-designed library. Of course, the fact that it that is has to be, in order to do what it does. However, code like this:

glBegin(GL_QUADS);
glColor3f(r1, g1, b1);
glVertex2i(x1, y1);
glColor3f(r_mid, g_mid, b_mid);
glVertex2i(x2, x1);
glColor3f(r2, g2, b2);
glVertex2i(x2, y2);
glColor3f(r_mid, g_mid, b_mid);
glVertex2i(x1, y2);
glEnd();

is pretty goofy. Anyone with experience writing GUI code using a Windowing toolkit would be appalled to learn that this is how you draw a rectangle. A more reasonable API would let you get a ‘rectangle’ object, then define things like its x/y position, its width and height, colour, etc. Then, you might make a call like:

window->add(rectangle);
window->update(); // to draw the window

But in OpenGL, we have to tell OpenGL that we want to start drawing a polygon, then tell it the colour and position of each vertex on the polygon, and then tell it when we’re done, all with different function calls. And gods help you if you get them out of order:

What happened here? I told OpenGL to draw a rectangle, and I gave it the top-left vertex first, then the top-right, then the bottom-left, then the bottom-right. This is a pretty obvious way to think about listing the points on a rectangle, right?

Except that OpenGL is designed to actually create the polygon’s bounding box based on the order you list the vertices, like so:

So, OpenGL did exactly what I told it to do; we just weren’t speaking exactly the same language. OpenGL requires that I list the vertices in clockwise (or counter-clockwise) order around the edge of the polygon.

OpenGL is an iceberg, though, and this is just the tip. There are Display Lists, Vertex Buffer Objects, shaders, 3D objects, normal vectors, projection matrices – it is a very complex beast, and all of that complexity is exposed directly to the user. So why does Shamus knock on all those other libraries, but give OpenGL a pass?

The answer is that OpenGL *has* to be this complicated. The reason? OpenGL lives on the graphics card. This is something that it is easy to miss the ramifications of, but they’re huge – the OpenGL function calls are talking directly to analogous function calls hard-coded in a chip on a piece of hardware. When you call glVertex2i(), you put data about a vertex directly into your video card’s memory. OpenGL is fast; it’s what lets us have advanced graphical environments that change and that we can interact with, rendering in realtime. So, subsequently, OpenGL’s end-user libraries are complicated; they have to be to let you take full advantage of what OpenGL is designed to do.

That doesn’t make it any less goofy, though.

Comments (1)

Project TreeWars: How to write bad code

The TreeWars project is a week and a half old (at the time of this writing). It’s come a long way; in its current form, it actually looks pretty neat:

There are now stats, and hit points, and the basic gameplay mechanic is in place. I’ve also laid the groundwork for some more complex gameplay, as well. Of course, I haven’t talked about gameplay all that much yet – we’ll get to that at some point, I’m sure. But what I want to talk about right now is how to write bad code.

Bad code happens. Sometimes, when you’re writing code, you will hit a stumbling block. Encounter a problem where the solution doesn’t jump immediately to mind. And often, you’ll look back on it later and say “what the hell was I thinking?” Well, here is an instructive example of that.

This blunder is actually pretty embarrassing; I really did know better, but that knowledge escaped me at the time. As you’ve probably noticed from the screenshot above, my program deals with drawing circles (called either ‘nodes’ or ‘vertices’). If a user clicks to add a new node, my code has to check and see whether it will overlap with an existing node.

So, I had a function that answers the question “is there a node close enough to the point (x,y) that a new node there will overlap?” If you’re good at geometry, you probably already see the right way to do it. But I bet you can’t spot the very very wrong way!

My solution (and I stress that this is a really, really bad idea) was to create a ‘bounding box’ around each existing node, and a bounding box around the area that the new node would occupy, then do some complex logic to see whether the bounding boxes overlap. It looked like this (and if you’re not a programmer, just note the general size and complexity of this code):

bool Graph::vertex_present(int x, int y, int size)
{
    int delta = size / 2;
    int x_min = x - delta;
    int x_max = x + delta;
    int y_min = y - delta;
    int y_max = y + delta;

    for (list<Vertex>::iterator cursor = vertices.begin();
         cursor != vertices.end(); cursor++)
    {
        Vertex v = *(*cursor);
        if (((x_min >= v.x_min && x_min <= v.x_max) &&
            ((y_min >= v.y_min && y_min <= v.y_max) ||
             (y_max >= v.y_min && y_max <= v.y_max))) ||
            ((x_max >= v.x_min && x_max <= v.x_max) &&
             ((y_min >= v.y_min && y_min <= v.y_max) ||
              (y_max >= v.y_min && y_max <= v.y_max))))
        {
            return true;
        }
    }
    return false;
}

It’s ugly, and hard to read, and I knew it felt like a hack when I wrote it. But at that moment, nothing better was coming to me. Now, for those of you who don’t enjoy recreational geometry, here’s the right way to do it: you know that the existing node is at (x1,y1) and that it has a radius of r1. The point you’re checking is at (x2,y2) and the new node would have a radius of r2. So, all you do is get the distance between the two points (basic geometry, I could have googled “the distance formula” and about 8 billion websites would have popped up to tell me how much I fail here), and then compare that to r1 + r2. Like so:

bool vertex_present(int x, int y, int r)
{
    for (list<Vertex*>::iterator cursor = vertices.begin();
         cursor != vertices.end(); cursor++)
    {
        float dy = y - v->y;
        float dx = x - v->x;
        if (sqrt(dy*dy + dx*dx) <= v->;r) return true;
    }
    return false;
}

See? much simpler.

Now, why did it take me 24 hours to figure that out? Well, I wrote the original code when I was pretty tired, and the nature of programming is that once you write a function and it works, it is easy to forget about it. After I needed to calculate distance somewhere else, though, an alarm went off in my head. “Hey,” said the alarm, “You could have used that over in vertex_present()! What is wrong with you?”

Well, alarm, look. Sometimes I just can’t brain as well as other times. But hey, at least it ended up being nice and pretty in the end, so thanks for that! Actually, vertex_present() doesn’t even exist in my code any more; it was refactored into some other function, because I only actually used it in a single spot.

Luckily, I can go back in time and show you how awful my code used to be through the magic of git, which I use to track all of my programming projects. It lets me periodically ‘commit’ the changes I’ve made to my code, and keeps track of everything I’ve done. I can then ‘checkout’ any commit, instantly reverting my code to an old state, and then ‘checkout’ the latest code again when I’m done. It can do a lot more than that, too. If you write code, I highly recommend using git or another version control system.

So, that’s all for today. Next time, we might even talk a little bit about gameplay! With a little luck, the game will be sophisticated enough by then that there will be something to talk about.

Leave a Comment

D&D Post-mortem: Getting creative with your mage hands

In D&D Post-mortem, I talk about my experiences running D&D 4e games, about 4e as a whole, and about collaborative storytelling in general.

Our most recent D&D session was pretty short – a small amount of cave exploration, and a single encounter. During that encounter, however, a few things happened that highlighted two fundamentally different approaches to roleplaying games. The scenario in question was this: the party’s Wizard wanted to use Mage Hand to disarm an enemy spellcaster. I had several objections to this idea:

  1. The enemy spellcaster isn’t likely to give his wand up without a fight. Assuming, for the sake of argument, that we want to make rules for this attempt, it seems reasonable to me that a Mage Hand would have a Str 2, and would have to make an opposed grab roll, with at least a -5 penalty for the act of snatching an object out of the opponent’s grasp.
  2. It sets a nasty precedent. If we allow such a simple and repeatable disarm, the game ceases to be challenging. Following this to its logical conclusion, well – the characters’ actions don’t happen in a vacuum. Word of this tactic would get around (indeed, if such a tactic worked, it would likely already be in widespread use). People would start creating defenses against it – locking gloves, magical barriers, whatever. It would necessitate an arms race between the setting and the character that would potentially alter the landscape of my setting in a way that’s not very appealing to me. I’m all for player characters leaving their mark on the world, but I don’t much care for this reactive manner. This would also make enemies with natural weapons fundamentally more useful, which would reduce the amount of variety in encounters. Which, I suspect, isn’t something anyone wants.
  3. There simply are no printed rules for disarming an opponent. More importantly, I believe this was an intentional design decision on the part of Wizards of the Coast. A disarmed opponent is effectively defeated; so disarming an opponent is something that you should only be capable of doing when an enemy is reduced to 0 hit points (as anything that is tantamount to defeat should only be possible when the enemy is actually beaten, i.e. deprived of hit points).

Now, I brought up the first objection during play, and the player countered with ‘well, the enemy spellcaster would be surprised by the Mage Hand suddenly appearing’. By that logic, it seemed to me that arrows from a concealed target should always hit their targets, and enemies should likewise be able to surprise and completely defeat the PCs with a good stealth check. That doesn’t sound like a good logic to use when running a combat to me. In a combat situation, everyone involved is, to borrow a quote from Alexandra Erin, “exceptional combatants trying very hard not to get killed”. I didn’t raise the second objection directly, nor did I think of the third until I’d had some time to think about it.

And it’s the third point that I really want to focus on, because it highlights, as I said above, a fundamental divide in how one approaches gaming. On the one hand, you have an approach that focuses on simulating a realistic world (albeit with high fantasy-style magic and other trappings of the genre) in as much detail as possible. This is called (or, at least, I am calling it) simulationist roleplaying.

Simulationist gaming systems tend to be heavy on rules. A game with rules that govern everything a player can possibly do is accurately described as simulationist. This is the style of gaming that leads to damage location, rules to determine exactly where missed arrows end up (and whether they break), and a very precise set of rules governing how magic works in the setting (and categorizing it, explaining how different types of magic do or don’t work together, etc). Simulationist games give you rules for how good your character is at any skill common to the game world, from fighting to cooking, or, gods help us, crafting. If you haven’t spotted it yet, I’m culling all of my examples from D&D 3e, because it is a heavily simulationist game. Earlier versions of D&D were also heavily simulationist.

Simulationist games tend to encourage attempts to find creative loopholes. Because there is a rule for nearly everything, and everything is spelled out in as much detail as possible, it naturally supports the sort of thinking that leads to “well, the spell doesn’t say it can’t do this…”. This, to me, is one of the biggest downsides of simulationist gaming, because it turns the game into a meta-game. Instead of playing a Wizard wandering through the world, destroying your enemies and impressing your friends with your magic, you’re playing a game where you carefully read the spell description to see if you can twist the words to use the spell in a new, advantageous way.

The other style of roleplaying, which I will refer to as narrative roleplaying, involves a greater focus on the narrative of the game, and on the broad themes of the world, without getting bogged down in detailed rules that ensure the game is carefully confined by a rule. In a narrative game, there is not likely to be a table to roll on to determine the quality of the bread baked by a local baker. Narrative-focused game systems tend to be as rules-light as possible, defining the areas that require arbitration (such as combat) and getting out of the way otherwise. Narrative systems also have a tendency to encourage reinterpreting the rules in ways that don’t effect their mechanical structure. D&D 4e and the entire White Wolf canon are good examples of games with a narrative focus.

The interesting thing about games with a narrative focus, or at least D&D in particular, is that there is a disconnect between the rules and the diegetic game world that doesn’t make sense from a simulationist perspective. For example, look at Second Wind. Second Wind operates diegetically on the principle that you take a moment to center yourself, to quickly bandage a wound, or to just take a ‘breather’, and thereby gain the stamina to keep fighting. Notice first that any of those things could apply narratively – you might do one or all of them, or something else that is analogous, as the situation warrants. But more importantly, you can only do this once per battle. Why? What makes bandaging a wound the first time extend your ability to keep fighting, but bandaging a wound again ineffective? It’s the same action; shouldn’t it have the same consequences?

The reason is that the rules account for things outside your character’s control. A battle is chaotic, and you don’t get many opportunities to step back and take stock of the situation and get your feet back  under you. Such a chance comes rarely – let’s say only once in a brief struggle of 10 rounds or so. Using Second Wind doesn’t simply represent an action that your character takes – it also represents your character taking advantage of things that are beyond her control, such as an ebb in the rhythm of the fight, to take a quick break and recover some stamina. As the player, the rules are giving you a limited ability to control things that are beyond your character’s control, for the sake of the narrative.

Encounter and daily powers work the same way. The ranger power Split the Tree is a daily power. The simulationist model would suggest that this doesn’t make sense unless the ranger has some sort of mystical ability that they can only tap into once per day that gives them the power to fire two arrows at once. The narrative approach gives us a way out, though: the ranger could fire two arrows any time she likes, but she doesn’t get an opening, or time to line up the shot, every round. That sort of opportunity only comes once in a while – hence, a daily power. The player gets the ability to decide when that opening and free time show up, but it can only happen a maximum of once per day. This is completely an arbitrary restriction imposed by the rules; for the sake of game balance, you can only do these things a limited number of times within the framework of the narrative. It is a concession to drama over realism.

This is especially noticeable in the rules on magic item daily powers. No matter how many magic items you’re carrying around, you can only use 1 magic item daily power per day (at the heroic tier). This isn’t because the magic items share a pool of magic; rather, it is because the narrative and the game balance demand that these things be used sparingly. A warrior who relies on his magic items and shows no sign of actual combat prowess is, well… Tony Stark. And Tony Stark is a tool.

Here’s another way to explain the fundamental difference between the two approaches: in a Simulationist game, the rules encapsulate the character. In a Narrative game, the rules encapsulate the narrative. And having said all of that, I’m still not certain I’ve made my point, which is that I prefer games like D&D 4e precisely because they encourage dramatic narrative thinking instead of simulationist thinking. The narrative approach gives you two important freedoms. First, you can make a balanced game without having to jump through contortionist hoops to explain why wizards and rogues have roughly the same level of power. Second, and more interestingly, they give the players a lot more room for creative expression – you can slap any narrative description or explanation on top of an existing rule, and as long as it doesn’t change the mechanics, you have nothing to worry about.

If you want to learn more about my homebrew setting of Yord, or follow the antics of the PCs, check out my campaign at Epic Words.

Leave a Comment

I know what’s going to happen in Doctor Who series 6

Doctor Who is off the air until September, and a number of questions remain unanswered. But just because we don’t get any new Who for three months doesn’t mean we have to stop talking about it! So here is my chance to answer all of your burning questions. Because I know everything that’s going to happen in the second half of series 6. All the reveals.

Spoiler Warning for everything, up to and including A Good Man Goes to War, and for the rest of the series too, if I’m right!

Okay, so I don’t really know all the reveals. I don’t have access to the scripts, and I certainly don’t have a retro-futuristic thought recorder pointed at Steven Moffat’s head (not that you can prove, anyway). But I do have a pretty good idea where the story is going, and I think I’ve got at least one reveal pegged.

To start, let’s review the two biggest questions that the show left unanswered after A Good Man Goes to War:

  • Who kills the Doctor (i.e., Who is in the Astronaut suit on the lake in 2011)?
  • How does the doctor survive being killed? Because, let’s face it, he does.
  • Who did River Song kill?

I think I know the answer to the last one. Here’s your big spoiler: River Song kills her father, Rory Williams.

How do I know this? Moffat has left us a lot of evidence hinting in this direction. The evidence comes down to a theme in Moffat’s work: misdirection, specifically repeated misdirection.

Let’s start with the misdirection. By misdirection, I mean that there is a tendency in Moffat’s writing to tell us something in such a way that we assume something else. The easiest example to spot is in Amy’s monologues about Rory in series 6. The first one is in Day of the Moon, when she is captured by the Silence, and is talking to herself (but directing the words to Rory). She says:

I love you. I know you think it’s him. I know you think it ought to be him. But it’s not. It’s you. And when I see you again I’m gonna tell you properly. Just to see your stupid face. My life was so boring before you just dropped out of the sky. Just get your stupid face where I could see it, okay?

So, this is designed to make you assume she’s confessing her love for the Doctor – especially the phrase ‘just dropped out of the sky’. This is even lampshaded later, when she tells Rory it was just a figure of speech. That lampshade is, of course, Moffat gently mocking the audience for falling for his misdirection. He likes mocking us for falling for it, too: he does the same thing with FleshAmy and FleshMelody. Kovarian tells the Doctor, “Oh, Doctor, fooling you once was a joy. But fooling you twice, the same way, it’s a privilege.” These are both moments where the fourth wall is broken while still maintaining diegetic cohesion (Russel T Davies did the same thing with the 10th Doctor’s last line, “I don’t want to go”, which is clearly meant to be spoken by Davies, Tennant, and the Doctor simultaneously).

There is a second example of the Doctor-Rory misdirection; at the beginning of A Good Man Goes to War:

I wish I could tell you that you’ll be loved. That you’ll be safe and cared for and protected. But this isn’t the time for lies. What you are going to be, Melody, is very, very brave. But not as brave as they’ll have to be. Because there’s someone coming. I don’t know where he is, or what he’s doing. Trust me, he’s on his way. There’s the man who’s never going to let us down. And not even an army can get in the way. He’s the last of his kind. He looks young, but he’s lived for hundreds and hundreds of years. And wherever they take you, Melody, however scared you are, I promise you, you will never be alone.

Now, this one drops a really big hint, because both the phrases ‘there’s someone coming’ and ‘you will never be alone’ parallels what Rory said in Day of the Moon: “She can always hear me, Doctor. Always. Wherever she is and she always knows that I am coming for her, do you understand me? Always.” And, of course, we get the reveal immediately:

Because this man is your father. He has a name, but the people of our world know him better as the Last Centurion.

So, where does this tie in with River’s story? In Flesh and Stone; when the Doctor asks River about the man she killed, she says he was “A very good man. The best man I’ve ever known.” It’s easy to assume this refers to the Doctor, but we’ve seen evidence that River has no illusions about the Doctor being a good man, particularly the line “This is cold. Even by your standards, this is cold” from The Impossible Astronaut, and her rant that begins “This was exactly you. All this. All of it. You make them so afraid” in A Good Man Goes to War. No, River wouldn’t call the Doctor the best man she’s ever known; she knows him too well. But she might say that about her father, who shows, time and again, limitless dedication to his wife.

There’s more evidence, too. In Flesh and Stone, Father Octavian says that “She killed a man. A good man. A hero to many.” Again, this could refer to the Doctor, and that’s the obvious choice. But it could also refer to Rory, in light of Amy’s line that “the people of our world know him better as the Last Centurion.” (which is interesting, because as far as we know Rory is not widely known as a hero on Earth. We appear to be missing a little bit of story there)

Ultimately, the reason I think this is more than just a lot of circumstantial evidence and idle speculation is that Moffat has already done the Doctor-Rory misdirection twice, and has blatantly lampshaded how much he likes fooling us with misdirection. A third misdirection is, at this point, a logical way to finish the series.

There is at least one problem with my theory, though I think it fits in with the same misdirection again. The episode title of A Good Man Goes to War has every indication of being about the Doctor. River’s poem certainly seems to talk about him:

Demons run when a good man goes to war
Night will fall and drown the sun
When a good man goes to war

Friendship dies and true love lies
Night will fall and the dark will rise
When a good man goes to war

Demons run, but count the cost
The battle’s won, but the child is lost

On the other hand, nothing in the poem (or the episode) explicitly says that the Doctor is the good man in question. In fact, River’s “This was exactly you…” monologue happens at the end of this episode, which leads me to believe the misdirection is complete – every reference to ‘a good man’ has been a reference to Rory, without exception.

So, how and why does River kill Rory? A friend of mine suggested that Madame Kovarian is River Song. This is plausible – River was raised as a weapon against the Doctor. There are certain physical similarities (Alex Kingston and Frances Barber have similar facial structures and hair, at least), although those aren’t even necessary given that River can regenerate. The River we know has always seemed more than a little haunted by her past, and raising an army against the Doctor, killing Rory, and being generally heartless and cruel might certainly explain those demons.

So, this is what I think we’ll see in the remainder of series 6: River is not rescued (or if she is, it is not for long). She grows up to be Kovarian, her mind being twisted by the Silence to hate the Doctor. Subsequently, she kills Rory (while trying to kill the Doctor). Somehow, she has a change of heart eventually, and becomes the River we are familiar with.

The biggest mystery left, for me, is why Kovarian and the Silence seem to be at odds with one another. The Silence went out of their way to kidnap Amy (did they know she was Flesh at the time?), and to try to make Amy tell the Doctor she is pregnant. These things don’t make a lot of sense if Kovarian and the Silence are allies, but we know River was raised, at least for some of her life, in the Silence-infested Graystark Hall Orphanage. So, either the theory about Kovarian being River is wrong, or Kovarian and the Silence have a falling out, and/or she manages to keep secrets from them.

Comments (9)

« Newer Posts · Older Posts »
Follow

Get every new post delivered to your Inbox.

Join 134 other followers