Jump to content

  • Log In with Google      Sign In   
  • Create Account


Need architecture advice


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 skywhnnn   Members   -  Reputation: 103

Like
0Likes
Like

Posted 12 September 2013 - 02:35 PM

Hello,

 

I'm new to gamedev and will appreciate if you can point me to common practices in architecture.

 

Let's assume, we have a multiplayer game. Same instance is present in various contexts:

- data: for database operations or displayonly stuff we don't need any mechanics, just relations and data

- serverside validation: now we need mechanics, but don't need some fields like descriptions/icons/etc, and desperately need optimization

- clientside runtime: now we need everything including lots of media, but as entity/component systems

 

and lots of other stuff like networking, IOC configs, build systems, etc.

 

So, is there any framework to start with, which allows to write code / configure things only once, yet get everything mentioned as result?


Edited by skywhnnn, 12 September 2013 - 02:35 PM.


Sponsor:

#2 Xai   Crossbones+   -  Reputation: 1329

Like
2Likes
Like

Posted 12 September 2013 - 10:06 PM

Your question hasn't gotten a good response because:

1.  It is very very far reaching, broad / open ended and vague.  It doesn't give any clear question you actually want answers to, but instead opens the door for the content of some people entire blogs.

2.  It is not specifying the actual REAL problems you are trying to solve.  The architecure of a flash game, an MMORPG, a peer-to-peer card game, an RTS, an arcade game .. there are all actually somewhat different ... and have different "correct" designs.

3.  You include a lot of partial specifiers of what you want the shape to be, but they are both incomplete and also not in line with how 95% of the people on this forum work.  You sound like a guy with either 4+ years of CS schooling, or multiple years of professional business programming experience ... and your bullet points sound like terms from that domain. 

4.  Some of this isn't game dev related, but is mixed in.  For example, what do "build systems" have to do with anything about game development?  All of the standard general purpose software development build concerns are identical in game development as in normal development (Inversion of Control configuration as well).  So for those topics, you would just use whatever tools are common for your toolchain (things like CruiseControl and Jenkins for CI, things like VisualStudio, XCode, or make/cmake/jam etc for compiling or executing unit tests).

 

And your "lets assume ..." seems a little too much to assume.  you need to define a little more to have common language for this.  what do you mean by "same instance in various contexts".  Do you mean that there are different pieces of code/programs running on different machines to make the 1 thing we call a "game" actually run?  Or do you mean you have a common OO class, instanciated to be each of these things.  The former is of course true for all multi-player games ... but the details vary a lot amoung types.  It is very UNCOMMON to have the same game class running server side as that which knows how to load images and sounds and interact with a user client-side.  These are almost always separate programs, running separate code (but sharing mutliple libraries).

 

Also, your idea of having raw data without validations and a layer with validations is very common in traditional non-game designs, but very uncommon in games.  Games don't usually have any "validations" that they don't need to operate, and if they need them to operate, they usually run in all appropriate contexts.

 

And the idea of running a "simulation" client-side that mirrors what the server does, and then syncing up these states when they don't agree is a full topic all to itself with many articles published.

 

You have simply opened too many topics in 1 tiny partially written thread.  Break your problem down and repost as specific questions for specific areas of guidance.



#3 skywhnnn   Members   -  Reputation: 103

Like
0Likes
Like

Posted 13 September 2013 - 02:04 AM

Thank you for the reply,

 

I understand the question may seem too vague, so I'll try to give a simple narrow example (please don't be picky on whether it's actually a good approach, it's just theoretical case).

 

Let's say, we have a game with weapon "sword" which has "damage" property, and 3 contexts:

 

data context it's present as simple ORM: "items" table (sword), "item_property table" (damage), "item_property_value" (sword damage=1), "player_items" table (Bob has a sword).

In plain OOP context it's present as class Sword extends MeleeWeapon extends Weapon... with "damage" field.

in component context it's present as Entity with MeleeWeapon component which has "damage" field.

 

What am I looking for, is a solution to define that "sword has damage" only once, and services to generate corresponding classes for each context, instead of having to define all 3 separately.

Build tasks: I modify sword damage in the server db and want to produce files required for client update automatically.

Config tasks: I want to keep my data context as is, but  I want the Entity to additionaly have SlashingWeapon and PiercingWeapon components with default values.



#4 PandaDragonThing   Members   -  Reputation: 311

