Hitting the wall

Brick-Wall-Background-40I’m still quite new to coding, and while I’ve used some structured learning courses via the likes of Codecademy and Udacity, I mostly just try and plough ahead on my own, only learning new concepts when the need arises. My approach to projects is simple – I alternate between implementing things that require learning a whole new concept, and implementing things I’m already comfortable with. This strikes a good balance of constantly improving my knowledge while always making steady, visible progress on any given project.

But what happens when your current to do list has several brand new concepts sitting at the top of it? All of which are significantly more complicated than anything you’ve tried before? Coding is sometimes strange in that often something that at first seems very complex can be achieved quite simply, whereas something that initially seems straightforward can transpire into hours, or even days, of frustration.

To give you an example – Finite State Machines. A Finite State Machine (FSM from now on) is basically something that can exist in a number of states, the current state being determined by a pre-defined set of conditions. A simple example of an FSM is a combination lock – it has two states: open and closed. The condition for the lock to be in its “open” state is of course for the correct sequence of numbers to be lined up. And the condition for it to be closed is anything else. This concept could be represented in code via a simple ‘if/else’ statement.

What I didn’t realise was that writing this sort of mathematical model would get exponentially difficult the more states you introduce. I’m using an FSM for enemy AI in a game I’m working on. The enemy AI is very simple – they have three states:

1. Wander around the immediate area aimlessly.

2. Move towards the player while firing in the player’s direction.

3. If they lose sight of the player, go to the last place they saw the player, and then wander around that immediate area for a set amount of time.

Each of these three states is very easy to program individually. Getting them all to change from one to another and back again was a nightmare, and I’m still not finished. I dread to think what will happen when I make the AI more complex.

The point of this example is to illustrate ‘hitting the wall’ with something. The wall is that thing that can often make you just give up on a hobby or new skill entirely after a few months. It’s that point when the ratio of progress-to-happiness associated with a new skill diminishes greatly. You have those initial few months where what you are learning is very basic, but you are going from zero knowledge to being able to actually do things! Eventually, you’ve got a handle on the basics and each new concept or step up the skill ladder is getting progressively harder and more complicated. When it comes to game development, it’s both very easy and instantly rewarding to make a thing you can move around the screen and shoot fancy fireballs, but it’s a hell of a lot more complex, and way less instantly gratifying, to, say, make sure your game displays correctly at any screen resolution a player might be using. Here is a terribly drawn graph to illustrate my point:

twallSo. If you’ve experienced similar in anything you’ve ever tried your hand at, how did you overcome it? I’m lucky in that coding is an almost infinitely vast subject; that even if I do feel like I’m coming up to that wall, there are usually a million other avenues I can head down instead.

Also, sometimes, taking a break entirely and doing something else can help. Unfortunately, writing this post has brought me no closer to improving my buggy Finite State Machine, but what the hell – I’ll fix it tomorrow instead.

2 thoughts on “Hitting the wall

  1. Hey would you mind stating which blog platform you’re working with?
    I’m going to start my own blog in the near future but I’m having a hard time deciding between BlogEngine/Wordpress/B2evolution and Drupal.
    The reason I ask is because your layout seems different then most
    blogs and I’m looking for something completely unique. P.S Apologies for being off-topic but
    I had to ask!

    1. I use WordPress – I use a free theme called Penscratch (so the basic layout and functionality is taken care of) and then my own custom CSS on top of that. WordPress is fine for a blog, if a bit cumbersome at times, but I’ve never actually tried any of the alternatives, so I have no idea how it stacks up against them.

Leave a Reply

Your email address will not be published. Required fields are marked *