Become a fan of Slashdot on Facebook

 



Forgot your password?
typodupeerror
×
Programming IT Technology

Designing Multiplayer Game Engines? 431

mikera asks: "I'm a pretty experienced programmer but I've just embarked on my first (massively?) multiplayer strategy game. To make things even more interesting, I've decided to write it in C# and pick up a new language at the same time. I've chosen a client-server architecture where the server holds the one 'true' state of the world. The only communication from clients would be commands to units, which is simple enough, but the server will have to propagate game state changes (events) to all clients. I would like to ask Slashdot readers if they have solved a problem like this before or can offer some opinions on the best way to implement a solution."

"Lag is not really critical, but I still want things to be responsive and it must scale up well with the number of clients. The size of the map data, the complexity of the objects and bandwidth constraints rule out sending the complete game state, so only incremental updates will work. The situation is further complicated by the need to limit updates to just the areas of the map that are visible to a given player/team - this is clearly necessary to prevent client-side hacks such as gaining full map knowledge.

I understand the theory well enough, but I'm interested in practical advice on how to implement a solid architecture. What should the object model look like? How do I propagate events that are only partly within a client's field of view? Are there any novel features in C# that might make my life easier? How can I make the networking code as transparent as possible so I don't have to write SendUpdate() after every assignment?"

Your comments, insights, hints and flames are eagerly awaited."

This discussion has been archived. No new comments can be posted.

Designing Multiplayer Game Engines?