Like
0Likes
Like

Posted 13 September 2013 - 10:53 AM

What am I looking for, is a solution to define that "sword has damage" only once, and services to generate corresponding classes for each context, instead of having to define all 3 separately.

Build tasks: I modify sword damage in the server db and want to produce files required for client update automatically.

Config tasks: I want to keep my data context as is, but  I want the Entity to additionaly have SlashingWeapon and PiercingWeapon components with default values.

 

1) Why would you need all 3 contexts? You'd only need two. The data context could be stored either in some file you ship off with your game, or in a database that your client can access.

2) By having information about swords in a mysql database you can easily change the sword damage without needing the client to update any of their files. If your storing the data context locally from game to game, then you don't edit any of the source code, but rather the simple .txt and ship that out in the next patch.

 

3) In your data context you can specify the type of weapon damage( piercing, slashing, etc.. ) and you can simply attach the correct Component to the entity. I don't know why you wouldn't want to change the form of data context.
 

Sorry if I am misunderstanding you. You're being very vague and not giving very good specifics of what you want.



#5 Xai   Crossbones+   -  Reputation: 1329

Like
2Likes
Like

Posted 13 September 2013 - 12:38 PM

I think you are approching this development effort slightly backwards.  You are trying to solve the abstract development "problems" before creating your program, instead of creating your progam ... and trying to improve on problems you actual run into while doing so.  That's not how good design, architecture, patterns and experience is built.  There are general "goals" and "strategies" in programming (goals include:  don't repeat yourself, keep it simple stupid, clean readable code, consistency) (strategies include:  single responsibility principle, liskov substitution principle, tiered design, factories, polymorphism, interfaces, etc). 

 

Understand that the main goal is that for any given program there are a certain set of lines of code that MUST be written and executed by the machine to make the program work (such as the reading of files, bliting to screen, computing of damage, starting and stopping of sound, processing of input etc).  But these usually make up only a fraction of the actual code in a program.  The rest of the code is organizational overhead.  While there may only be a few ways to draw a texture on a triangle in a video card, there are HUNDREDS of ways to organize and layer code that eventually does so. 

 

These organizational structures, patterns, abstractions ... they have NO INTRINSIC VALUE.  They have value only to the extent that the humans who use them find them helpful for getting to the desired goal.  Accept that your program will not be able to be 100% perfect.  Accept that there will be "some" repitition of code, some ugliness of design, and some inconsistency and difficulty in maintenace.  When trying to get a progam working, the first question should not be how to make it fit a principle or ideal.  It should be how to make it work, to do what the computer needs to do.  And then, the second (or third or fifth) question should be "Is this code as clean, well designed, performant and or pleasing to me as it should be?". 

 

You don't learn to make high quality guitars by asking the luthier to explain to you the "right" ways of making them.  First you learn how to do a specific detail - staining or polishing wood perhaps, or attaching fretboards.  Then once you have done that thing, you ask as to how you might improve at that thing.  Then you move on to another.  And after years, you hopefully are good at all of the skills required to make quality quitars (or computer games).

 

So what I am sugesting (in a long winded and not so obovious way) - is that you bring an ACTUAL EXACT and REAL example of something you are actually doing, and ask for how to make THAT THING better.

 

For instance, if you have a "Sword" or "Weapon" interface or class, and perhaps have made it data driven, and perhaps are now looking at your code, unhappy because you feel like it is too much duplication, you then would be asking, "How might I generate this set of artifacts (or their equivelent) from a single source to reduce this duplication?".  By posting your existing code, and your question that way, people can help you factor out commonality in your design, or push you toward a more appropriate abstraction that would not create as much redundancy.

 

People cannot tell you how to generate code in general, or recommend or judge abstractions in general ... but only in specifics.

 

