Category: design

Thinking about a human-like AI for playing Scrabble

[I got into playing Words With Friends on Facebook and my mobile phone back in 2012, and started writing a lengthy article on designing an AI to play scrabble-like games in a manner that convincingly simulates a learning human. This weekend, several years later, I’m a spectator at a local Scrabble tournament, and decided to finally finish up my thoughts.]

Designing AI for Scrabble-like games

I’ve been playing the Zynga game Words with Friends with various people for a few weeks, and have gotten progressively better at the game. After looking back and reflecting on the evolution of my play, and the development of my strategy, I became inspired by the idea of a convincingly human-like AI that embodied the various stages of my development as a player.

While actually programming it is a little more effort than I want to put into it, even just thinking about the design for such an AI is interesting.


Fibonacci Tartan and Kilt

Some time ago, Youtube channel Numberphile posted a video on a tartan based on the fibonacci sequence.

Inspired by this, I’ve created a fibonacci-based tartan of my own:


Isn’t it beautiful?

My design is based on the first seven numbers in the Fibonacci sequence: 1, 1, 2, 3, 5, 8, 13. It uses one thread of yellow, then one thread of red, two threads of dark green, three threads of navy blue, five threads of red, eight threads of dark green, and thirteen threads of navy blue. To scale up the size of the sett, I will be multiplying these numbers by seven. I call the tartan, Fibonacci-7.

I just started a crowdfunding campaign to register the tartan with the Scottish Registrar of Tartans, and have a kilt made with it. It will cost an estimated $2250 to have it produced. Once registered, the tartan will become available to textile manufacturers to produce cloth and garments in this tartan.

If you are interested in math or just love a beautiful tartan, please consider donating to the cause, and spread the word. If every visitor to this site donated just $1, we’d have funding within less than one month. So if you’re a regular reader of this site and have found my articles on GameMaker useful, please show your appreciation by donating what you can. Thank you.


I have created a font I call min. It’s the first font that I’ve created. I used bitfontmaker. It was easy and fun, and I liked it. I want to do it more. Minimalist pixel art is something I enjoy, and I wanted to try my hand at the glyphs of a typeface, so I created the most minimalist typeface I could that was still legible. I might have been able to go further but I like the size. Most letters are 3×5 px or smaller in their original drawing.

It’s also an asset package in the GameMaker Marketplace. If it does well I’ll probably create a font pack of fonts that I develop over time, and see how that does. So if you’re a GameMaker user, please download it from there so I can get accurate analytics stats.

Update: I’ve added a second font to the collection, submin.ttf.

Download links

  1. Min Font – Free GameMaker Asset Pack
  2. min.ttf
  3. submin.ttf

Making a Configuration System in Game Maker, part 3: Where’s Part 3?

A while ago, I started a series of articles that I never finished, on creating a configuration system for GameMaker games. I posted Part 2 almost 2 years ago, and had intended to follow up in just a couple weeks with Part 3, but it stalled and never came out.

A few readers have asked, so I figure an explanation is owed.

The series I had started on creating a configuration system has been on hold since the second article. As I got into designing the system, I kept running into problems with making my system platform-independent and universal.

I had intended to write a universal configuration management engine for handling things like monitor resolution switching, master volume, music volume, and sound fx volume, and a customizable set of configuration widgets for whatever your game might need (essentially, a set of generic, reusable buttons, sliders, checkboxes, and other UI controls). Ideally, I had hoped to write a set of scripts that would use GML functions to define rooms and objects that would constitute the configuration system. Ultimately, I wanted to create a GML script config_system_create() that would set up the entire system — rooms, objects, and functionality, so that you could simply import a GEX extension, call one function, and have a full-featured system generated at runtime, without having to spend any time designing and implementing all the resources yourself. But in GM:S, YYG obsoleted the functions that allowed me to define objects at runtime, execute strings as GML code, and a number of other functions relating to how Windows handles video and audio.

