1. Computing & Technology

Discuss in my forum

Why I made decisions about the design of the Star Empires Game

By , About.com Guide

This article discusses the design behind the Star Empires game. This is one of the games in the Programming Games in C Tutorial. (Tutorial will be published in August 2011 and a link added).

When you are programming a game, it's always a good idea to have a design to start with. The odds are that it won't be the final design, you're almost sure to modify it as you go along. Having a design in your head gives you something to code against though. It can be very tempting to jump straight in and start coding and in truth it can be fun, but if you go down that route the odds are you will end up with a prototype that isn't qyuite right and you will scrap it and start work on version two. It's one way to design but not the best use of your time!

Star Empires is a simple Console game with you fighting the computer for control of a galaxy of ten star systems. You start with one system, the computer has one and there are eight others to be won. At each system there are star ships and you have 50 at your starting system as does the computer player. If you find the game too easy you could give the Computer more to start with. Balancing a game, even a two player game isn't that easy and best done once you've got it working, not before.

.

Game Mechanics

At its heart this is a race to capture systems. You get new ships faster by having more systems and in that respect it's like a see-saw. As your side gains more forces the see-saw tilts more and more in your favor and there will come a time when victory is guaranteed.

New starships come along at all star systems. I chose a system where you got a small % increase of 10% per turn (rounding down) at each system with star ships present. It's not exactly realistic but it works and it stops you sending out all your ships at one go. So if you started with say 10 then increase by 10% (1) each turn to 11, the progression goes 12, 13, 14, 15, 16, 17, 18, 19, 20, 22, 24, 26, 28, 30, 33, 36,39 ,42,46,50,55,60,66,72,79,86,94,103, etc. It starts slow but snow balls. The alternative is to have a fixed growth amount per system. Getting this growth right is key to the game speed. Too slow and the game takes too (yawn) long, but too fast and if you blink it's game over man!

There are plenty of alternatives to try, perhaps different size systems with varying number of factories. Or maybe you can invest production into building more factories instead of building ships. As this is about programming games, not designing the ultimate in complex galaxy invasion simulations I went for the simplest but think of all the possibilities. Get out a spreadsheet and run the figures.

Fleets in Space

You have lots of choices as to how ships reach other systems. If they all had star gates and travel was instantaneous, the game would lose something. Part of the fun, is co-ordinating attacks which take different amounts of time for fleets to reach other systems, while hoping your systems wll be safe. You have to balance launching massive attacks with all your ships against keeping lots back for growth and system defence. Giving the player choices like this are what make the game interesting.

So I settled on having fleets. A fleet is an entity made up of one or more ships travelling from one system to another. The fleet takes one turn to travel one parsec and no systems are more than 6 parsecs apart. With nifty planning you can have multiple fleets travel from different systems and arrive at the target at the same time for massive impact.

I excluded battles from happening in space except at systems. It kept things simple.

Battles

If you want to go to town on combat you could implement Lanchester's Laws which are a simple expression of combat attrition between two different sized forces. I went for a rough approximation (sort of like the old Combat Resolution Tables in S&T/Avalon Hill Board games) where each ship starts with a 50:50 chance of destroying an enemy ship, but for every odds increase (2:1, 3:1 etc), the larger side gets a 10% advantage. In most battles, it's morale which often determines who wins. If you see your side getting decimated, you're going to have a "woah, time to depart" moment. So the combat system works out the chance of each side's ships destroying the others and then it cycles through all the ships working out how many of the other were destroyed, does the same for the other side and then removes the casualties.

Once either side reaches 50% of their starting strength they do a morale check. The attacking side will run away if that happens and they have a system to retreat to. The defending side will run away at 50% if they own another system. If not they fight to the death.

Game Over Man!

An easy one,. At the end of any turn, if one side has no systems and they have no fleets in transit then they lose. If they have fleets moving then the game continues. Once the fleets arrive they will attack the destination system and if they fail to capture it then the game is over.

Conclusion

It's a simple yet fun game. A few key decisions affect how enjoyable and playable the game is. Test, test and then test more. If you don't like it, change something and try again. I haven't covered computer AI in this article, that's for the next one!

©2012 About.com. All rights reserved.

A part of The New York Times Company.