Saturday, February 8, 2020

How to design and implement turn-based system?




Possible Duplicate:
How to implement turn-based game engine?




I am considering making a game like Master of Orion but I don't know how to start with turn-based systems. If any of you played this game they know what I mean, same system is used in Civilization. 1. You give orders to your units and production queues 2. Click End Turn. 3. Everything moves, go to 1.


I know that some form of state machine is used, but maybe you could point me into some book or manual on the matter.



Answer



It's worth pointing out that there are really two kinds of "turn-based" systems. There's the true turn-based system, and there's the immediate-mode hybrid.


In a true turn-based system, you come up with a set of orders, but nothing actually happens until you push the "end turn" button. There's no combat, there's no production, there's just you laying out orders for what you think should happen during that turn. For examples, look at the PC game Dominions III, and the classic board game Diplomacy. In games like this you never have to ask questions like "which unit should attack first this turn" because there is no "attack first" concept - everything occurs simultaneously. This is also the genre that's amenable to play-by-email. Every player makes their orders, every player hits "go", every player looks at the new turn with dismay as their entire plan collapses due to everyone else interfering.


In the weird hybrid mode, generally unit movements and combat happen "immediately". Generally you can buy units, and that also happens immediately. You can say things like "I'll attack this force, and if I lose, I'll buy reinforcements before the next turn". Eventually you run out of action points and you have to hit end-turn, at which point it does end-of-turn effects like healing, resource gathering, and also lets other players take their turn. This is often known as "hot-seat play" because each person can do their turn in a row, but has to sit there waiting for the other players.


In the first case, it's pretty simple. Each unit, building, and city keeps information about what its next move is. When you hit end turn everyone carries out their orders - you just run the simulation, in whatever manner your simulation requires to run.


In the second case it's also pretty simple. Some units (generally buildings) have orders, but most units just do what you say, immediately, often with a pretty little animation. You'll need to keep track of when they have to stop doing things.


If you want more than that, you'll have to tell us what you're having trouble with. :)


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...