My goal was to enable a developer to drop in my finished configuration system as a GameMaker extension, and invoke its default implementation with a single function call, and use other function calls in the extension to build custom features, but use most of the features without modification, beyond turning features on or off, and to also have the capability of adding customized settings specific to their game. I wanted to write my system one time, and have it be re-usable so that I could save myself from having to spend a lot of time re-creating the system in each new project.

Most difficult of all, it requires that I design a system that anticipates every need a game developer might possibly have, for any type of game they might dream up. Doing it one time and never having to touch it again would be great, but it’s probably not realistic.

This was an overly-ambitious goal. I’m laughing at myself a bit, now, thinking about it.

Still, there were a lot of achievable ideas that I had for the tutorial, and a demonstration of how to implement them would be a worthwhile exercise.

It won’t be drop-in, single-function system, and it’ll be specific to the Windows build target, but the design should be adaptable to your project with a little work.

I don’t want to make a promise for when I expect to deliver this, but I will complete the series and a reference implementation before I publish the first article.

Topology of Metropolis in Superman (Atari 2600)

One of my favorite games on the Atari 2600 is Superman (1979), designed by John Dunn, and based on the program code from Adventure by Warren Robinett. This game has stayed with me to this day as one of my favorite games. I started playing it again recently, and began thinking about the different aspects of it that make it such an enjoyable game to play again, even 35 years after its release.

While it might appear to be a very basic game to a modern eye, in its day Superman had many innovative features. I won’t give it a full review here, but the one that I find most interesting is the game map. The world of Superman is much larger than most contemporary games of the era, most of which took place on a single, non-scrolling screen. The way the Superman’s map is laid out is confusing and non-intuitive, making the game very difficult for a new player, but once you start to gain a sense of how the different screens that make up the city are variously interconnected, it becomes possible to navigate very quickly through a number of methods which can be memorized with some effort and repetition. First-time players can take 15, even 30 minutes and up to win, while an experienced player who is familiar with navigation can often beat the game in under 2 minutes.


Global Game Jam 2014 postmortem

The Global Game Jam 2014 site doesn’t seem to have a blog capability this year, or if it does I’m stupid and can’t find where I can blog about my progress. So I wrote this entry as the weekend unfolded.

The theme this year was: “We don’t see things as they are, we see things as we are.”

Interesting theme! I like it. A good idea came to mind almost immediately. I thought about a world that changes as the player changes. By picking up items, the player’s attributes change, and as the player’s attributes change, the world’s attributes change as well.

Then the idea came to me to have the player change by looking into mirrors that reflect a distorted view of the player. The more the player looks at the distorted reflection, the more they come to look like the reflection, giving them new powers… but, the world changes to match.


GameMaker tutorial: Elegant instance_change() in your state machine

In GameMaker, a commonly used technique is to build a system made up of a several objects to represent an entity in your game, such as the player or enemy, in various states, such as idle, dead, shooting, jumping, running, climbing, and so forth. This is what is known as a Finite State Machine pattern.

When the time is right in the game, we change an instance from one state object to another by using the powerful instance_change() function. Instance_change() takes the instance and transforms it into a new type of object. Its Event behaviors will change to those defined by the new object type, but its old properties (object variables) will remain the same as before, allowing the instance to retain its variables with their current values.

The instance_change() function takes two arguments: object, the object the instance will turn into, and perform_events, a boolean which controls whether the new object’s Create event will be performed or not.

Normally, the Create event is where an object initializes its variables and initiates its default behavior. When we’re dealing with a State Machine comprised of a number of objects, this can become problematic, however. Some code in the Create Event is initialization code that we may only want to execute one time, to set up the instance when a brand new instance is created, while other code in the Create event is behavioral and we may need to execute whenever an existing instance reverts back into that state again. Thus, the perform_events argument in the instance_change() function isn’t adequate for this situation — it’s too all or nothing.

