• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0

Is my design "bad"?

6 posts in this topic


I think I have a bad design.  


I’d appreciate some pointers or directions on how to evolve this design.


This game is a port of a hex-based board-game.   It’s a pretty complicated board game (400 pages of rules) with 1000’s of different units, many with LOTs of special case rules.    My code is in C++ and using Allegro as well (although that is pretty hidden in my design, I could swap that out if I wanted too)


At a high level I have a class for the game itself which includes the core variables about game state, maps of all the core game elements and pointers to the major core steps.


There are classes for each of the core game elements (players, units, fleets, planets, etc.).    As previously mentioned the actual instances of these elements are in their own std::maps in the core game class.


For each major phase of the game (economics step, production step, etc…) there is a class which contains all relevant information for that
step (screen initializations, game logic for that step, listeners for input, etc.).    There is a pointer to the instance of each of these in the core game class.


From a GUI standpoint, anything that needs to put something on the screen (or for that matter interact with the human player) calls a GUIFactory class, which in turn calls classes for the various screen elements (button,image, dropdown, etc.).   I’ve further broken it out that those classes call a separate library of classes for actually rendering.


My class hierarchy is pretty flat for the core elements, although there is quite a bit of inheritance going on the GUI side (some layers are from the library though).


Anyway it does work…it’s just I’m barely scratching the surface on the rules/game content that I need to create and its feeling fragile/difficult to maintain already.   And I haven’t even looked at some of things I know I need to tackle like network play or if I wanted to make an AI player.  Maybe I have done it “right” and it’s just a complicated game…but before I get too much further I thought I’d ask the experts.

Clearly this isn’t enough information for you to redesign it for me…because I don’t want you too…I want to do it [learn better that way]…but
some pointers on how I should be thinking about this would be appreciated.    


Happy to post code if you need a better explanation.



Share this post

Link to post
Share on other sites

with 1000’s of different units


You should rather have a few solid units than a large amount of units that are similar to the others.


It’s a pretty complicated board game (400 pages of rules)


complicated isn't always better and is inverse to playability.


Share this post

Link to post
Share on other sites

Clearly this isn’t enough information for you to redesign it for me…because I don’t want you too…I want to do it [learn better that way]…but
some pointers on how I should be thinking about this would be appreciated.

With 400 pages of core rules, thousands of unit types and lots of special cases you're certainly going to spend some effort on this.

I suggest, as a start to separate presentation from model.

I am somewhat confused by the fact you spend a lot of words on the GUI and how to present controls, what about the game itself?

Special rules might be somehow be encoded by using sub-classes I guess.

Can you just tell us the game you're trying to do? Perhaps we can take a look? If not, provide some examples of what those units need to do.


As for the GUI itself, I'm afraid you'll have to bite the bullet. I am not well aware of how Allegro works. In Java AWT, I guess I would have to design a specific panel for each unit and provide each unit with a PopControlPanel() call of some sort which would create a popup window.


I'm sorry, it's really little information for us to work on. I'm really shooting blind.


Share this post

Link to post
Share on other sites

I'm sorry, it's really little information for us to work on. I'm really shooting blind.


yes sorry some details coming below...


You should rather have a few solid units than a large amount of units that are similar to the others.


Very true, but in this case I didn't design the game rules...its a boardgame I used to play back in high school and college (oh too many years ago smile.png).     and I don't have to tackle them all at once, just looking to make sure my design would let me get there eventually.   The game was sold as a series of modules which all expand on the core rule  set.    If you were to include all the modules you would get the stats I listed above.   And yes its very complicated totally nerd out kind of game
The game is Federation & Empire by a company called ADB (Amarillo Design Bureau  can be found at starfleetgames.com).     To be clear...I'm building this game for myself and I have no legal right to sell, distribute, etc anything related to the board game (and certainly not use the licenses they in turn have with Paramont Pictures).   I've just always liked the game and since I left professional development many years ago, this is my side project that reminds me I still have some idea how to code... I have no plans to ever let anyone else have a copy...but doesn't mean I don't want to do it right.


anyway onto details about my design


class CoreGame 
/* various functions related to the startup of the game itself called by GameInit() below which I've removed to keep this shorter*/
	void ChangeGamePhase(int state, int newState);
	void AdvanceTurn();
	int GameYear;
	std::string GameSeason;
	int PlayerTurn;
	int GameTurn;
	int GameStep;

	void GameInit();
	void SetNextGamePhase(int &state, int newState);
	int getGameYear() { return GameYear; };
	std::string getGameSeason() { return GameSeason; };
	int getPlayerTurn() { return PlayerTurn;};
	int getGameTurn() { return GameTurn;};
	int getGameStep() { return GameStep;};

