Announcement

Collapse
No announcement yet.

Multiplayer Coding/Issues

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Guys:

    I'm right in the middle of coding and can't write long or I'll lose critical track of what I'm doing . so this will be v. brief

    Cool idea but...

    You need to consider that:
    1) we would like to use all the computers for AI
    2) all the AI processes will move at different speeds on different computers. So starting with the same seed will not guarantee everything will stay in synch. However with some mods this might be practical.

    So to implement the basic idea you're talking about you would need to send all AI Actions as well as all player actions. AI thoughts don't need to be in sync I think until they are implemented. So Glak's idea May be doable, and is certainly an option we can look into.
    Project Lead for The Clash of Civilizations
    A Unique civ-like game that will feature low micromanagement, great AI, and a Detailed Government model including internal power struggles. Demo 8 available Now! (go to D8 thread at top of forum).
    Check it out at the Clash Web Site and Forum right here at Apolyton!

    Comment


    • #17
      Hi All,

      If the users start a multiplayer game probably the best to collect the system information out from the players machine. After the game can start different AI threads on different machines (the most time consuming on the most powerfull machine). When the system in "idle" status than the system can send the synchronizing messages around the machines of the players.

      Blade Runner
      [This message has been edited by Blade Runner (edited September 12, 1999).]
      Blade

      Comment


      • #18
        fun, I have been away for three days happily setting up my linux box, this moment I am downloading X servers etc.
        well, you guys have pretty much spelled out what I am going to do, especially Glak.

        As for the AI's getting out of sync, just make a limit of how much 'thinking' they can do, the only bad thing is it would take advantage of super fast processors, but you have enough confidence in your AI right mark?

        Well I'm off, might come back to message board tommorrow, but I am busy getting linux set up with everything including Java(going to do my programming in Linux).

        bye all

        Comment


        • #19
          Osiris:

          Please give us at least an outline before you launch into coding, or we could have a real train wreck! I think the actions-sent model is Very good. It fits in quite nicely with the military movement system too. However we need to be sure all the other models are compatible with it too. I've seen things that looked really good up front before that were shown with a little discussion and thought to be pretty lousy... That said this one looks really appealing, Thanks Glak

          The actions sent to all peers model does not in any way preclude using All the processing power for the AI. Why do you think it does? It actually supports remote processing very well.

          Anyway, why don't you post your vision for what you're going to do with some specifics, and we'll give the group at least a few days to talk it over and make sure all the duke's models are on board. I know you want to get going, so we'll just give a few day comment period, and if it still looks good, cut loose on it .

          As a side-benefit if we do the time-pressure strategy (blitz Clash) model, the model will be the best for handling that too i think.
          Project Lead for The Clash of Civilizations
          A Unique civ-like game that will feature low micromanagement, great AI, and a Detailed Government model including internal power struggles. Demo 8 available Now! (go to D8 thread at top of forum).
          Check it out at the Clash Web Site and Forum right here at Apolyton!

          Comment


          • #20
            John: I don't think synchronization will be a problem because from what I've heard about this game all players will take turns simultaneously. Thus the problem has to be solved no matter how things are done. I think the main way to work around this is to make it so that the game machanics themselves allow for things to happen simultaneously. If two archers shoot at each other in a turn based game only one gets killed, in a simultaneous situation you have to put more of your focus on the arrow. Each archer generates an independant arrow which has characteristics (such as direction and speed) generated when it is shot. At this point the archer has no role in the resolution, only the target. I'm not sure if the archer analogy was needed here but I used to use it a lot when discussing the rules of Magic: the Gathering back when no one (including the judges) fully understood the rules.

            In Starcraft (where I first figured out how this model works) there are 15 turns per game second (1gsec=1 real sec on speed setting "normal"). If I tell my marine to shoot at your tank first the command passes through my interface. Since your tank is a legal target (I can see your tank) the command is approved by the interface. This is just to make things convinient for the player, this step isn't really needed but it makes the game much better. Let's just say I give this command on turn 10,000 and that we are playing on extra high latency (1.0 second delay). The command is labeled with the time and sent to all computers in the game. It does not reach all computers at the same time. For example it gets to my computer very quickly because it didn't have to go anywhere. It gets to computers at other times. As long as it reaches all the computers within the allotted latency time everything works out, if it doesn't then the game lags to compensate. If people notice the game laggin then they just need to set the latency higher to get rid of the problem. Anyway so the command gets to each player at a different time. This is not a problem however because each command is labeled with the turn that it was issued on. So if my command gets to me at 10,000 and you at 10,005 (a third of a second later) and to laggy lou at 10,013 everything is still ok. All computers wait until 10,015 before executing the command. At turn 10,015 they execute all commands issued on turn 10,000. The commands can even come out of order from various turns without incident. Actually instead of sending individual turns it sends a UDP packet with all the turn's commands bundled together. If on turn 10,015 it has not received the packet from 10,000 the game will wait until it gets it. All players wait too but I am not sure how that works since I have never progammed anything.

            Your second paragraph brings up another issue. I think that all computers should always know exactly how things are at all times. Eventually they will have to know. I think that it is much easier to transmit all changes than to update things as need be.

            Example: you have a forest and I have seen it before but I don't know anything about its current status. You sent a guy to burn it. (I know this doesn't happen in clash, just an example). You give him the burn forest: all command. He goes about his merry way and destroys your forest. So now you have a whole bunch of burnt forest squares. Later I send someone to check it out. How does my computer suddenly get information about the situation? Either you send it the state of the forest square by square or you just tell it that you used the burn forest commmand. I think that the first case would take more bandwidth, especially if you are sending information on complex things. On the other hand sending the burn command is simpler and can be sent at the time that the player enters it into the interface. Since players will probably be consistent in terms of data entry rate over the course of the game commands will then be sent at a constant rate. If you send information as it is needed it will come in clumps (and you will have to send more I think) which seems inefficient, plus you have to figure out which infomation is needed in the first place. Wow that was long

            Mark:

            1) You could divide the AI players up by processor strength and then they would play simultaneously with the humans players that they are leeching computer power from. In this way. So say my computer has 3 units of power, Joe has 5 and rick has 6 and there are 10 players in the game. So we add up the numbers and get 14 computer units, divide by 10 and get 1.4 per player. I have 3 so I have to share my computer with one AI guy. (2.8 is close to 3.0), Joe shares with 3 (5.6) and rick shares with 3 (5.6).

            The computer would think simultaneously with the human player host. They would send out command packets together etc.. Of course if the human player things slower the AI would divide its commands up in such a way as to minimize bandwidth.

            So while you would use all computers to process the AI they would not all work together on the same projects.

            This way the AI players become more like human players in terms of how they play the game which I think is a good thing.

            2)
            For random number generation I guess I don't have any idea how it works. So I'll just propose that it be done a different way.

            With every command packet sent out (send at least 10 per second) you could send a random number, if the packet is small you could probably send a bigger number. At the end of the turn if that player hasn't sent enough digits then he has to send the rest all at once. Now the numbers are all added together in order to make some giant super number, like 645983745927301247 but way longer, like more digits than seems reasonable (I assume that this is well within the computer's capabilities). Now each time a random number is needed if can just go grab a few digits off of the super number (except the first since it can't be a 0, so you just drop it). So if I need a random number from 1-100 I just grab the first two numbers 4 and 5 and get 45. Actually instead of using digits you'd probably want to use bits and measure that way but whatever. The only problem that I can forsee is if you need a number from like 1 to 3, but it can't be four. Well I guess you could just reroll (grab more numbers) if you get a 4. If the super number runs out just loop the current number or use the one from last time or something like that. So basically nothing is done using a random number function, you sort of make your own.

            Oh I just saw Blade Runner's post, yeah that is what I mean, I think. I just don't use the word thread.

            Comment


            • #21
              Glak,

              Good ideas! So, using this method each computer would independantly keep the state of the entire game, based on the commands sent by other players, correct? That would allow all players to take turns simultaneously? Definitely better than forcing players to wait for others to play but will this method introduce problems with syncronization? It seems to me that if commands from several players are processed in different orders by each computer the possibility exists for each computers world image to get out of sync. Perhaps there is some way to force all computers to process commands in the same order?

              I had an idea that was similar, though not as well developed as yours, but I'll throw it out and see what people think.

              At the start of the game everyone starts out with an identical world, perhaps generated from the combined random seed you mention. After that only changes made to the world need to be transmitted to other players. And not ALL changes need to be sent, only those that CAN be known to other players.

              John-SJ

              Comment


              • #22
                woohoo, well I dont get what you are saying with the AI sync glak but maybe it just needs to sink in a little more.

                Dont worry Mark, it will be impossible for me to program for probably another week.

                Well I will lay out a rough model of multiplayer functions later, ST: Voyager just came on so have to go

                Comment


                • #23
                  I'm not sure which part you are refering to so I'll assume that it was the part with the marine and the turns and stuff like that.

                  I'll try to explain it better and if this makes sense then you can probably go back and read the other one for the details.

                  Basically there are two network models: the peer to peer and the client server. The server model is used in games where there are a lot of people, like quake or everquest. You cannot be fair to all of the people and still get good performance. So instead of keeping the game perfectly synchonized they just accept commands as they come in.

                  Say we are playing everquest and we both want to shoot arrows at a gnoll. I (using mouse or keyboard) tell my computer that I want to shoot, you do that same thing. Then once my computer knows what I want to do it tells the server. The server lets me shoot as soon as it receives the command (and according to game specific factors). You do the same thing and you do it independantly. The server also lets you shoot as soon as possible. So even if we click the button at exactly the same time it is unlikely that we will shoot at the same time.

                  While that is the best model to use for games that don't need to be perfectly fair it is not the best for other games. Let's say we turned Starcraft into a turn based game for a moment, and we make a little change to how the server works. Ok so now we both enter commands to our various units. Well let's just say that my commands get to the server first. Now instead of letting them take effect right away now it waits until all players have entered their commands for the turn. Once it receives everyone's command they are all processed simultaneously.

                  So basically we have a functioning game of SC, though it is slower than normal because each turn takes a minute or so instead of 1/15th of a second.

                  Now let's make it realtime (yes I know clash will not be realtime but I want to finish the example).

                  Since it generally takes .5 seconds (or more) for commands to get back and forth from the server to the player we have to introduce something called latency. Since it makes the example easiest to understand we will set the latency to 1.0 seconds (15 game turns on speed setting normal).

                  Now the game is still turn based however commands are no longer processed on the turn you sent them. Instead turns are held by the server until the proper time, then they are issued. In this example commands are held until 15 turns after they were issued by the client not received by the server. When the commands get to the server isn't important or even kept track of.

                  So say we take the following actions of the following turns:

                  t1: I do nothing, you do nothing, the server receives no commands
                  t2: you issue command A, I do nothing, the server receives no commands (it is far to early for it to get your command, even if you have a great ping)
                  t3: I issue command B, nothing fo you and server
                  t4-6: no one does anything
                  t7: we don't do anything, the server receives command B from me. It does not execute it.
                  t8-11: nothing
                  t12: the server receives command A from you.
                  t13-16: nothing
                  t17: it is now 15 turns (1.0 seconds) after you entered command A, command A is executed.
                  t18: command B issued.

                  Notice how your command was executed before mine, even though mine actually got to the server first. Having a better computer/connection does not help you.

                  However we are still using a server. Why? Ok now what if we made your computer the server. (you and I still play normally, just the server is using your computer) Does the outcome change? No, since all that matters is when the commands are entered. We could have also made my computer the server with no change to the outcome. If both computers can act as the server with identical results than is a server needed? No, just make both computers think that they are the server and one of the clients, with a second client.

                  However this only works when cause and effects situations are clearly defined such that both computers given the same input will produce the same output. (no randomness at all). However there are work arounds (because SC does have a token amount of randomness), such as the one that I suggested.

                  Now how would this work in clash? well first of all it isn't real time so that means you don't have to deal with latency and you probably don't have to use UDP packets either. Also you will want commands to be executed on the turn they are issued, instead of .5-1.0 seconds later. To keep the bandwidth down I suggest breaking the turn up into subturns but only for the purpose of sending information evenly, it will have no effect on the game.

                  So now we are playing SC with the clash model (back to turn based, no server)

                  t1a: I issue command A, you issue commands C and B (you are faster with the mouse)
                  t1b: I issue D, E, F you: G, H, the AI: (who is using my computer to think) X, Y, Z

                  t1c: me: JK you: LMN AI: TUV

                  t1 resolution phase: ABCDEFGHJKLTUVXYZ all executed simultaneously.

                  The commands were sent as they were issued but took effect all at the same time. The AI finished thinking t1b but since it had six commands it divided them equally to minimize bandwidth

                  At this point turn two begins

                  Well I hope that cleared everything up for you, and if it didn't then I guess my D in english is justified.

                  I'll be getting a new hard drive and switching to 98 (don't get NT unless you are certain that you need it) so I might not be able to reply for a few days

                  Comment


                  • #24
                    OK, yea glak that is excactly what I am shooting for, the last example you had.

                    well here it is, the first rough model sketch for the MP object, this lists all the commands for the MP object....

                    --Multiplayer object's public functions--

                    -int joinhost(string[])
                    This command joins the 'string[]' game lobby
                    error messages = 1=succesful -1=cannot connect
                    example: mes=joinhost("217.29.174.95"); or mes=joinhost("www.url.com");

                    -int makehost()
                    This command simply makes your computer host
                    1=succesful -1=error making server

                    -int connected()
                    This simply returns -1 if the computer is not connected, 1 if it is in
                    a lobby, or 2 if it is in game play

                    -int setnick(string[])
                    This sets the nickname of your computer, this is basically for chat but
                    other things too.

                    -int talk(string[]) talk(string[],string[])
                    The first broadcasts string[] to all players, the second sends a individual
                    a message and no one else

                    -string[] gettalk()
                    the return value of string is "time nick private/broadcast|message"
                    example: "5000 Osiris broadcast|hello everyone"
                    I use a | character instead of a space so
                    if you type something like the following it will work..." spaces behind the text"

                    -int launchgame()
                    IF you are the host of the game then you can run this function to
                    launch the connection over to gameplay mode.

                    -int sendcommand(string[],string[],string[])
                    This is a function for any command this player has made OR the AI's on
                    that computer, string[] = player string[] = category string[] = command

                    -string getcommand(string[])
                    this gets the command in a big messy string the string[] = category
                    so if you want to get a command from government then you do this....
                    string command;
                    string=getcommand("government");
                    The string also has a time stamp on it, so the string would look something
                    like this...
                    "5000 military unit100 move south"
                    all the commands the computer gets is safed in a big buffer, so after
                    all the players finish's there turns then you can get all the commands.

                    -int infoendturn(string[])
                    this returns -1 if string[] player has not ended there turn, returning
                    1 means the player has ended there turn and is waiting.

                    -int endturn(string[])
                    This is to end your turn OR any AI players turn, string[] = player
                    as usual -1 means error 1 means succesful

                    critism invited, tinkering invited.
                    [This message has been edited by Osiris (edited September 16, 1999).]

                    Comment


                    • #25
                      Hi Osiris:

                      Looks good to me... unfortunately I have no idea what I'm doing ;-) I'm trying to think about the existing game models and any changes we need to make now with multiplayer in mind. Unfortunately things are really busy at work and It'll be the weekend before I'll get any chance at all. Soon I will start a thread for the dukes on multiplay effects on their models.

                      Cya,

                      Mark
                      Project Lead for The Clash of Civilizations
                      A Unique civ-like game that will feature low micromanagement, great AI, and a Detailed Government model including internal power struggles. Demo 8 available Now! (go to D8 thread at top of forum).
                      Check it out at the Clash Web Site and Forum right here at Apolyton!

                      Comment


                      • #26
                        Well, I have the java knowledge, have the
                        Multiplayer part very planned out, but one thing, COMPILER.
                        I have $0 that I can spend and I need to gomer a copy off someone and ++++ it which might take a while.

                        ===Inside workings of multiplayer(without source code )===

                        ????????????????????????????
                        | |
                        | |
                        Clashnet-------Public functions
                        | |
                        | |
                        | |
                        Connection |
                        | | |
                        | | |
                        | | |
                        Read* PlayerRead* |
                        | | |
                        [7555] [0,1,2,3,4,5,6,7]

                        * These class's are used for running threads,
                        the Read listens on Port 7555, and the PlayerRead access's players sockets 0-7(1-8 for non-progs). Clashnet is the main class, and all the public functions are there, and they also access the 0-7 sockets for writing.

                        I wish I could start writin this stuff but need a compiler ;

                        aahhhhh!, no spaces for ascii chart!! oh well, still kind of see it, if anyone knows of a site that has version of Visual J++ etc. please tell me, looked already but couldn't find anything.
                        [This message has been edited by Osiris (edited September 30, 1999).]
                        [This message has been edited by Osiris (edited October 01, 1999).]

                        Comment


                        • #27
                          Osiris:

                          Have you done a web search looking for free trial versions of IDE products? I know there's an old version of visual cafe up for grabs, but it probably doesn't have the most recent jdk in it.

                          A quick search on HotBot using "java free ide trial" turned up 80 hits, one of which was http://e-i-s.co.uk/jipe which looks pretty good although it only covers java 1.1 currently. But they have a java2 version in development.

                          [This message has been edited by Mark_Everson (edited October 01, 1999).]
                          Project Lead for The Clash of Civilizations
                          A Unique civ-like game that will feature low micromanagement, great AI, and a Detailed Government model including internal power struggles. Demo 8 available Now! (go to D8 thread at top of forum).
                          Check it out at the Clash Web Site and Forum right here at Apolyton!

                          Comment


                          • #28
                            Warez sux. Free trialz sux, 2. Only Free Beer (TM) Rulez!

                            Sun is giving away free beer in form of their
                            Java Workshop 3.0
                            . It's not the most elegant IDE around, and doesn't include RAD GUI tools (you won't need that for network code, I think ), but it's useful. I use it sometimes when I don't have Emacs around.

                            Try it out, or find some free IDE you like better, there are several around, as Mark says.

                            Martin
                            [This message has been edited by mca (edited October 01, 1999).]

                            Comment


                            • #29
                              what does IDE mean? I'm taking a beginning java class and I had to buy a program and it has IDE like everywhere, like on the box, the shortcut to run the program, and in the help file. I don't really need to know what it means but I just can't stand not knowing what something means.

                              Comment


                              • #30
                                Glak:

                                IDE = integrated development environment. Just lots of cool tools to make coding easier. The best have drag-and-drop GUI features where the code is generated automatically in a visual interface (this is the RAD GUI mca talks about, I think Delphi pioneered it way back when.).
                                Project Lead for The Clash of Civilizations
                                A Unique civ-like game that will feature low micromanagement, great AI, and a Detailed Government model including internal power struggles. Demo 8 available Now! (go to D8 thread at top of forum).
                                Check it out at the Clash Web Site and Forum right here at Apolyton!

                                Comment

                                Working...
                                X