Hey peeps,
I am trying to get my head around how to design the following system, which I think can be defined as a finite state machine:
Say we have a pile of 16 building blocks (towers, walls, gates) together forming a castle. The player can drag the blocks to 16 places on a floorplan and if done right they will see the whole castle. All towers (there's four of them) are equal so they can go on any of the four corners. Same goes for some of the walls.
All in all there are 16 spots on the floorplan where you can put a building block and each of the spots can have 17 "states": empty + either one of the 16 building blocks. Doing some maths this leads to 17^16=a LOT of combinations.
The program starts with an empty floorplan and a pile of building blocks. It should then show a message like "build your own castle, start with the tower". When the user places a tower correctly, it should say "well done, now build all four towers". You get the idea.
Problem is: there are so many things a player can do. Put a block at the wrong place, remove a block, correctly put walls or towers all over the floorplan ignoring the directions given to them, etc.
It would be awesome if I could avoid having to use thousands of if-then statements to decide wether I should take the next step, show an error message or go back to the previous step based on what the player is doing.
How would you describe the NEXT, PREVIOUS and ERROR conditions for every step of the building sequence? Are there any design methods for this? Thanks a lot for your input.