Comments Filter:
  • by thecarson ( 514020 ) on Sunday February 03, 2002 @05:33PM (#2947578)
    Holy Mac [holymac.com] has the transparent networking architecture in a C# framework. It should work well for what you're trying.
  • by Anonymous Coward on Sunday February 03, 2002 @05:33PM (#2947582)
    worldforge [worldforge.org]
  • by peripatetic_bum ( 211859 ) on Sunday February 03, 2002 @05:34PM (#2947584) Homepage Journal
    Having been on the dev-team of a popular MMPOG, I have to say that while your ideas are fundamentally correct, but now is not the time to learn c#, just to add another language to your CV. In addition, C# is too OS limited as it stands and you need to be thinking outside the box.

    Thanks
    • by FFFish ( 7567 ) on Sunday February 03, 2002 @05:49PM (#2947668) Homepage
      Especially considering that, say, Python already has MP libraries. A research paper from UO [asbahr.com], another fellow who's trod this path before [ufoot.org], several MUD/MOO/MP libraries and games [vex.net], Merchant Empire [sourceforge.net], Twisted [librenix.com], Eve [eve-online.com], and so on.

      Using Python would allow this fellow to achieve his goal of learning a new language, fast. He can then properly focus on the important things: program structure and gameplay.
      • by JasonAsbahr ( 54085 ) on Sunday February 03, 2002 @07:22PM (#2948064) Homepage
        Hey, thanks for the plug. Here's an open letter to developers about my new project, Netsu. It uses Python, the Nebula Device, *and* Twisted...

        Greetings,

        I'm a professional game developer who has committed a large portion of his adult life working on virtual worlds of one sort of another. Recently, I worked on Ultima Online 2, which some of you may have been looking forward to playing. I know I was! :-)

        I'd like to talk to you a bit about my current project, 'Netsu', which is the culmination of many years of background work. "Netsu", Japanese for "heat" and "fever", is an anime-inspired world which incorporates multiple perspectives of play and a reputation network for players to self-organize. It's going to be fun.

        Currently, I'm working on combining a number of existing open source technologies to build the new virtual world system. These include the 'Nebula Device' 3D engine from Radon Labs on the client side, the Twisted framework for server-side and client-server communication, and (as the project moves forward) the OpenCyc knowledge base as server-side archetype repository and artificial intelligence server.

        As I develop use cases and other design documentation for Netsu, I intend to keep them as portable as possible between gaming systems, so that they can benefit the most people. I anticipate this work feeding back into Twisted, expanding it to be a more general simulation framework, and into Nebula, adding network support and in-game world editing tools.

        So where did this project come from?

        The genesis of the project began with my work on virtual reality systems in the early 90's. I developed virtual building walkthroughs for architects, VR games, and created the first hardware accelerated PC-based virtual actor system for Compaq.

        This work was all done with C and C++, and it was during this period that I ran up against the need for a dynamic and interactive way to "reach inside" the simulation and manipulate the code and data directly. And that's how I first became acquainted with the language Python.

        The next major phase was to build a 3D client engine with Python embedded as a control language. The fruits of that effort are described in the paper I presented at Python 7, "Beyond: A Portable Virtual World Simulation Framework". (This was also the first mention of 'Netsu'.)

        In 1998, the path of development took a turn when I was recruited into Origin Systems to work on developing the Python foundation for the Ultima Online 2 project. The focus during the period was on innovation on the server side and on client-server communication. The results of that labor are described in another paper presented at Python 9, "Python for Massively Multiplayer Virtual Worlds".

        Both papers are here [asbahr.com].

        However, to this point, all the software developed for these projects was closed source. The desire for an open source virtual world system was lurking in my head, but it wasn't until the O'Reilly Open Source conference in 2000 that my plan for the open source virtual world crystallized.

        At the 2001 O'Reilly conference, while presenting on the UO2 design work, I took the opportunity to discuss my plans for the future open source virtual world system. The response was extremely positive.

        So what are next steps to realizing this goal?

        Glyph (the originator of the Twisted project and a fellow ex-Origin colleague) and I have been meeting periodically over the last few months to discuss these issues, which intersect nicely with his long term plans for gaming in Twisted. I've also been meeting with the Cycorp folks (who happen to office just down the road from me) to discuss integrating Cyc and driving Python class generation from Cyc.

        I recently integrated Python into the Nebula Device, which allowed me to easily integrate the PB remote object communication protocol and made Nebula the first 3D clients for Twisted. Over the next six months, several major components will come online, including character creation, character motion, the GUI system, basic terrain management, character inventory, and combat.

        As I wrap up my current consulting project (porting Python to the Playstation 2 and developing a GUI for designers to build Python logic), I'm devoting 100% of my time to Netsu and open source development.

        It is my hope that this collaborative approach for virtual world development grows, spreading outward and providing a foundation to help other developers build their own virtual worlds and enable the sharing of code and art resources between worlds..

        If you are interesting in finding out more about the project, drop me a line via email and tell me a bit about your interests and background.

        Cheers,

        Jason Asbahr
        jason@asbahr.com
      • ...he might as well learn a language that's actually useful, rather than C# (pronounced ``see-crash''). Ruby is not only extremely useful, but you also don't spend too much time counting spaces to make sure your code blocks are where you think they are... (-:

        Oh, and you can run it in a JVM (did I mention portability?) and spit it out as C if you like.
        • Counting spaces? (Score:3, Informative)

          by cduffy ( 652 )
          I've never had to count spaces with python -- and it's been my primary application language for years.

          It's a fine point to try to debate with, until you try to actually use the thing and realize it never comes out at all (as opposed to counting curly braces in other languages, which really has happened to me).

          Further, Python too can be run in a JVM or converted to C.
    • by Anonymous Coward
      Who cares if it's OS Limited? He wants to use C# and target the usual 90% of the market.

      Use the BEST tools available for the project you are designing. Anyone who tries to tell you otherwise has no concept of proper development.
      • Use the BEST tools available for the project you are designing.

        That's not the reason he's using C# though. He appears to be going with it because it's the latest buzzword.

        - A.P.
      • Since a major development effort for a game of this type is on the server side, I wouldn't go as far as saying C# is the best tool available. It certainly has nothing to do with the 90% client side share of Microsoft Windows.

        I would definitely advice against using anything Win32 specific on the server side. It's just plain common sense to avoid limiting yourself to Wintel servers.

  • WorldForge (Score:4, Redundant)

    by Shiny Metal S. ( 544229 ) on Sunday February 03, 2002 @05:39PM (#2947605) Homepage
    Take a look at The WorldForge Project [worldforge.org]. You probably won't learn more anywhere else.
    • Re:WorldForge (Score:5, Insightful)

      by nehril ( 115874 ) on Sunday February 03, 2002 @05:50PM (#2947670)
      there is an old (1999 ish) article at www.gamasutra.com/features/19990903/lincroft_01.ht m (free reg required) that talks about all the net play problems that the Xwing vs Tie Fighter team faced.

      I remember reading it a while ago before you had to register, it had alot of insights as to saving game states, lag, updates, and "late joiners" to a game.
    • What an annoying site. Won't display anything if you're using WebWasher [webwasher.com] to block banner ads, it just says "WebWasher not allowed".

      Just FYI if you're using WebWasher, in the "Proxy Engine" section of the options, turn on "No identification as WebWasher with server", and you'll be let straight in.

      What's the sense in blocking WebWasher? If you block people, people aren't going to see your ads anyway, the people blocking them are exactly the people who aren't going to click on them anyway. And especially as WebWasher has an option to hide itself!


      • *shrug*.

        You do know, don't you, that in the long run a lot of services will probably go over to micropayments, right? Bandwidth costs _money_. Someone has to _pay_. If it's not consumers via advertising influence, it will just be someone else.

        C//
      • What's the sense in blocking WebWasher? If you block people, people aren't going to see your ads anyway, the people blocking them are exactly the people who aren't going to click on them anyway. And especially as WebWasher has an option to hide itself!


        The logic is that you don't get the content that those ads are paying for. Sure, it has the option of hiding itself, but this is better than nothing. It seems that this option isn't turned on by default, or I would think that you wouldn't have run into the problem.

    • Re:WorldForge (Score:4, Insightful)

      by Znork ( 31774 ) on Sunday February 03, 2002 @06:45PM (#2947908)
      Um, if you're working on a commercial project, be careful if you look at worldforge beyond architecture documentation, without at least talking to your legal department (or lawyer) first. WF is GPL and you are no more safe against copyright infringement suits if you copy GPL code than you would be if you got your hands on the code to EverQuest, Anarchy Online, or any other MMORPG.

      Looking at code is tricky buisness. You can do it in some ways, and you're probably safe as long as you're not creating a direct competitor with a commercial product, or a work-alike of something. If you do a clean-room implementation of something there cannot be even a chance that you've seen the competitors code. If you're doing your own thing, and just glance at the code to get a basic feel for how they've done things, then write your own, different code, you can probably consider it fair use. Maybe. But it's tricky territory.
  • by EraseEraseMe ( 167638 ) on Sunday February 03, 2002 @05:39PM (#2947612)
    First: Ignore the nay-sayers who say "Don't do it in C#"
    An argument over the language it's programmed in will only make you lose time on what is truly important, the project itself.

    Second: Ignore the nay-sayers who say it's too big of a project.
    By the time they give you a full, thought-out reason why you can't do it, you'll be half-done.

    Third: Do listen to people who have done it before.
    Browse programming newsgroups, MMORPG newsgroups, hopefully one of the coders will connect and you'll be able to pick their brains.

    Fourth: Don't get dragged into the open source/closed source fiasco.
    You should be programming for just yourself, unless you have a team, then it's a free-for-all

    Fifth: Cut yourself off from all human contact and work on it.
    Stop showering, stop feeding the cat, forget the wife/kids/work. Finish it as soon as possible because I want to see what you're working on :)
    • the scary part is that the parent post is modded +5 because of this line....
      Fifth: Cut yourself off from all human contact and work on it.
      Stop showering, stop feeding the cat, forget the wife/kids/work. Finish it as soon as possible because I want to see what you're working on :)


      come on you all know it's true!
    • I mostly agree, except this one:
      Second: Ignore the nay-sayers who say it's too big of a project.

      By the time they give you a full, thought-out reason why you can't do it, you'll be half-done.
      The nay-sayers are probably right here, and if you research to people who've done it before (rule 3), you'll notice the vast majority of such projects fail.

      You must break a project like this into smaller pieces. You must have a forseeable point when you can release something. You can't forsee the end of a project as big as this, so you have to design intermediate points into it where you have something that is at least interesting to other developers, but much preferably is of some interest to gamers (even if only forgiving gamers).

      Open Source ideals aside, it's very hard to maintain dedicated to something that only you have ever seen. Also, incremental development is just more likely to be successful.

  • Mud-DEV mailing List (Score:4, Informative)

    by Oriumpor ( 446718 ) on Sunday February 03, 2002 @05:40PM (#2947619) Homepage Journal
    the mudd developer mailing list is an excellent source of information on exactly this sort of topic... although not specifically regarding the STRATEGY portion of online gaming... most of the issues you have spoken of have already been resolved... take a look at the archives publicly available at https://www.kanga.nu/lists/listinfo/mud-dev
  • FreeCiv (Score:5, Insightful)

    by RedWizzard ( 192002 ) on Sunday February 03, 2002 @05:46PM (#2947652)
    Sounds like the architecture you're planning is quite close to FreeCiv's [freeciv.org]. You might want to take a look at that.
  • Yes I Have (Score:3, Funny)

    by Anonymous Coward on Sunday February 03, 2002 @05:50PM (#2947674)
    Back in '97 I did the exact same thing in Perl. It was actually a multiuser accounting package, but the principals are the same.

    By blasting debits, the accountants could increase the net value of the company. If they missed, the debit's could rip through the balance sheet of the company...rendering it's offshore shields useless. If that happened a few two many time, it could spin the whole company into bankrupcy and court-ordered liquidation.

    I found that the biggest problem was latency. I worked on some time compensation algo's, but I didn't get a chance before I was right-sized by the company.
  • freeciv! (Score:3, Interesting)

    by jdavidb ( 449077 ) on Sunday February 03, 2002 @05:50PM (#2947678) Homepage Journal

    Yes, it's been done before, by freeciv [freeciv.org]


    I never miss a chance to plug freeciv, because it's my favorite game, and a prime example of what good can come from programming free software.


    freeciv takes the same client/server approach you're advocating, and, as near as I can tell, scales somewhat. Now, if you've got a lot of graphics going from client to server, it might not work the same. So I recommend freeciv just as a starting point.


    Have fun!

  • Some Advice (Score:5, Interesting)

    by Shelrem ( 34273 ) on Sunday February 03, 2002 @05:51PM (#2947682)
    I'll avoid most of my comments about your choice of language because most of it is of a political nature, rather than practical one; however, I really wouldn't suggest trying to make a massively multiplayer game with a language you're unfamiliar with. It's quite an undertaking even with a language you know. I know; i'm working on one.

    As for the networking code transparency, this one seems fairly obvious to me.. Just keep a datastructure containing all the changed or "tainted" objects as you go. Make mutator functions of your classes set objects as tainted. Then, just do the networking updates once or twice every time through the main loop (assuming it's in the same thread. Otherwise, you can implement something that might end up being a little more efficient).

    As for updating only what the player needs to be updated on, this seems like a question of algorithm efficiency. I don't know the specifics of your game, but with most massively multiplater games, transmitting the entire world state, or even the entire list of changes to every client, every cycle would be insane. So, you have to only update the section of the world that the player can see. How to do this well depends on the internal structure of the world, and what sort of stuff the player can "see". If the game is room-based, then this is easy. If the player can always just see a specific size circle or rectangle around him, this is also easy (each event can check distance to all players in its regeon). If it works like most RTS with arbitrary viewing areas, then you might have to be a little more clever. Whether this is even much of a concern is really a question of the number of people supported, and the expected hardware this'll be running on.

    Hope that helps,
    ben.c
    • I'll avoid most of my comments about your choice of language because most of it is of a political nature, rather than practical one; however, I really wouldn't suggest trying to make a massively multiplayer game with a language you're unfamiliar with.

      This is very good insight. However, I think C# is a great choice and an exception for this situation. If you have a C++ or Java background, learning C# is extremely trivial. Plus, the networking libraries of the .NET Framework are very intuitive.
  • by hieronymous72 ( 454289 ) on Sunday February 03, 2002 @05:52PM (#2947694)

    AOP might be a great way to handle the problem of dealing with the update issue. You can program as though they are on the same box and code your aspects to deal with what to send and when. It's not an easy thing to learn (think when you went from procedural to OOP) but it can pay huge dividends.

    I use AspectJ (www.aspectj.org) but that's for Java...I don't know of any AOP toolkits available for C# since it's such a new language.

    Good luck.

  • Some advice... (Score:3, Insightful)

    by powerlinekid ( 442532 ) on Sunday February 03, 2002 @05:56PM (#2947717)
    If you want to maximize your users, why not use java instead of c#. The syntax is really similar and the performance difference is negilable. On top of that, your users can run the app is solaris, linux, and windows. Along with that, you can build a client java app, so that users can just use IE, Mozilla or Netscape to play the game. My experience with network clients and users, is that they like to use what they're accustomed to. By embedding something into a browser you're cutting down some tech support and installation problems. The other deal is c# is not too tested and requireds special installations for Win 9x and 2000 because they don't come with it. Everybody doesn't have XP yet. I've implemented some stuff like this in java before and it works very nicely due to java's nice network libraries.
    • DON'T LISTEN (Score:3, Insightful)

      by augustz ( 18082 )
      Please DO NOT LISTEN to this guy.

      Try supporting a large java app, with folks who may have to install JRE's, open up security settings in their browser sometimes talking to an admin before being permitted to do so, who will find ENDLESS incompatabilities between various versions, and will discover that that java does NOT look "like what they are accustomed too" and you have yourself a gargantuan support, installation and education headache the like of which you probably have only had nightmares about.

      Mix that with the fact that you WILL be taking a performance hit by going to java, and the difference in performance between Java and C# is only likely to INCREASE and the technical arguement becomes even simpler. Remember that Microsoft will be droping Java support as fast as they can, do you think future IE/Windows is going to have a JVM? No chance.

      Mix with the face that C# at least so far appears to be an HONEST open standard, unlike Java's endless standardize promises, which have been repeatedly broken so that the only ones who continue to defend their promises of open standards are the insane java zealots, and you have a solid business (open standards are better, safer, and do not put you on the hook to a commercial company) and even moral decision that is clear cut.
      • Re:DON'T LISTEN (Score:3, Interesting)

        by Sentry21 ( 8183 )
        A few comments about your post...

        Try supporting a large java app, with folks who may have to install JRE's, open up security settings in their browser sometimes talking to an admin before being permitted to do so, who will find ENDLESS incompatabilities between various versions, and will discover that that java does NOT look "like what they are accustomed too" and you have yourself a gargantuan support, installation and education headache the like of which you probably have only had nightmares about.

        If you need a JRE, include one with the game installer.

        If you do not know how to change security settings in the browser, then use the regular version. If you have an 'admin', you should probably not be playing a game (at work? at school?).

        If you include a version of the Sun JRE that your product works with, then your product will work.

        I do not see how java can be 'what they are accustomed to' or not. 99.99% of games have a custom UI anyway. Java apps can be double-clicked on. What is the issue here?

        You will be taking a performance hit going to java. Most of a game's speed depends on the video card. It is hard to max out a modern CPU. With a JIT compiler (or a native compiler, if you so desire), you can eliminate most of the speed hit.

        C# appears to be an honest open standard created by a company that has historically proven that they have no interest in keeping interoperability any longer than it takes to lock in developers. They will undoubtedly come up with 'extensions' that will make life, if not impossible, then at least difficult for any non-MS users/developers.

        I would go with Sun's stupidity over MS's malice any day of the week. At least I know Sun isn't -trying- to screw me over.

        --Dan
  • Map/Update idea... (Score:3, Interesting)

    by powerlinekid ( 442532 ) on Sunday February 03, 2002 @06:02PM (#2947741)
    Divide the map up into areas where you want all users to access the same things. Use a broadcast message to send mass updates to this. This cuts down individual client updates. Say there is an earthquake or something in the game. Broadcast this data to all those that affected in one big message. Java has features for this although I'm sure c# does also.
    • Broadcasts would 'hardcode' his game to only work on LANs.
      Or how is he supposed to 'broadcast' to multiple addresses?
      I believe IPv6 may have something for this, but nothing I know of in IPv4

      Besides, are the clients supposed to ack this information to the server? If so, you have per-client overhead, and at best saving around half of the overhead of sending it to all clients separately.

      -- Flamebaits in sigs: The best way to spread stupidity
  • Thoughts (Score:5, Interesting)

    by Joe Rumsey ( 2194 ) on Sunday February 03, 2002 @06:05PM (#2947755)
    If you've never written a client-server game at all, you might check out Netrek [netrek.org] for some basic ideas. It isn't massive, but it is client-server, and it's where I learned most of the important things I know about network programming in general (and I do, in fact, get paid to write network code for games now.) Quake or Quake 2 source are probably also good things to look at, though I haven't seen their code personally.

    None of those solve the major problems you're really asking about though: how to decide who gets to know about what. Worldforge [worldforge.org] is the only open source project I can think of to point you to in that area. Perhaps some MUDs might be useful as well, but they tend to be based on rooms, not areas, which doesn't translate well at all to most other games.

    Probably the biggest problem is avoiding N^2 operations as much as possible. At some level, there's no way around it: N players in an area generate events that have to be propagated back out to N (or at least N-1) players. This obiously makes scaling to arbitrarily large populations difficult. On the other hand, if you can guarantee a set maximum number of players in an area/server/whatever, you can target that maximum and not worry about it a whole lot.

    A slashdot post isn't really the right medium to answer this question. There aren't any quick and easy answers, you need to figure out what makes sense for your game on your own. I've spent a large portion of the last year thinking about these problems myself, and I wish you the best of luck on it. I'm having a blast myself, but it's also the most challenging work I've ever done.

    I am interested in hearing your reasons for using C#. That's actually somewhat shocking, but maybe it's just ignorance on my part. I can't imagine why you'd want to bet the farm on such an immature system, regardless of the strengths you've perceived in it. What does it do for you that C++ doesn't, and is it really worth it?
    • Hi Joe!

      I agree that Netrek certainly has example aspects of what this guy is trying to do. State is held entirely on the server, and only a subset of information important to the player based on their tactical perspective is transmitted.

      Now as to why C#. I don't understand what this guy is exactly trying to do. A massive multiplayer strategy game sounds like a rather large undertaking.

      I have been throwing around the idea in the back of my head of writing a version of the Netrek server and client using C#. As far as worth, I see it purely as an educational undertaking. If it works, then the result may be more maintainable and extensible than the existing C code.

      In the case of netrek, I doubt performance is an issue considering the game used to run on minimal hardware by todays standards. But in a massive multiplayer strategy game, I could see that as an issue.

      I probably won't go forward with this because I have little interest in games these days. But it is interesting to think about.
  • by jon_c ( 100593 ) on Sunday February 03, 2002 @06:05PM (#2947756) Homepage
    First off let me say that you are way in over your head, don't go into this thinking you will actually make a everquest. Everquest took 4 years to develop with a full staff of experienced programmers and artists, DAoC only took 2 years, but they had a very complete engine to work with. However i do not want to discurege you, attempting this, while foolish is a noble task where you will certainly learn a great deal. that being said:


    The only communication from clients would be commands to units, which is simple enough


    Generally the way this is handled is setting up a TCP communication for critical information, such as the stats of the player, text communication etc.. then send small UDP (connectionless) messages for non-critical data, such as player and monster movments. Be warry of using TCP for everything, this is something Anarchy Online did, which caused some pretty massive problems on the server side.


    The situation is further complicated by the need to limit updates to just the areas of the map that are visible to a given player/team - this is clearly necessary to prevent client-side hacks such as gaining full map knowledge.


    There are two approches for this, one is a moving 'buble' of information, where you update the client with all data within a certain radius, another is the zone approach (i.e. everquest) where you send the an entire zone worth of information. Note that you are not sending everything, only monster,player movment and state (are they fighting).

    What should the object model look like?

    I have no idea, i imagine it would be far too large and complex to even describe in a slashdot post. However i recommend you look at it from a top down view, then try implementing from the bottom up. For example, you know that you have a 'world' and the 'world has players, monsters and items', 'players and monsters' could be concedered 'actors' with certain command antributes. 'actors interact with items' etc.. you should start seeing how to construct a object model. also don't worry about what this looks like at first and you will no doubt be revising it as you go a long, make things the work and compile so you have some possitive feedback for you hard work. When things seem out of hand, step back, make some coffee and draw out what you have and try to thing of a way to break it apart into managable sections.

    ok that is all, good luck.

    -Jon
  • by Rayonic ( 462789 ) on Sunday February 03, 2002 @06:05PM (#2947757) Homepage Journal
    It sounds like you're taking a lot of the stuff off the client's hands to add security. While this is a good idea, I can't stress enough the importance of the client predicting the positions of players and objects. Objects especially are easy to predict (an arrow arcing through the air, something rolling, etc.) Movement prediction can make or break a game; you'd be surprised how little tolerance players have for people/things jumping around with no movement in between.

    Heck, players can be pretty predictable objects themselves, if you want to get fancy. Most games have pretty simple algorithms predicting the future state of a player character (if player X is moving in a straight line, he'll probably continue to do so.) But I think you can get fancier than that. What about curves? (circle strafing) Or if the player is repeatedly hitting a button every half-second. (chopping wood?)

    It'd take a lot of coding, but the master server could conceivably take note of each player's input characteristics and compile some sort of "personality" profile for each one, which it could transmit to clients every time they start up, to help with their local prediction.

    Please note that I have no idea how much CPU time this would take up,
  • by king_ramen ( 537239 ) on Sunday February 03, 2002 @06:06PM (#2947759)
    having one "master state" will be hard to scale. Make different states for different "zones" (either physical as on a map, or having to do with aspects of the game), and then you can delegate zones (or subzones) to other machines. Do this also for object-classes (player attribute state may be separate from object state, separate from location states, etc.) so that different subsystems can be independently optimized. A cluster of master META routers can glue these parallel states together to provide a single entry point and consistency. Round robin DNS would be sufficient in most cases (esp if using UDP or persistent (stateful) TCP).

    Obviously, until things ramp up, you should be able to do all this with one server, but making these parallel states will make scaling much easier when the need arises.
  • Two strikes ... (Score:5, Interesting)

    by Ldir ( 411548 ) on Sunday February 03, 2002 @06:06PM (#2947761)
    If this is a commercial project, please tell us the name of the game so we can avoid it.

    In all seriousness, in my opinion (unless you're doing this solely as a personal learning experience), you are starting with two critical strikes:

    1. You're trying to do a major project in a language you don't know (and an immature one at that).

    2. You're trying to do a major project in a genre with which you have no experience.

    Either one could cripple the project. Put them both together and you're doomed before you start. You may eventually make it work - sort of - but it will never work well, and it will be riddled with bugs.

    I encourage you to start by developing a small multi-player game in a language in which you are already proficient. This will let you focus on the design and structure without fighting the language. Keep it simple, manage the scale, but incorporate the kinds of capabilities you want in the final version.

    When you've got that working, throw it awy and develop it again in C#. Since you're starting with a working design , you're now free to focus on the mechanics of the language. You need time to learn its limitations and idiosyncracies, and to become proficient. (I will let others debate the wisdom of C# - I'm skeptical of all proprietary languages, especially until they're field-proven.)

    Once you have succesfully finished a small project in C#, you can begin planning your real game. Based on your experiences, you may decide to scrap C# entirely. If you choose to stick with C#, then throw away ALL of your original code and start over. No matter how good you think your first code was, by the time you finish the big project you will know that it's crap. Might as well get it out of the way up front to reduce re-work and improve the overall quality.

    Of course, if this is a project you've been assigned as a commercial effort, you won't be given the luxury of doing it well. You probably already have a deadline pulled out of thin air, and you're probably already behind schedule. Speaking as a pointy-haired boss who actually has significant coding experience (a long time ago, in a galaxy ... etc.), most PHB's have no clue when it comes to software development. They work with the suits to draw up pretty little Gantt charts, and haven't the foggiest notion as to why they are complete fantasies. You can see some of the results in the bargain bin of your local Best Buy, or in the "still delayed" list of your favorite gaming magazine.

    In any case, good luck.

    • 3. You are planning to use an unproven language purely for its hype.

      So to sum up, you have no clue what you are doing (the very fact that you asked it on slashdot, of all things, is an evidence of that); you don't know the language you want to use; and, instead of evaluating your options, you decided to ride the hype, perhaps to make your CV buzzword-compliant. Therefore, this project is doomed before it is even started.

      Oh, and just to throw in some more buzzwords, I suggest you make it a Web service using the .NET framework combined with an innovative XML protocol for the information superhighway! Wow! That will impress every PHP on Earth.
  • Is it this easy? (Score:2, Insightful)

    by monk ( 1958 )

    Just thinking out loud, but it sounds like the client subscribes to updates from units in a particular "area" (defined however you like) and will automatically be subscribed [sun.com] to the "partial" or "distant" updates for adjacent areas. A client's key allows it to subscribe to exactly one area at a time.

    Server side you keep a list of client subscriptions and something like the PropertyChangeListener [sun.com] approach from Java to simplify the updates from your units. I think any solution has these or similar elements, your implementation will depend on what C# can do for you. I don't know anything about that. I used Java links as examples , since I didn't find any C# API links out there.

    Please let me know how things go, and I'm interested in feedback on my ideas from more experienced MMPG builders out there.

  • by 2nd Post! ( 213333 ) <gundbear.pacbell@net> on Sunday February 03, 2002 @06:11PM (#2947781) Homepage
    Assuming you have a secure communication channel (whether it be trust, PKI, or other encryption), you can try to reduce lag by distributing resource request and allocation.

    Rather than the server handling 100 clients, when it needs to push out identical data to all 100, you push out data to 10 of those clients and rely on those 10 clients to push out data to another 9 clients.

    You can also push in the other direction. When client 1/100 says 'Hi!', rather than pushing it to the server to push it to 100 clients, the client pushes it to the client he's attached to, who pushes it out to the other 8 people, as well as to the server. The server then pushes the 'Hi' out to the other 9 clients it's connected to, who pushes out to their respective 9 clients.

    It's akin to treating the connection to the server as some sort of nested tree; you introduce latency but reduce the amount of server lag.
    • Interesing idea (you are basically describing a P2P network), but "latency" and "server lag" are the same thing. Lag is the ability to for the canonical server state to diverge from the client state, and this occurs because because of latency in sending/retrieving updates. In a time-critical application, where state needs to remain as consistent as possible in all views, your idea is problematic. This is especially the case when you start to consider clients with high-latency connections of their own.

      I think there is also the problem of peer-to-peer connections from a security point of view. Hacking a naive player's machine would be quite easy for a directly-connected, semi-sophisticated player.

      • There's several kind of lag to deal with:

        Server getting too many requests for resources.

        Client getting pushed too much information.
        Client getting pushed too little information.

        Planned, intentional, latency is much more workable than a classic DoS. As a workaround, for example, you introduce locality.

        IE, people get clustered around deputized local servers, so that you can bypass spanning the network.

        If I broadcast 'Hi', it only needs to go up to the server and back down, but it's only spread around the local group. That way people in the virtual geographic space don't get spammed with my packets and lag is much reduced.

        Anyway, that's just an idea.
  • You say this is your first multiplayer startegy game and you plan to learn a new language while doing this...:

    If you were te write your first novel, would you consider writing it in a new language just to learn it ?

    If you just want to learn or fool around with some code, go ahead. If you want something decently done, use everything you already know... there will be more than enough challenges and things to learn down the road without looking for them.

    just my 2 cents.
    --red
  • by krs-one ( 470715 ) <.moc.smuroflgnepo. .ta. .civ.> on Sunday February 03, 2002 @06:18PM (#2947810) Homepage Journal
    First, you need to head over to gamedev.net [gamedev.net] They have a huge array of information and an online forum devoted to games that you would not believe.

    Next, C# is not the way to go. Its a new language, both in the programming world and to yourself. You'll only dig yourself into a pit with it. I would suggest C/C++ for a 3D engine.

    Finally, assuming this is a 3D engine (which, if it wasn't, would have no chance of making it in todays world), pick what 3D API you are going to use. Since you are chosing C# as the language, I assume that you have to pick DirectX (am I right in my assumption). However, if you were to pick C/C++, you could use OpenGL, not only the better of the two API's, but then its instantly portable to other operating systems.

    Hope this helps.

    -Vic

    P.S. See sig for the game engine I am writing.
  • by nsample ( 261457 ) <nsample AT stanford DOT edu> on Sunday February 03, 2002 @06:22PM (#2947822) Homepage
    One thing to realize is that MMPORG-style worlds are just that, for the most part: worlds. But more critically, they're worlds in the ancient and ignorant sense: members of the flat-earth society would be proud of these domains!

    One thing that I've had quite a bit of success with (because others did it long before me), is a clean mapping from a thread-model to flat-earth style geographies.

    You can divide your "world" into square-miles, acres, hectares, sq. km, or whatever else is fitting. Heavily-objected areas (heros/boss regions, domain entrances, towns, etc.) have a finer resolution thaan open gaming spaces. Then, each region has a controlling thread to track it's stationary objects/events, transient objects (like characters), and drops.

    Clients represent a simple intersection of threads, in terms of FOV, and you rarely run into the "four corners" issues (when a client is at the vertex of 4 thread-spaces. But even so, this 4-threads-feeding-one-client is a very light worst-case.

    Now, I don't do C#. I do Java, C++, and LISP. I can only imagine that C# has robust language-level thread libraries and if so, you're good to go in the flat-earth. If not, you'll really have your work cut out for you. A single-threaded world can't really scale to "massively multiplayer." If you have any more questions, drop me a line. (I wrote a decent paper on how to partition a flat-earth world-space.) =)
  • by MotyaKatz ( 129919 ) on Sunday February 03, 2002 @06:23PM (#2947829) Homepage
    The utmost strategy game, Empire [empire.cx] has been around since late 1970s, and it's been developing ever since. It is correct, that Empire is the most, or one of the most difficult of the present online strategy games in their curve of learning (chess is tactics), but thus it is also more challenging!

    The powerful server is released under GPL. It is quite neatly written in ansi C and is ported to numerous platforms. Clients for it exist both in command-line form - in C and Perl, and in GUI - VB and PythonTK.

    The most difficult thing in such a game is not the programming one, that one is in fact relatively easy. Inventing the rules and the possible scenarios is the challenge!

    If you just want to practice Client-Server programming, you better write a server for a game with simple rules, aforementioned chess for example.
  • by powerlinekid ( 442532 ) on Sunday February 03, 2002 @06:25PM (#2947839)
    Game engine should be built into the client (unlike what some people have posted). Let the home processor handle that instead of taxing the bandwidth of the server. The server should be a massive database with a server frontend to handle client request. The server software should have an idea of where someone is and whats going on, so that broadcast messages can be used instead of individual client stuff. Cut out as much individual updates as possible, they'll just tax the servers processor and bandwidth. The database should contain the true state of the world, represented as series of tables,etc with values that dictate what the client game engine does. For the database you could just use real software such as oracle, db2 or mysql which might have better speed than a custom system. On top of this if you use java for your server software, you can use jdbc which blows away odbc. Just my 2 cents...
    • Do not every trust the client for anything unless you really have to. Anything on the client can be altered by the user and propagated around the game. This is how multiplayer games are cheated.
    • How would you handle the security then? How would you prevent someone hacking the client so that they could see around corners for the person hiding in wait for a victim?

      No, the viewable state of the world has to be calculated on the server, or on a Grid environment if things are getting hefty in the calculation side of things. It is a downer, yes...

      If the client has the map, even a local map, then that player has an advantage if they have a modified client that erases the LOS algorithm.

      And that is just one of thousands of security holes the product would have. Scary eh, how client-server is harder to do when you have real people in the equation...

  • Some ideas... (Score:3, Informative)

    by maunleon ( 172815 ) on Sunday February 03, 2002 @06:31PM (#2947865)

    Stuff like "How can I make the networking code as transparent as possible so I don't have to write SendUpdate() after every assignment?" we can't answer. I mean, it's all events, and there are hundreds of ways to write this. There are countless examples. GUIs are event driven, for example.

    A long time ago I wrote a multi-user game. It wasn't anything fancy, but it did the basics of what you are trying to do. It turned out that calling SendUpdate() wasn't the problem -- that's easily done with proper design (inheritance, etc). Heck, you can encapsulate the whole message in a class and let the constructor/destructor take care of it, if you want... The main problem was scheduling time to clients, especially when one client was slower than another. For example, it would be unfair for a fast client to send 10 move messages in the same time that a slow client would send one.

    Another distinction you need to figure out is what needs to be real-time and what doesn't. For example, if the program supports inter-user messaging, you can implement "soon-enough" delivery rather than "just-in-time" delivery. It all depends what it is used for. That can be done with a MQ type setup rather than a real-time connection, and it can be sent from client directly to another client.

    I wish I could work on such a project again.. open sourced, closed source, I don't care, just not commercial. But the internet is littered with the graves of abandoned open sourced programs, which tells me a little about how much commitment people are willing to put into these things.
  • Use the Jabber protocol for client <-> server communications, or even server <-> communications. You even get chat for free, then, and you could potentially use a standard Jabber client to inspect the server's state, and send administrative commands. All communications are in XML, so it's easy to see what's going on, and there's fewer endianness problems (even if it's more chatty). You can probably use SOAP or XMLRPC via Jabber.
  • by rufusdufus ( 450462 ) on Sunday February 03, 2002 @06:34PM (#2947875)
    I made a 3d game engine and in my cleverness, I figured I'd reduce load on the server by offloading the physics asynchronously onto the clients. I learned the hard way that THIS WONT WORK. The reason is that different floating point processors get slightly different answers in some instances. Indeed, if all processors are the same stepping of the same intel processor, you'll be fine, however for example an Athlon might in some rare circumstance be different by the very last decimal point from an Intel. The butterfly effect will eventually catch up to you and the Athlon machine will for example detect a collision where the intels didn't.
    Using emulation or fixed point is either too slow or too inaccurate, so I ended up just doing all the work on the server and doing continual sychronization.

    To be more precise, in order to smooth out 'lag' time, the clients would do their own emulation, but would resychronize all decisions on the 'heartbeat'. Using interpolation, this worked out to have great apparent lag response, even lag times of 3 seconds were smoothed out. The only problem then was when a client's lag was unstable, fluctuating a lot. I smoothed this out by emulating a 1 second lag in all circumstance, so everyone has a smoothed out lag response which isn't too bad to play. Only unstable lag of 2 seconds or more caused a problem, where that client would see his character jump around everytime synchronization kicked in.
  • My Experiences (Score:3, Informative)

    by sjbrown ( 9382 ) on Sunday February 03, 2002 @06:36PM (#2947884) Homepage
    You said strategy game, so hopefully my findings might be handy. Most strategy games are sector-based, like Freeciv or Warcraft. I'm using a pretty good (IMHO) model for my own project, Metagame-Sector, which you might be interested in.

    Basically, I've broken it down into 5 objects: Game, Map, Sector, Player and Item. The ownership relationships are as follows: Game owns one or more Maps, and zero or more Players. Map owns one or more Sectors. Player owns zero or more Items.

    There are three subclasses of items so far: Trivial (like swords and onions), Units (like tanks and horses), and Charactors [sic] (like Mario or Frodo). There are also interfaces for the items such as Movable and Jumpable.

    Check out Metagame-Sector [sourceforge.net] if this model interests you.

  • Here's the basics (Score:4, Informative)

    by Adam Wiggins ( 349 ) on Sunday February 03, 2002 @06:37PM (#2947885) Homepage
    • The game makes a connection to one (or more) other games via UDP. UDP is ideal because it doesn't guarentee that the packets will arrive in order, or even that they will arrive at all - but it does guarentee that any packet that arrives will be intact and unaltered.
    • The games need to time sync to each other, by sending "here's what time it is" messages to each other and then recording how long the trip took - much like ping.
    • Update packets are sent whenever an object changes. You can do this one of two ways. One is to explictly setting a "changed" flag on the object, and then at the end of the update loop check to see if that flag is set, and if so transmit an update packet. The second is to have a "compare" and a "copy" function for all game objects; you can create a copy of the object at the beginning of the pulse, and then compare it to the current one at the end of the pulse. If they are different, transmit the update packet.
    • Update packets must not rely on each other. They must contain all pertinent information about the object. Typically that will include its current position, its current velocity (vector of motion), animation state, hitpoints, and so forth.
    • The timestamp on received update packets should be compared to the most recently received packet for the object that it applies to. If it is older, discard it. (Remember, UDP can deliver out of order.)
    • The game uses data about the objects' motion and state to continue to animate the object moving even inbetween packets -sometimes called "dead reckoning." When an update packet is received that shows the object in a slightly different position, the object should interopolate (sometimes known as "lerping" in the industry) to its new position so that it does not appear to pop.


    The only remaining issue is what we call "who is right?" If one game claims that a ship blew up because it was hit by shot, and another game claims that the ship dodged at the last minute, who is right? If the game is client-server, the answer is easy: the server is always right. In fact, clients shouldn't even display "big" events like a ship blowing up until it has confirmation from the server that that is what really happened. (Sometimes it's a good idea to use "hint" animations - if the client expects that a ship has been hit and is going to explode, but hasn't received confirmation from the server yet, you might want to show a shower of sparks. Then, if the confirmation is received a moment later, the explosition doesn't seem to be delayed quite so much.)

    In peer-to-peer, things get much tougher. In some cases one of the peers simply declares itself a server, in which case you have the situation above. In true peer-to-peer, it's simply up to the game designers. The most obvious choice is to make each machine responisble for its own position as well as the position of the objects its has created. So the player controlling a given ship has the last say on where that ship was at any given moment.

    In some cases, you may find that certain game elements (especially if it is an action game) don't work very well when you have to deal with 100ms or more of delay on network traffic. In that case you may want to remove or change those elements. You should pick a number where represents your "maximum" allowable delay, based on whether your target audience is modem users or not.
  • You might like to investigate Unreal's network architecture [epicgames.com] for ideas.
  • If you want a successful project, choose solid, mature implementations of equally mature programming languges.

    You could succeed anyway, but then you could be a successful pianist with three missing fingers too. That doesn't mean you want to deliberately chop off three fingers. :)
  • Use Ada 95. (Score:3, Funny)

    by Black Parrot ( 19622 ) on Sunday February 03, 2002 @06:55PM (#2947952)


    I know that suggesting a different programming language usually gets the same kind of reception that suggesting swapping underwear would, but why not consider writing it in Ada 95?

    The learning slope will be very steep at first, but once you get the hang of it it will pay off in spades. Ada is a software engineering language, and it makes you do a good bit more thinking before you start spilling code, but over the long haul you end up spending most of your time in the think-program cycle rather than in the more popular but IMO less satisfying program-debug cycle.

    Pros:

    • Ada is designed for large software projects.
    • Bullet-proof against buffer overflows and such.
    • Supported by GVD [act-europe.fr] (the visual version of gdb).
    • Very strong portability properties.
    • Supports both high-level and low-level programming. (OO, generics, etc. all the way down to in-line machine code. But all are optional; you can write simple code when that's what the problem calls for.)
    • Built-in support for multitasking and distributed computing, if you want it. (And distributed might be the way to go for a big-game server.)
    • If you need a GUI there are thick bindings for GTK+ [act-europe.fr], portable between UNIX and Windows. These bindings are OO, so you can create custom widgets by inheritance.
    • Everything mentioned above is available for free.
    Cons:
    • The aforementioned learning curve.
    • Probably fewer volunteers on the project once it gets big.
  • by freeBill ( 3843 ) on Sunday February 03, 2002 @07:02PM (#2947978) Homepage

    ...except you can substitute Ruby for C#.

    Our Documentation Index [faeriemud.org] page gives a basic list of the areas we have documented. The General Philosophy [faeriemud.org] describes our philosophical outlook, while Core Concepts [faeriemud.org] describe the main ideas which are needed to understand coding FaerieMUD [faeriemud.org]. Our engine [faeriemud.org] is based on the same Design Patterns you're describing. It is open source and is basically finished and tested.

    The game engine is known as "The MUES Engine" (pronounced "muse") for Multi-User Environment Server because it allows many users to simultaneously interact with one or more environments each being served by one or more servers. When MUES is being used for serving MMORPGs or MUDs, the environments are usually called "worlds" but MUES does not make any assumptions about their nature. They can be chat rooms or workgroups for collaboration or whatever.

    The MUES code is pretty well documented, so you may even be able to use it as pseudocode. (For that matter, it may be possible to use it in Ruby since it doesn't make assumptions about how the objects which are served to it are created.)

    Good luck, and let us know if any of your ideas look like they'd help us.

    All of which should not be taken as disagreeing about any of the other advice to look at WorldForge or MUDdev lists or whatever.

  • by glyph ( 7208 ) on Sunday February 03, 2002 @07:02PM (#2947985) Homepage
    If you're really trying to develop a massively multiplayer game, make sure that you're ready for a collossal failure.

    I can already see the debate about C# heating up over this -- but that's tangential to the real problem. It's not that C# will doom your project, it's that you wouldn't choose C# if you knew what you were doing (and your project weren't already doomed).

    First, my personal suggestion (and I say this as a developer with 2 years commercial MMP development experience at this point): EITHER you want to write an infrastructure, OR you want to write a game. Writing both by yourself will take you the better part of 10 years. Having another programmer around who is doing the other part is handy -- but making sure that they are separate tasks is important. I recommend ditching C# to use Python, and my personal infrastructure project, the Twisted network framework (http://twistedmatrix.com), but if you're not going to use that, then find another high-level language with good asynchronous networking support and the ability to load code at runtime. Other good possibilities are Common Lisp and Scheme.

    If you don't have any experience in the area, and this is for an Open Source project, join an existing project and learn some things from there. I can also highly recommend getting involved with a failed project in the game industry to see how difficult the whole thing really is :-)

    Be prepared to fail at least once. The number of failure points in an MMP project is astronomical: client code, server code, internet latency, even the community itself is a potential "bug". If your technology is great and your game is fun, but it attracts really mean-spirited people for some reason, you might see your servers empty out over the course of a few months, or never even get to a real "massively" multiplayer state.
  • While I'm not sure what kind of strategy game you're doing, but if you're planning to make it scale well it's going to be a lot of HARD work. There're a lot of issues to tackle - server load balancing, bandwidth mixing and dead reckoning. If you're considering what features to build, look at the API provided by RTime www.rtimeinc.com. I find their model pretty comprehensive.
  • From the intro page: [gotdotnet.com]

    Terrarium is a multiplayer ecosystem game developed using the .NET Framework.

    It will probably give you some ideas on how to implement this kind of thing.
  • by pioneer ( 71789 ) on Sunday February 03, 2002 @08:07PM (#2948181) Homepage
    I'm not at liberty to say how I know this but this is what I know of Everquest (the most popural MMORPG):

    They used NT and C (Asm too?) to develop Everquest and they are paying for it dearly.

    Everquest has had up to 80,000 simultaneos users which were distributed over 200 NT servers.

    These servers are in two locations and they have two FULL TIME employees who walk around all day -- their sole job .... reseting crashed NT servers.... yes, that's right. full time server reset people...

    In addition, they've had nightmare situations with patching and keeping these systems up to date.

    And another thing I know is that their next game (forget the name) they have started nearly from scratch and are developing on a UNIX derivative (may be linux... not sure) mainly because the costs of running the game on NT are too great...

    learn from experience...
  • by B.D.Mills ( 18626 ) on Sunday February 03, 2002 @09:09PM (#2948361)
    Here are some Slashdot articles that have been posted about cheating in online games. You may want to give them a quick read if you're developing an online game.

    Combating cheating in online games [slashdot.org] (16 November 2000)

    Multiplayer Game Cheating [slashdot.org] (16 July 2000)
  • by trenton ( 53581 )
    Did you decide this just to generate a deluge of flames?
  • 1) Slow down a bit, and give this project the respect that it truely deserves.

    2) Don't use C# for everything*

    3) Break the project down into parts that are actually accomplishable (i.e. network layer, world engine, actual game). Choose one of these layers and actually get it to work.

    4) Read lots of books because it's gonna take a lot more than a couple of comments from /. to show you all that you need to do.

    I don't really know of a great networking book, but you would really need to brush up on newtonian physics. There is an aweful lot of physics involved and 3d hardware will for the most part, not calculate this for you.

    5) Pay your dues on some open source gaming engines. Get your feet wet before diving head first.

    * C# is bad only because your gonna need big time speed for the 3d engine. The server is likely to require a bit of speed in handling client requests efficently too.

    For these areas, I would recommend C, or C++ if you know C++ _really_ well. C++ can be just as efficent as C but you have to know _exactly_ how C++ works and you must know the spec inside and out.

    C# is really fine for the frills of the engine, but any VM based language would not do well for the heart of the engine.

    Key is to use languages where they are appropriate.
  • Here [garagegames.com] is a very in-depth look at the networking model for StarSeige: Tribes and Tribes2. It is written by Mark Frohnmayer and Tim Gift, who kinda wrote the thing. It goes into great detail about all the things you're going to have to think about, including construction of the stream layer, the perception of real-time play, preemptive client prediction, etc. A must-read if you're thinking about programming this kind of thing.

    You might also want to check out GarageGames [garagegames.com] for some other game development resources.
  • by Casca ( 4032 )
    I want to build a car using (insert new untested material here) because its new. I know I'll need some windows, and wheels, and some sort of engine. I don't really want any suggestions about what materials would work the best because I want to learn how to use the new (untested material). What I really want to know is has anyone else ever done this before, and what should I look out for? I'm pretty sure I'll need to make sure it gets good gas mileage, but it will have to be really heavy, acceleration isn't important, but I want it to be responsive in the turns...

    Why would anyone ask a slashdot group about a C# project?
  • by X ( 1235 ) <x@xman.org> on Monday February 04, 2002 @01:09AM (#2949083) Homepage Journal
    Really, writing something as sophisticated as this with a new language which neither you nor it's developers completely understand yet is a really, really bad idea. I wouldn't use C# for any major production project yet. It's not ready for it.

    If you have no prior experience writing this kind of application, I'd recommend using somekind of a framework to provide you the basics. This will save you the roughly 1 billion design mistakes you are likely to make. If you were experienced with this kind of thing, I'd give you different advice. But for your first run it'd be a smart idea to learn a decent design that someone else has already done.

    You could look at a few open source projects which are doing this thing. If you don't like any of them, the other thing I'd suggest is using a J2EE solution. What you're describing sounds like a good fit for a JMS-based solution, particularly using message-driven beans. The nice thing with a J2EE solution is you have a proven framework to work within that can provide you with the scalability, availability, and reliability that you need.

    I'm not against reinventing the wheel, but it's best if you have some experience before you do that, otherwise you'll end up with a triangular shaped rock. ;-)
  • MMPORG Servers (Score:2, Informative)

    by Anonymous Coward
    I won't cover the networking problems, because that's not my forte, but rather the issues of physical proximity of players. You have to assume that a player has a limited range of sight and effect to cull the amount of data sent to a player in real-time. Assuming a perfect 56K connection, you can only send about 600-700 bytes per 100msec frame, so (BOE) you can really only send position updates for about 20-50 other players, depending on compression techniques, etc.

    Spatial Data Structures (Hanan Samet) describes a set of aglorithms such as quadtrees (2 - 2.5D), and octrees (3D) which can be used to solve the proximity problem in log time in multidimensions, i.e. you can find the N players within a reasonable distance in a pretty short period of time. In fact, you only have to traverse down once, then traverse back up until you're out of range. Insertions are log N as well, so the server should be limited on network bandwidth, not processing power. You can also give priority (send this packet first) to the player that you're looking directly at (or who's looking at you), with diminishing interest in other players (if his back's to me, and mine to him, I don't care quite as much as if I'm looking directly at him),

    The second part is "what happens if I don't get a packet for an assigned player in time", a typical UDP problem. In a flight/driving sim game, you can "guesstimate" with an area of probability where the player's going to be, and if you're shooting at him, give the probability of a hit. Sometimes you'll miss when you should have hit, and vice versa, but you have to do something.

    Do the canonical system first, with objects in 3-D space which can manueuver and shoot to tune your algorithms on the server, then you can refine the game. Doing a simple "space shooter" should be relatively easy. You can make robo-clients with scripts to test out your weights and probabilities. Once you have the empty space shooter, you can add a world with static objects, which should be replicated on each client. Dynamic worlds (walls falling down, etc.) are much more complicated, where you have to set the before and after on each client, and kick it off with a trigger. Dynamic interactions get a tad too complicated even in single player games.

    If you're doing a game with animated players, it's easiest to have pre-programmed positions (running, shooting, slashing with the sword, kicking), so only a code for the target of the action has to be sent down. You can't ship down full animation information, it's too expensive. Unfortunately, it makes fighting unrealistic, because there's no reaction to the pre-programmed code. Doing interactions between figures is an N^2 problem (I block his kick), which while doable, requires a lot of hand-animation work. Full inverse kinematics is computationally prohibitive (AFAIK), but there are approximations that are quite realistic.

    Keep your hopes up. There's a lot of stuff out there that's not very good because it was put together in a hurry.

    For the networking stuff, try some tuning of packet sizes and rates for different scenarios (modem, DSL, high ping times) to figure out what's most efficient in terms of accuracy and percentage of arrived packets. You should be able to figure out your optimal packet size and rate for each scenario.

He has not acquired a fortune; the fortune has acquired him. -- Bion

Working...