For example, let’s say I have a generic object for an enemy, oEnemy. I want some visual variety to this enemy, so I’ve created a few different sprites for it. In the Create Event, I want to randomly choose one of those sprites to be the sprite for this instance. But if the instance changes into another state object, and then reverts back, if I call the Create Event, it will randomly choose a new sprite. I don’t want this, as it ruins the illusion of continuity — I need that instance to retain its sprite. But I do need the Create Event to run, whenever it re-enters this state, because I’m using it to set the instance in motion.

So, how can I elegantly select which lines of code I want to run in the Create Event?

Conditional blocks

This is the least elegant solution, but you could use if to check whether a variable exists or has a value. For example:

if sprite_index == -1 {sprite_index = choose(sprite1, sprite2, sprite3);}

This is inelegant because it adds lots of lines of code that only need to be run one time (when a brand new instance is created) but need to be checked potentially many times (any time that instance changes back into the object state). It also only checks certain, specific things, case by case. As I continue to build the state machine, I may end up introducing more features which require initialization, which would necessitate more checks, further bloating the code. I always want to write the least amount of code needed, both for reasons of performance and maintainability.

Move one-time code to an init state object.

The more elegant solution is to recognize that initialization is its own state, and we need to separate it out from the other states in the state machine. We can create an oEnemy_init object, put our one-time initialization code into it, and then the final step in the Create Event for the init object would be to change the object into the default state.

None of the other states in the state machine should put the instance back into the init state, thereby guaranteeing that the init code only executes once. Now your code is neatly separated, your states objects in your state machine are as simple as can be.

HTML5 Game Development With GameMaker published

Today Packt Publishing announced the publication of HTML5 Game Development with GameMaker by Jason Lee Elliott. I was involved with the creation of this book as a technical reviewer, and as such I’m intimately familiar with its contents.

While the book title refers to HTML5 games specifically, most of the content is applicable to any development in GameMaker Studio, regardless of your intended build target.

Some of the highlights include:

  • Numerous examples of the “Finite State Machine” pattern implemented as a system of related Objects
  • Building a Box2D physics-based game
  • Creating a particle system
  • Facebook integration
  • Flurry Analytics integration
  • How to publish your game on the web.

If you purchase through the link below, Amazon will compensate me for the referral.

Bad Puppy: Design Analysis

So, last weekend I made Bad Puppy for Ludum Dare 25. I didn’t realize it as I was making it, but it seems that I’ve come up with a game that is really pretty fun. I’ve gotten many compliments from people who’ve tried it, and the more I’ve played it, the more it’s grown on me.

I think it’s worth analyzing the game to identify factors that contributed to it being fun.


Bad Puppy is cute. Everyone loves puppies, they are irresistible. So this makes the game inherently enjoyable — if the puppy works. I think I did a good job with making the puppy cute enough, using just a simple animation and some basic sound effects. The running and wagging animations are winners. 

One of my most frequent feedbacks has been that the “graphics could use a little polish” — I agree. But I also don’t want to lose the charm of the simple/crude 8-bit pixel art aesthetic. I think the style works for the game, but it could be enhanced by more variety. That’s why I added an enhancement to make the sweater color random. I’m also planning on doing something similar to vary the skin tone of the person, and maybe create a selection of hair styles. There will definitely be a female person too, as soon as I’m able to create her.

The graphics for the pickup bonus items are rather crude, and I’d like to improve them as well. I’ll probably try something subtle, like adding shading and shadow to them, and see whether that works.

I’ve also thought about doing something with the drab grey background color, but I’m not entirely sure what I want to do with that yet.

The barking sounds, panting, and “good boy!” are also cute. I just recorded myself barking and manipulated the sample a bit in Audacity to make it sound 8-bit. Something about the lo-fi, crude aesthetic seems to enhance the cuteness.


Bad Puppy is a very simple game. It is also a relatively fast game (in terms of short play times). A typical play usually doesn’t last more than a minute or two. Short play makes the game enjoyable to repeat. 

I made the game short by increasing the difficulty, and by providing no means of regaining lost meanness, or gain extra lives. This means the game must inevitably end, and a play is only as long as the player is able to make it with their skill. When you play a short game and the length of play is determined by skill alone, it tends to make you want to play again, because you just know you can do better the next time.


The controls are very simple. You run around, and bark. The controls are simple enough that they could be done with a 1-button Atari joystick. The game doesn’t need anything more than this.

Despite being simple from the user input standpoint, the motion that is governed by the controls have a little bit of polish in them. First, you don’t keep moving if you release the controls, but you also don’t stop immediately, either. Rather, if you are not pressing an up/down control, your speed in the y-axis decelerates gradually until it reaches 0; and the same for left/right and the x-axis speed. This gives the puppy a slightly “slippery” feel, makes the motion feel like a more natural curve, rather than orthoganal directions, and “de-diagonalizes” the motion so that the only way you move diagonally is if you are pressing in both the x and y axis simultaneously. It is a motion mechanic which feels natural as well as puppy-like.


The play mechanics and strategy are something I’m proud of. I can’t say I designed this from an ingenious flash of insight, but the way it came together, it felt very natural and like things were coming together in a way that felt right, and following my instincts to do the least complicated thing that seemed necessary worked well.

With the gameplay, there are a few things that stand in tension against each other, which result in a kind of dynamic equilibrium that makes the game fun.

  1. To bark at someone, you have to be close to them. You don’t get points for barking at someone who is too far away, you have to be a certain distance away from them or nearer. This means that you can’t be just anywhere in the room, and have to move in order to be in a good position to bark for optimal points. It also means that you have to put yourself at risk, because…
  2. When a walking person gets too near to you, they start to chase you. They don’t simply walk a predetermined course, unresponsive to your position. This creates a sense of adversary, as opposed to uncaring/ambivalent people who just walk and don’t react to your presence. It makes the game more interactive.
  3. Chasers give up if you get too far away from them, and go back to horizontal walking. This gives you additional incentive to run from them. But it can also influence the player to not run too far away from them, either, if you are trying to lead/herd them. Keeping you closer to the people makes the game riskier, and keeps the player on their toes more.
  4. You are faster than the people, which is good because if you weren’t, the game would end too quickly. You need to be able to get away. Puppies running faster than people is natural and feels right, and is in that sense realistic.
  5. The room wraps. You can take advantage of this to escape at the edge of the screen, rather than get boxed in by the edges of the room. 
  6. People will wrap horizontally, but due to the way the homing AI works, someone chasing you will “lose” you if you wrap off the edge of the screen, effectively giving up chase. However “normal” walkers who are not in pursuit of you will continue to move in the direction they are heading in, and wrap. Since there’s no visual way to differentiate between these two modes, it makes the enemy AI difficult to predict, and forces the player to react rather than anticipate.
  7. People do *not* wrap vertically, and mostly do not move in a vertical direction unless they are in pursuit mode. After playing a while, a player can pick up on this and use it as a strategy to evade a group of people when they are surrounded.
  8. To bark at someone, you need to be facing them — barking does not increase your score if you are facing away from the person, even if you are close enough to bark at them. This means a strategy of always running away while barking will not work; you need to repeatedly turn around and bark toward your pursuers. Coincidentally, this is very puppy-like behavior, running away and then turning around and running back, but trying to stay out of reach.
  9. An effective strategy is to try to “herd” the people by taking advantage of their pursuit response, in order to get them to bunch up. When bunched up, there is a lot of room to run around and avoid petting. And you can bark at the entire herd, which multiplies the points you get per bark. Having an effective strategy available to the player which they can discover through play makes the game more fun, because it rewards them for playing and making the discovery, and gives them a tactic through which they can feel they have achieved mastery over the game.
  10. To effectively counter the herding strategy, and prevent people from bunching up too much, I added an AI behavior, whereby a person who has been barked at too many times (which is randomly variable) will run away. Run away mode is mostly identical to walking mode, except that the direction is always away from the player, and the trigger distances to return to normal walking mode puts them a far enough distance from the player that they will not immediately revert to pursuit mode. The result of all this is that after a short time of successful herd-barking, the tactic’s reward diminishes as people start running away, and the risk increases because the retreating people spreading out makes the room more crowded, and it becomes harder for the player to avoid petting.
  11. The original version of the game lacked bonus pickup items. I realized quickly that with the player having only one thing to do, the game was a bit too one-dimensional and did not offer enough of a replay value. Adding the bonus pickups gives the player a secondary objective of collecting the bonuses.While this is completely optional, the game really seems transformed by presenting the player with temptation and giving them something else to do. Without the bonuses, a player can focus completely on avoiding petting, and will tend to last longer. With bonuses, there’s just enough temptation to try to pick them up that they become willing to take risks which will result in them getting petted a little bit, and the attrition wears the player down over time, reducing average play time. A clever player might see through this and decide that the way to get the highest score is to ignore the bonuses and focus on defensive play, trying to score only through barking, and picking up bonuses only accidentally. This might well be a better long-term strategy, but the value of the bonus items increases dramatically over time, which puts the value of going after them at a level where it seems worthwhile if you’re trying for a high score.

A few players have suggested adding something more to the gameplay, but I’m not sure what changes might improve on this without disrupting the dynamics of the core mechanic. I’ve thought of a few things, and will be experimenting with them in time. But sometimes knowing when something is complete and when not to add more is where the real design talent is.

I think there are many opportunities to polish what I’ve built so far without touching gameplay — an online scoreboard feature would be a great way to enhance the game and get people playing for global bragging rights, for example.

I’m interested in feedback, so if you’ve played the game and have something to say, please drop me a comment below or at the LD submission page, or tweet at me.

Influential Games: Mountain King

One of the more memorable and innovative titles on consoles and home computers in the early 80’s was Mountain King by CBS Electronics. I knew it on the Atari 2600, but it existed on other platforms also, including Atari 5200, Commodore 64, Vic20, and Colecovision. It was atmospheric and spooky and mysterious and inspiring, and one of my favorite games of all time.

Mountain King (Atari 2600)

There were a number of things that made Mountain King special, and examining them in detail is worthwhile.

Non-violent, Yet Scary As Hell

There was very little death or injury in Mountain King. It had a theme of exploring, not violence. The biggest threat in the game was the clock running out. Things that would hurt or kill you in another game imposed a time penalty on you in Mountain King. Fall too far, and rather than die or take damage, you’re stunned for a length of time proportionate to the height of your fall, and slo-o-o-o-wly get back on your feet. The wait could be agonizing, making seconds seem like hours. On certain difficulty levels, there are time limits for accomplishing certain objectives, and in any case your remaining time rolls over and is added to bonus time which dwindles with each re-claiming of the crown, so you are always under significant time pressure and there’s a feeling of speedrunning when you’re playing for a high score.

Mountain King spider

There is one deadly threat in the game, a giant man-eating spider that inhabits the lowest levels of the mountain. You can’t fight it, only run from it, but it is not normally necessary to descend to this level, so it is mainly in the game to provide a sense of fear of the depths. If you accidentally fell to the spider level, the scuttling sound of the approaching spider would fill you with panic and dread, and make you scramble toward safety with new urgency.

Audio Innovator

Most home videogames of the day did not feature music at all, or if they did, it was little beyond an introduction jingle that lasted a few bars, or a repetitive loop that quickly became annoying. Mountain King not only used music, but integrated it into the game in a novel way. A special theme plays when it is time to find the Flame Spirit, and the music gets louder as you come nearer to its location. A mostly-invisible entity which blinks sporadically, can can only be seen in full in the beam of your flashlight, using the music volume to triangulate and home in on the location of the Flame Spirit was one of the more novel mechanics in a videogame, and holds up well to this day.