I will give you my example.  I started on some simple 2D game stuff about 15 years ago.  Early on I produced some results but had really ugly code and bad abstractions.  How do I know they were bad ... only because I had a hard time keeping strait what code was responsible for what feature and where to change things as I made my game better, without creating bugs.  So over time, my code moved toward certain shapes.  And many of these shapes eventually settled and haven't moved much in many years ... because they are now good expressions for what I need them to do (in a relative sense).  I can't remember my "bad" designs from 15 years ago.  But my current concepts are fairly simple.  These are NOT necessarily designs OTHERS should use, they just work for MY code basae.  I have "game resources" which represents things which need to be managed by resources managers (such as images and sounds), this general concept is not a class but a term, I have actual classes for the different resource domains including "ScreenResource", managed by a ScreenManager, and SoundResource by a SoundManager, etc.  There is some repitiion here, which I have factored into ResourceUtils, but mostly they are different.  I have GameObject which represents everything which interacts with the "game world" and affects the management of "game state".  I have a Game base class which represents an instance of the logical game, which is subclassed for each logical game such as ColorInvasionGame, which is different than my Application class which represents a client progam that the user uses to play or serve a game, which has derived classes such as ColorInvasionWin32App and PokerServerApp, etc.  When it comes to my simple 2D game sutff, I have IPhysicalObject which is anything with a position in the "physical" game world, and IMovableObject which is a physcial object that may change position, and IActorObject which is a movable object which may cause changes, usually via user input, AI action, or timers or other event triggers.  Of instance an asteroid is a movable object, but a pirate ship is an actor object.  Each of these adds an API to interact with the additional features it provides, while letting the common simple physics/collision engine work on physical objects.

 

The above has nothing to do with your original question, because I still need more details about the code you "have" that isn't as good as you'd like to have, to give you better advice.  The above is like 10% of the primary classes of my game design, which is broken into over 100 classes, about 30% of which are heaviliy data driven (and would be approprite as DB tables or configuration files) ... there is no 1 size fits all design.  My engine doesn't support 3D, doesn't do real physics, can do either turn based or real-time, and is only made to handle the small indie hobbiest stuff I like to play with in my spare time.  It is underwhelming and poorly designed in some areas, and overengineered in others ...

 

Just make code work, do something you like, and make it better piece by piece.



#6 skywhnnn   Members   -  Reputation: 103

Like
0Likes
Like

Posted 13 September 2013 - 02:09 PM

Ok, let me explain myself deeper.

 

I'm asking not as a developer looking for a practical guidance, but as a project manager looking for theoretical opportunities.

I understand very well that architecture alone won't get you anywhere, however I work with people instead of working with sourcecode (well, I do work with sourcecode, but it's secondary) — and it's a huge difference. I can find an expert in, say, pathfinding or rendering via certain engine pretty easily, however noone can grant me that he won't get depression in the middle of a project, or get an offer he can't resist, or whatever — I had experience of the course changing because of really absurdous reasons. And I can tell you, specialist market is very limited if you have a tight budget, so having an opportunity of flexible architecture as hedge is very important, cause it's often far more effective to rebuild project with new architecture which fits your developer than try to make him switch to an old one.

 

In quick web projects, or complex enterprise projects this is less of a problem (everything goes for former and strict standards for latter), but I find gamedev to have much more room for freedom.

 

My context examples were really just examples — I'm simply looking for an example solution to have one codebase for multiple final patterns.

 

I had experience of implementing smth similar for 2 contexts, but it was quite terrible and specialized for a certain project therefore nonextensible, while making an extensible one would require too much time, that's why I'm looking for something already existing.



#7 Xai   Crossbones+   -  Reputation: 1329

Like
0Likes
Like

Posted 14 September 2013 - 09:20 PM

Fair enough.  Now the bad news.  You will probably not find this, or at least not here.  While there are a fairly large number of professional game developers here (relatively speaking).  It is kinda a boys network where they talk shop and help each other with technical problems ... and help a lot of beginners out getting started.  The attitude of the forums here is people talking about what they are passionate about, and not a whole lot of people here are passionate about general code organization, standards and architechture (actually that's not completely true, but ...)

 

Honestly, most game development code traditionally has been poorly architected from a genreal practices point of view - obviously there are exceptions to this, but it was the norm.  Even seperation of concerns are often violated in the name of performance.  This is changing lately, with such big budget costs, the industry has had to get much more "formal" for AAA titles.  But then a lot of people just started doing mobile apps, and the majority of those are done like quick web projects (no design, no arch, just whatever the coders felt like playing with).

 

You might have some luck looking around for existing open source projects and talking with them about their specific architectures.  Also, some of the professional projects have been open sources after their main lifespan (such as Doom/Quake, etc).  you could look at those to extract ideas.  Probably the best place to look might be if any of the decent and indie or professional level game engines have sample programs (you know, unity, ogre 3d, irlicht or whatever) ... if they have sample program they MIGHT have used decent architecture in them to help people learning.  But I can't promise you they have.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS