Monday, January 28, 2008

Speech bubbles

I'm experimenting with dumping animated GIFs of the game:

Click on the picture to see the movie. The frames are being played back at a steady rate rather than at the rate of play, so it can be hard to make out what's going on. Here's a summary:

The thief starts in his cabin aboard a ship docked outside the city walls. He disembarks and heads towards the city gates. Before reaching them, however, he is spotted by a patrolling member of the city guard, who opens the portcullis and gives chase. Diving into the harbor to escape capture, the thief swims underwater a short distance before climbing back out. Unfortunately he emerges under the light of a street lamp and is spotted again. The guard pursues him back aboard the ship, but the thief is able to hide under a table in the aft cabin. The guard, who did not see him hide under there, eventually gives up and leaves.

Meanwhile, you can see miscellaneous mutterings from other guards inside the city. I haven't implemented any sound attenuation yet, so whenever anyone says anything you see it.

The guards say lines when they spot the player, when they lose sight of the player, when they arrive at the last spot where they saw the player, and when they return to patrolling. They also randomly say lines while patrolling. This last part is clearly the weakest and needs lots of thought and improvement. (And better lines: That's what she said!)

Here's another, larger movie demonstrating the theft of some gold from the Temple of Theron (named after a local weatherman and not the South African actress):

The thief reads the sign while waiting for the outer patrol to pass. The door is locked with a simple three-pin lock that takes only a handful of turns to pick. Once the door is open, he discovers an inner guard passing nearby. By following close behind the guard he is able to circle to the far end of the temple without being spotted. He reads a hymn in passing before nabbing the gold.

There's still a ton left to be done on this game. At the moment I am focusing on getting good guard behavior. A big part of that is using guard speech to communicate what they are sensing and doing.

Speech needs to be presented visually. My inspiration is comic book speech bubbles. There are a couple of problems: positioning them, and ensuring that they don't flash by too quickly to be read.

Positioning speech bubbles is similar to map labeling which has a variety of algorithms available. I'm thinking of trying simulated annealing.

Up until now the game has not had any real-time animation, although I plan to add some for accent effects like screen transitions, blood spatters, water splashes, and gold sparkles. The game updates every time the player presses a key. If a speech bubble is associated with a given turn it can go by very quickly when the player is pressing keys quickly, or holding down a key and using the keyboard auto-repeat.

Many games in the Roguelike tradition require the player to dismiss text messages using the Space bar. I find this somewhat cumbersome so I'm looking for a way to avoid it. Andrew Doull, who is developing Unangband, came up with his own solution to this, which is to accumulate messages for the turn on-screen starting at the top line and working downward. You can press a key to dismiss them without taking a turn, but you can also press any of the keys you would ordinarily use to make a move and it will both take a turn and clear that frame's messages. I've tried out the latest build of Unangband and it has the problem that messages can flash by too quickly to be read. There is a message history window, accessed by pressing Ctrl-P, but if you have to use this on a regular basis it seems like a failure of the user interface to me.

One feature I'd like to add eventually is undo/redo capability. This would serve the purpose of a message history since you could rewind time to see what you missed. Again, though, the interface should not require regular use of this just to see what's going on.

I'm going to try halting the keyboard auto-repeat whenever a popup speech bubble appears. This should fix the problem of a held key making turns go by too quickly. It may also be annoying, though. It also doesn't address the problem of a player pressing keys very quickly, as they might when they are trying to maneuver in a direction other than a straight line.

Other ideas: Deadly Rooms of Death, a charming turn-based puzzle game, plays out speech bubbles in real time. The conversations thus occur in a separate timeline from the gameplay. This works when they aren't integrally linked to gameplay, but in my situation the guards' speech indicates their internal state, so speech needs to be coupled to the game's turns.

I've thought about accumulating messages over multiple turns based on how much real time has elapsed. Each message would have an on-screen duration, and would remain in the visible message queue for that much real time, regardless of how many turns have elapsed.

I'll be trying out various things like this to see what the benefits and drawbacks are. If you've got any other ideas, send 'em in!

Monday, January 21, 2008

Locks and Backups

I got the stupid locks hooked up, by getting up at 3am this morning.

I'm working on a cross between Thief and Rogue. It seemed like it might be fun to try and implement stealth gameplay in a turn-based game.

Stealth gameplay is all about getting into places while avoiding detection. There are several challenges in making it fun.

The biggest challenge is that it has strong positive feedback: the worse you're doing, the harder it gets. Once you're detected, guards summon more guards, alarms go off, and so forth. As a designer you want your games to have softer failure modes, where the player doesn't have to die and reload from the last save.

One way to soften things is to make the player character much faster than the enemies, so they can run away. The guards will give up the chase after a short time and return to their patrols, effectively resetting the game.

In a turn-based game it's hard to give different characters different speeds. Some games have speed ratings for characters that determine their turn order. Faster characters will periodically get to make two moves in between slower characters' moves. This makes the interface more complicated, though; it's hard to know when each enemy will move.

I've opted to give enemies slightly reduced movement abilities, instead. Guards cannot cut diagonally around corners. By running around several corners, you can gain distance from guards, eventually losing them. They move to the last place they saw you, look around a bit, and then return to their patrols.


Of course, it wouldn't be a stealth game without locked doors. Locks are essentially a way to keep the player standing in a dangerous place for a period of time, hoping that a guard won't come by.

Lockpicking is usually pretty stupid in games. The Thief series' lockpicking boils down to a timer; when it expires, you've got the door open.

I've got a simple minigame for mine that has a small memory element. You are presented with the digits 1-N, where N increases for harder locks. You have to push all N digits in the correct order. As long as you are pushing them correctly, they light up. If you push an incorrect digit, the puzzle resets and you have to start at the beginning again. The ordering is determined for each lock in the game at startup and doesn't change, so if you need to pick a second lock of the same type, you can do it in N turns as long as you remember the order.


I was doing backups to a USB hard drive, but it was still too manual for me. I had to get the drive out, hook it up, and run the backup. Also, I only have one external hard drive so my backups were not offsite.

I'm trying out JungleDisk now. It's an online backup system that uses Amazon's S3 storage. This means the data storage part is generic and can be accessed independently of the JungleDisk software. JungleDisk is also fairly generic; it maps the Amazon storage to a drive letter, so you can use it just like another drive. I could probably use Windows Backup onto it if I wanted.

The pricing is $20 for the JungleDisk software, and then whatever it costs for the Amazon S3 space. Amazon charges for space and bandwidth, so you only pay for what you use. The rates seem pretty reasonable, especially compared to some of the flat-rate online backup services I looked at, like Mozy ($5/month). Amazon's rates are 15 cents per gigabyte per month for storage, and 10 cents per gigabyte of upload bandwidth. Download bandwidth costs at most 18 cents per gigabyte.

Monday, January 14, 2008

Fun with food

This is a fairly useless post; sorry.

Diet Coke vs. Coke Zero

I finally did a side-by-side taste test of Diet Coke and Coke Zero. Here are the ingredients lists for each:

Diet Coke: carbonated water, caramel color, aspartame, phosphoric acid, potassium benzoate, natural flavors, citric acid, caffeine.

Coke Zero: carbonated water, caramel color, phosphoric acid, aspartame, potassium benzoate, natural flavors, potassium citrate, acesulfame potassium, caffeine.

They're both kind of foul, but if I had to choose one I'd go with Coke Zero. It's got slightly more citrus taste and seems a bit less cloying.

The story I heard is that Diet Coke was rolled out around the same time as New Coke, and was an attempt to be New Coke with no calories. New Coke was canned and Coke Classic returned, but Diet Coke retained the New Coke flavor. Coke Zero is a zero-calorie rendition of Coke Classic.

Of course, like an idiot I didn't think to buy a can of regular Coke to compare against the two. However, it can be difficult to compare corn syrup to aspartame. Aspartame lingers on the tongue for a long time after you swallow.

Egg-Carton Rotational Inertia

For a great demonstration of rotational moment of inertia, use up eight of the eggs in a dozen. Get someone to place the remaining four eggs in the carton without you seeing. Then try to guess where the eggs are without opening the carton.

It's surprising when you go to pull the egg carton out of the fridge and all the eggs are at the far end of the carton. My wife and I amuse ourselves by trying to distribute the remaining eggs evenly throughout the carton. If we wanted to keep the rotational inertia as close as possible to a full carton we would keep the eggs at the ends of the carton, though. I've started doing that instead.

Battle Ponies

This week I watched four episodes of the Legend of Zelda cartoon that aired in 1989. It's not great television but it got me trying to think of a cartoon franchise that would appeal to both little girls and little boys. I think I've got it: Battle Ponies! These are ponies (a la My Little Pony) which have been trained as ninjas to fight the evil Zombie Nazi Dinosaur menace.

Binge/Purge Cocktail

Ah, New Year's Day: when a young woman's thoughts turn to toxins, and the purging thereof.

A coworker of mine is trying out a ten-day toxin-purging regime whereby she does not eat, and subsists entirely on a concoction made of (“Toxins?” my wife said. “Let me guess: lemon juice and cayenne pepper, right?”) mixed with Grade B maple syrup (it has to be Grade B or you don't get all your vitamins and minerals) and water.

This sounds suspiciously like a recipe for a cocktail to me. As a cocktail, it has the benefit that, while you're binging, you're purging too! If I have any vodka around I may give this a whirl to work out the proper proportions.

Actual Coding

I'm back working on my stealth-gameplay Roguelike. Very little progress, though. I need to hook up locks to doors. The problem is that doors are currently a terrain feature, with no state. I handle opening and closing by altering the terrain. Now I need to be able to associate a lock object with the terrain feature. Locks have a type, which contains the order in which you need to push their pins to unlock them (if you don't have a key).

I think I will just write ugly code to start with, until I figure out what kind of generalization is appropriate. When you interact with a terrain feature, if it's a door I will look up the associated lock (if any) in some sort of spatial hash.

Eventually it seems like I might want to have an actual door object, which could keep track of its state. Right now I have several door-like things in the game which have similar code: doors, portcullises (you can see through these), and windows, with differing appearances for horizontal and vertical orientation on some of them.

Monday, January 7, 2008

Turn-based movement

The combination of new baby and two-year-old continue to take most of my time and sleep.

I've been thinking about simultaneous movement versus “I go/you go” systems in turn-based games. I've got a Roguelike game I work on from time to time. It is currently a simple I-go-you-go system. Everyone is in a big list, and each unit moves in turn, without being able to move into any square occupied by another unit.

This comes up short in a couple of ways. If you have a line of units all trying to move through a hallway, the order in which they take their turns will determine how closely packed they can be. Because of this, it is harder for the player to predict how units will behave. Predictability is important for my game.

This kind of sequential movement also means that each unit sees the world at a slightly different point in time. Again, this affects predictability.

There are ways in which you can alter the movement order to try and prevent collisions. For instance, if a unit tries to move and discovers that its desired location is occupied by someone who hasn't moved yet, the moving unit could adjust its position in the turn order so that it waits until the blocking unit has moved. (You'd have to ensure that dependency loops were handled somehow.) This might be good enough.

A really expensive way to solve this would be to do pathfinding for all units simultaneously. The state vector would consist of everyone's positions. There would be a lot of edges in this graph, so it probably isn't an option.