Upon taking the Crown, a well-done TIA chip rendition of Grieg’s In The Hall Of The Mountain King plays, signaling your time-limited escape run to reach the Perpetual Flame at the top of the highest mountain peak in order to advance to the next level. The music created a sense of frenetic pace and urgency as you raced to the mountaintop. During the ascent, bats appear, which (similar to the Bat in Adventure) would rob you of the Crown. To avoid them, you sometimes had to hurry, and sometimes it was better to wait. This heightened the tension and anxiety you felt as you tried to make it out without losing the Crown, a setback which normally left you with insufficient time for a re-attempt, and meant an inevitable game over. More than any other feature, possibly rivaled only by the scare factor of the Spider, this made the game memorable.

Mountain King used silence to great effect, as well, for most of the time you are exploring the depths of the diamond mine in pitch dark and in complete silence, apart from the sound effects of picking up diamonds and the squeaking of bats. And if you fell, the sound effect — a simple descending tone — effectively conveyed not just that you had fallen, but how far. When you fell so long that part of the drop was in silence, you just knew you were going to be in for a long recovery time.

Each of these audio elements combined superbly to create a great mood, one of the best on the Atari 2600.


Mountain King’s themes of mystery and exploration are enhanced in a number of ways. First, the instructions don’t tell you exactly what you need to do — rather, they hint and allow you to figure things out for yourself. Enough information is there to figure the game out, but enough is left out that it leaves the player with a sense of mystery and discovery. The Flame Spirit and the Skull Guardian and who placed the Crown in the mountain are never explained, leaving the player to wonder and speculate.

The game reinforces the mystery and discovery directly in game play, by making a number of things invisible — black sprites on black background, discoverable only by shining your flashlight everywhere. Treasure Chests, which are worth a lot of diamonds, are not essential to find, but are common enough that you are likely to encounter a few of them as you collect diamonds. The Flame Spirit is unique and critical to the game, and normally invisible, but the combination of the musical theme and its occasional flickering into visibility make it findable even without the flashlight, but by learning to use the flashlight to find Treasure Chests to boost your diamond score enough to find the Flame Spirit sooner, the game leads you to use it in discovering the Flame Spirit as well.

Glitch World

These mysteries are fine enough, yet pale in comparison to the Glitch World that hangs high above the mountain itself. It seems that not much is known for certain about the Glitch World, whether it is truly a bug in the game, or whether it might have been placed there by the programmers deliberately for unknown reasons. But there are platforms high above the mountain which are just barely reachable if you make a super jump from a specific place on the mountain.

I discovered this all on my own quite accidentally by jumping around aimlessly, and it was one of the most exciting things I had run into in a game before. In an era that predated the internet, there was little chance of learning anything about this but by discovering it yourself, and the excitement of this, and the intimacy of learning a secret that, for all you could know, was known only to you and (maybe) the programmers of the game, was very special.

In the early pre-Nintendo 80’s, kids would talk at school about accomplishments and discoveries they had made in video games, often times to incredulous schoolmates who would demand proof, or claim to have seen the same thing on their Atari. There were a few books and magazines out there, even then, but we didn’t have access to information the way we do today, and it gave us the opportunity to discover things ourselves. There were of course some kids who became notorious for lying and making up something in an effort to seem cool and special, as well, but the fact that you couldn’t 100% disprove a claim, and everyone would insist that they were not making stuff up. The only way one could verify extraordinary claims (in a still mostly pre-VCR-era) was if you witnessed it firsthand, so this made the rumors and secrets surrounding videogames something extra special, and if you were a witness, it made you special. I fear that era is gone forever, changed irrevocably by the Internet Age.

And for me, Mountain King might have been the most mysterious. Warren Robinett’s Adventure Eater Egg might have been cooler, but because it gave you a message, it seemed to have a purpose, and however cool it was, it just didn’t have the same mystery that the Glitch World in Mountain King had. We never found anything up there, no matter how high we climbed, but we never doubted that if we could only find some way past the impossible point, and get just a little bit higher, some great secret would be waiting for us, and all would be revealed.