//this is my image resource manager class
	ResourceManager<ImageResource> RM_Images;
//pointers to the classes for various game states (again removed some to keep this shorter
	ECONSTEP* econstep;
	PRODSTEP* prodstep;

	std::pair<int,int> ActiveObject;
	std::pair<int,int> LastActiveObject;

//all the various game objects
	std::map <std::string,SHIPCLASS> ShipClass;
	std::map<int,RACE> Race;
	std::map<int,PROV> Prov;
	std::map<int,PLANET> Planet;
	std::map<std::string,MAPCELL> MapCell;
	std::map<int,UNIT> Unit;
	std::map<int,FLEET> Fleet;


Then as an example here is the class for my econstep


	std::map<int,ECONHIST> EconHist;   ///this is a object for holding some historical stats
	FlowLayout* flow;    ///the pointer to the root of the screen

	bool surveyStatus;   //various game logic flags
	bool tugStatus;

	void CalculateIncome();       //game logic for this step that happens without user input
	void InitEconStepControls();



	void InitEconScreen();     // generates the widgets that need to be on screen and sets up listners for input
	void InitEconStepScreen();
	void ConductSurvey();    //just one of the various logic steps which may happen as a result of user input


one last example....this is for one of the game objects themselves (a race)


class RACE

	std::string RaceName;
	std::string ShortName;
	int RaceID, iOffMapProvs, iOffMapMinor, iOffMapMajor, iOffMapSB, OrigOffMapProvs;
	int iCredits, iCommandPoints, iSurveyTotal, iSurveyShips;

//logic functions (in this cas related to econ
	int DetermineOnMapProvs();
	int DetermineOnMapMajor();
	int DetermineOnMapMinor();
	int DetermineCapitalMajor();
	int DetermineCapitalMinor();
	int DetermineCapturedProvs();
	int DetermineContestedProvs();

//these should be private, but haven't moved them yet
	std::multimap<int,std::string> ProdQueue;   //hold the allowed production for each turn
	int team,iEconStatus;
	std::map<std::string,int> mothballs;    //holds lilst os reserve units and count


I used those examples because they are all related.    But the question was asked about logic, you can see there is some above, but the really gory rules come in the ShipClass class. which I haven't needed to spend a ton of time on yet as the real differences come in how units move and fight and right now I'm building out most of the logisitical related aspects of the game (inital unit placement, econonmy, production, base maintence, that type of thing)


Share this post

Link to post
Share on other sites

First question...

Why are you using maps the way you are?


ShipClass;    std::map<int,RACE> 
Race;    std::map<int,PROV> 
Prov;    std::map<int,PLANET> 
Planet;    std::map<std::string,MAPCELL> 
MapCell;    std::map<int,UNIT> 
Unit;    std::map<int,FLEET> 


You are linking an int to a object for example of type race. Surely this should be a vector instead.

Ok here a few things you should consider before starting to code everything into the same class.

As youve stated there can be many rules etc so you need to think about away that the system will be able to extended apon. Below are a few links of design patterns you should most likely use to help make your job easier. Once you have finished reading all of those and understand them, and maybe implement them. Maybe you should have a better idea on how you want to design your system.



Good luck!






Share this post

Link to post
Share on other sites

Thanks I'll certainly check those links out.   And yes I'm using the factory pattern already for everything related to the GUI.


Why are you using maps the way you are?


The main reason was for improved random access.     For example there are LOTS of Units in the game.    But the unit is a fairly basic class.   It has stats about that particular unit, but all of its base charateristics (and special rules) are determined by what ShipClass it is.  And there are also lots of those.    The name if you will for a ShipClass is stored as a string (which is the key in its map) so I can quickly lookup the details about a unit's shipclass withouth having to traverse a vector looking for the shipclass which has a given name.    There are similar relationships say from Fleet to Unit, or Prov to MapCell...


I might have gone overboard here in that they don't all have to be maps (most of the others are pretty small datasets so traversing a vector probably wouldn't be a big deal performance-wise), but the unit to shipclass relationship is really what drove me down this path


Share this post

Link to post
Share on other sites

Ok first of all if you know the name of the ship, you should know which object you are looking for, or have some link to that object in some way. So then you dont need to use a map and just need somewhere to store it aka a vector.


Additionally if you go ahead with your idea finding an object in a map is O(log n) where as if you use a hash map for example unsorted_map it is O(1). I still recommend using a vector though for the first reason.


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
Followers 0