Wednesday, July 22, 2015

The Perfectionism Paradox

This past couple of weeks, I have been playing my way through some of my old favorite PC games.  I have been playing the original Thief and my personal favorite turn based strategy, Alpha Centauri. Once I got past my (very thick) nostalgia glasses, I found a few things that irked me.

Thief is a game loosely focused on stealth, but in reality, it's a game about messing with guards in a variety of ways.  What I immediately noticed when I started playing this game was the wonky control scheme. For some reason, there are four different speeds in which to move forward.  There are the standard run and walk, along with a slow modifier for each one.  This may sound like a good idea for a sneaker at first, since you may want to sneak run past a guard as you are being chased by another, but in practice, you will accidentally press a movement key when trying to look around a corner.  This makes any hope of getting into a smooth control groove aggravating.  It was a great reminder that using industry standard control schemes tend to make for a more enjoyable experience.

The other game I've been playing a lot of is Alpha Centauri.  Man, I love this game!  It is a turn based strategy game in the same vein as the Civilization series.  I should say it's in the series, since it has Sid Meier's name on the box, but I feel that the sci-fi theme in the game changes the flavor of the Civilization formula enough to make it unique.  Either that, or I love sci-fi and get bored with running a normal society too easily.  It's music fits the action onscreen very well.  It seems to come into my consciousness just enough to remind me that I'm commanding a sect of humanity to survive.  Commanding humanity beyond the stars is a great way to forget all of the petty issues I run into on an average day.

Having just gushed about Alpha Centauri, there is something that I've found that really started to bother me.  I play it like it's a SimCity game. It is something that I noticed as I played up until the conflict period of the game, where you fight, negotiate or contain your opponents, and stopped playing after a few turns into it.  Once this conflict stage began, I found myself either bored by the fighting or yearning for a somewhat... more engaging experience.  That's not to say that the conflict stage in Alpha Centauri is boring, I just found myself not playing a single game to completion once I developed all I could at my main landing site.  My soldiers seemed to me to be nothing more than tools, lacking any sense of personality or anything else to get attached to losing them en masse to take a single colony.  Consequently, I would end up massing up a massive army only to feel apathy when I lose them in a series of battles with my opponent.  I tire of the build, move and attack phases of the game, which is what the mid to late portion of this game center around.  Watching the same fighting over and over again with no input on who wins the engagements becomes tedious, killing any desire to finish the game.

What could I do to make the fighting more engaging?  I have been dwelling on this since I noticed that once the fighting starts, I stop playing.  One method is to make the combat more exciting, with units crouching and shooting, turning and firing, covering when artillery strikes.  That would make the units look like they are doing more, possibly engaging the eyes while the fight takes it's course.  Another method I considered was to implement a Final Fantasy Tactics type of combat.  When you engage another unit, you are given the option of joining the combat as a leader and directly engage the enemy on the field.  This would make an already long game even longer, however.

Looking at these old games has given me time to consider the strengths and weaknesses of their designs.  Even with the minor gripes on each game, I recommend giving each a play.  Cheers!


Monday, July 13, 2015

The Motivation Problem

Motivation.  Man, is this an issue!

I have done a few game jams and have only once been thoroughly uninspired by the theme. Even then, I haven't had an issue working my way through the initial, "What AM I making?" most (longer) projects I've worked on are plagued with.  It's not that I'm uninspired by the project (well, mostly, anyway), it's more of the long burn the long project presents me versus the, "Gotta go, gotta go, GOTTA GO!" mentality that pushes me through a short, succinct project that I embark on in any game jam.  Why would doing a game jam seem relatively easy compared to a solo project, where I have as much time as I need?  I have had to think about this exact problem as I work on my latest project and I think I have come up with a few reasons.

3. The rush.

I'm not sure what it is about doing a jam, but I always get a rush when I'm in them.  It's like a gaming Mardi Gras filled with fellow masochists. We're all in a fellowship of suffering for our favorite pastime, designing games.  There's some comfort knowing that I'm not the only one who is doing it, all competing for attention and glory.  That's a huge rush.

2. Long burn versus short burst. 

A solo project long-term is not the same thing as a quick weekend of design.  Sure, you can continue to develop the game you come up with in the jam, but at the end of the day, you're still facing the prospect of a long, sometimes soul-crushing, development time. A jam is nice because it has a clear, short time frame in which to work. Polishing any game takes a looong time. And from my experience, once you have that proof of concept from the jam, guess what most of it ends up being?  That's right, the polish.  I haven't quite mastered the polishing stage, since all of my games have come from quick burst of inspiration.  Once the inspiration expired, I moved onto another project that caught my fancy. The long burn of the polishing stage is the next stage I need to master.

1. It's a solo project.

I really want to discount this as my number one reason, but I must come to terms about my own behavior.  I suck working alone.  Sure, I can work my day job a whole day alone, with me being the only one in the office that day, but I feel as those days fall into the short burst category.  When it comes to the long burn type projects, having someone there to bounce ideas off of or prod me into doing that part I don't care for really helps me advance.  Not having someone relying on my work to get something done makes me want to put that project on the "I'll do it at some point" list.  This destroys most immediate motivation I have.  Honestly, I'm not sure how to remedy this.

Thank you for reading this rant!

Saturday, July 4, 2015

Adventures in Quad-Trees!

This past week I have been looking into implementing a quad-tree data structure in my game engine.  Although the amount of stuff on-screen in most of my games may not really benefit from it yet, I figured now would be the time to implement it before I face massive slowdown from too much shiny (รก la fancy particle effects that bounce off of players, walls, etc.).

For those who are in the dark about what a quad-tree is, it's a specific data structure that can significantly streamline collision detection.  The basic concept is that the screen is split into zones as the number of objects on-screen increases. Once the number of objects on-screen reaches a threshold, the quad-tree splits the screen into exactly four quadrants.  Each quadrant can only contain so many collidable objects. If there are too many objects in any one of these quadrants, that quadrant can then be split into four more quadrants and so on, until each portion of the quad-tree is either at or below capacity.  Once you have the objects placed in different quad-trees, you can then check collision between only those inside the specific quad-tree rectangle and not check against one across the screen.  This can potentially save significantly on collision checks

Now, I know I asked myself, "Why would I want to do this?  Isn't it cheaper to just do collision tests on all of these objects at once?"  After all, all of my games up until this point have had only a handful of objects on the screen at once, and only a few objects cared if they collided with anything.  The first game I made, Log Jam! only cared if the player collided with any log, not if any logs collided with each other.  This led to some really weird problems, where the logs would "ride over" each other.  Although this was purely an aesthetic issue, it has always kind of bothered me.  Implementing collision logic between the logs would add variety in movement to each one, and make the game more dynamic overall at the cost of a LOT more collision checks.  This is where I could have implemented a quad-tree system to minimize the number of checks I would have to do.

An example of a collision issue in Log Jam!

Another example of wonky overlap with the logs
Working with Log Jam! as an example, let's go through the number of checks that we would need to do if we are later into the game, where there are a bunch of logs on-screen at once, such as in this screenshot:
A late game screenshot of Log Jam!
 In this shot, there are ten collidable logs on the screen (the waves are just for polish and aren't affected by the logs).  In this example alone we have 10 log collision checks to do, coming out to 45 checks minimum to make each time through the game loop.  If I was sloppy in coding (as I sometimes am), the number of checks would be closer to 90, assuming that I forgot to cull redundant checks.  Keep in mind that each check is a simple rectangle collision check, relying only on the bounding box of the log.  Even in this example, that is a lot of checks!  Let's break this into a more manageable size:
The same screen broken into a quad-tree
Now in this example, our parent quad (the entire screen) only has two objects in it, the log straddling one and two and the player's raft. quad one has two objects in it, two has one, three has two and four has three.  Let's go through the math: the objects in the parent node have to check against all of the sub-nodes and each other, netting 17 checks. The logs have to be placed into one of the quads, netting in another 24 checks.  Once all of those are into quads we can check each: quad one has 1 check, quad two has no check, quad three has only 1 check and quad four has 3 checks.  This leads to a total of 46 checks.  Hmmm... Not much better, is it?

If we limit our checks of the parent node to only those sub-quads that the object hits we can cut the number of checks.  For example, the player's raft will only hit quads one and three, that check alone netting us 4. we then compare the raft against quads one and three, netting another 4 checks. Doing the same with the log, we net 7 checks, cutting our total collision checks to 15.  When we put this into the our previous calculations, we end up with 44.  Not great, but a modest improvement.  The more objects that appear on-screen, the better the results we will get.

In my example, the quad-tree algorithm adds a lot of overhead to collision checking, so in this case, it may worthwhile for Log Jam! If there was a lot of collision checking that I had to do, such as where I was dealing with something where the logs rotated and the collision checks weren't just dealing with rectangle checks, but whether a rotated object indeed hit another, the quad-tree would make more sense. Having it in the toolkit for speeding up the game loop doesn't hurt, however.

Well, that's my broad-stroke analysis of quad-trees.  I'm sure that I'm missing something in this, but I just wanted to write my way through the problem before diving deep into the code.  If you have any questions/feedback, leave a comment.  Thanks for reading!

- Chandler