Announcement

Collapse
No announcement yet.

TCP Link between game server and AI server

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

    TCP Link between game server and AI server

    Hi everyone, I've been working on an RPG mod for UT2004 for a couple years now but never really had enough energy to force myself to learn the programming necessary to do it all myself.

    Well, now I've decided to take it up and get this thing going once and for all. That said the first task is getting the game server to talk to the AI server. I'll be posting my progress and questions in this thread so that others can see how it's done and so those interested in giving suggestions can do so.

    I know I'll need to use the TCPLink actor to initiate the connection:

    http://wiki.beyondunreal.com/wiki/TcpLink

    What I don't know is where I'll need to put it. We had previously gotten a basic two way connection going at one point, in which whenever a player stepped on a specific switch it would send a message to a simple listen server I'd written which would then make a request to a database to find out how many times the switch had been stepped on, add one, and send the new number back to the game server which then sent it on to the client as a text message.

    What needs to happen is as follows:

    Game server starts, makes a connection to the AI server, AI server tells the game server the last known positions of all non player characters and what they were doing, game server spawns them, and AI server takes control. Then communication needs to continue going back and forth as the AI server manipulates the non player characters by sending instructions over the TCPLink and the game server sends info about the surroundings of the NPCs to the AI server.

    Oy, but first things first. How do I initiate a connection upon game start and then maintain that connection until the game ends? It does not need to be a constant stream of data, but it does need to keep listening for data, and sending when necessary.

    Ok, I've brainstormed enough, I'll get to work on this and if anyone has any ideas please let me know. In the meanwhile I'll post results here.

    #2
    omg, i hope Ut2004 Addict sees this !! or Xyx

    Comment


      #3
      Would I be right in thinking that by 'game server' you actually mean 'login server' and by 'AI server' you mean 'game server'? ^^;
      That's what it sounds like to me at least.

      Comment


        #4
        Why do you have a seperate AI server? Why not do everything within the game engine? Is the AI particularly intensive so you need the extra speed?

        Comment


          #5
          No, gameserver obviously is the UT2004 server the player connects to, while the AI server could be any kind of TCP server (probably not UT2004 at all) on the same or another machine, that accepts a connection from the gameserver.

          KrisWood:
          There are several examples of TCPLinks in UT2004. Most notable are the built-in IRC client (GUI2K4.UT2K4IRCLink) and ElMuerte's HttpLink class for his LibHTTP utility package. I've also created a TCPLink subclass for my IRC reporter bot. (WormbotReporter.WIR_IRCConnection)

          Comment


            #6
            Thanks for all the responses. What we're making is a small scale online multiplayer world that works like an mmo but in scope is more diablo or NWN-esque. The AI in this mod needs to be able to think for itself to a limited degree, and more importantly there will need to be hundreds of NPCs. If the game server is trying to support all these dynamicly created NPCs it'll be brought to its knees in short order.

            Edit: And yes, Wormbo has it right, the AI server is a python script running on a seperate machine.

            Wormbo; The IRC client might not be a bad idea at all. Our AI is already able to chat with us via IRC why not modify the IRC client to take calls from and to the bots as well as players. I'll look into that!

            Comment


              #7
              Ok here's my progress so far. I've watched a few video tutorials, and read some online tutorials, and i'm still utterly befuddled as to what I'm supposed to do. It seems to me that I should put the code in the gametype because it's something that needs to happen as soon as the game starts up and continue running until the game is over.

              HelloWorld.uc
              Code:
              class HelloWorld extends DeathMatch;
              
              var string WLhelloWorldString;
              
              function PostBeginPlay()
              {
              WLhelloWorldString = "This is a test of the Wanderlust Hello World system.";
              
                Super.PostBeginPlay();
              
                while(1==1){
                  Log(WLhelloWorldString);    // Write our log message
                  TextToSpeech(WLhelloWorldString, 5 );
                }
              }
              I compile it, put it in my E:\UT2004\Wanderlust\System\ folder, set up all the ini files etc, and then run it using the -mod command line. It starts up, I get the main menu, I go to instant action, and there are no maps to choose from! >.< I've got to be doing something wrong here. Any ideas? I tried this once a long long time ago and got it to work as a mutator doing something similar to this but I've completely forgotten how I did it. :-/ For now i just want it to write to the log and announce it via TTS every second. Once I get that much working I'll start on the TCP stuff...

              Any help would be greatly appreciated!

              Edit: oh yeah, I can still open maps from the console, but once I'm in the game it's just a regular map, the mod doesn't do anything, and nothing in the log indicates that it's even working.

              Comment


                #8
                hmm maybe extend xdeathmatch i think, i cant remember off the top of my head

                Comment


                  #9
                  loading from the command line like this?
                  Code:
                  open ons-torlan?game=HelloWorld

                  Comment


                    #10
                    Originally posted by AquaticSheep
                    loading from the command line like this?
                    Code:
                    open ons-torlan?game=HelloWorld
                    Tried that, still didn't do anything except make the maplist disappear. I also tried it with

                    open DM-1on1-Albatross?game=HelloWorld
                    just in case it needed to be a deathmatch map since that's what I'm extending...

                    Comment


                      #11
                      Copy/paste defaultproperties from parent class, xTeamGame or xDeathmatch.

                      Comment


                        #12
                        The correct syntax turned out to be:

                        Code:
                        open DM-1on1-Albatross?game=Wanderlust.HelloWorld
                        My good friend MarZer finally signed on though and asked me what I was having trouble with. He then walked me through setting up the new gametype so what I have is much much larger now. It works properly though, sort of...

                        Here's the portion of code I'm having troubles with:

                        Wanderlust_Game.uc
                        Code:
                        class Wanderlust_Game extends Gameinfo
                        	config(Wanderlust);
                        
                        //user-editable vars
                        var() 	config	bool			bLogDebug;
                        
                        var string WLhelloWorldString;
                        
                        event InitGame( string Options, out string Error )
                        {
                        	super.InitGame(Options, Error);
                        
                        //    bForceRespawn=true;
                            WLhelloWorldString = "This is a test of the Wanderlust Hello World system.";
                        
                            Super.PostBeginPlay(); // Run the super class function (Mutator.PostBeginPlay).
                        
                            while(1==1){
                                Log(WLhelloWorldString);    // Write our log message
                                TextToSpeech(WLhelloWorldString, 5 );
                            }
                        
                            if(bLogDebug)
                            {
                            }
                        }
                        It's stuck in an infinite loop (of course!) at the loading screen. Any ideas for a better way to approach this? :-/

                        Edit: My current console command line is now:

                        Code:
                        open DM-1on1-Albatross?game=Wanderlust.Wanderlust_Game
                        Here's what the log had to say about it:

                        Code:
                        Log: Browse: DM-1on1-Albatross?Name=Player?Class=Engine.Pawn?Character=Jakob?team=255?game=Wanderlust.Wanderlust_Game
                        ScriptLog: No loading hint configured for  Wanderlust_Game
                        Log: Collecting garbage
                        Log: Purging garbage
                        Log: (Karma): Level Karma Terminated.
                        Log: Garbage: objects: 39481->35724; refs: 540796
                        Log: Game class is 'Wanderlust_Game'
                        Log: Bringing Level DM-1on1-Albatross.myLevel up for play (0) appSeconds: 131.257000...
                        Log: (Karma): Autodetecting CPU for SSE
                        Log: (Karma): Using SSE Optimizations
                        ScriptLog: GameInfo::InitGame : bEnableStatLogging False
                        ScriptLog: This is a test of the Wanderlust Hello World system.
                        ScriptLog: This is a test of the Wanderlust Hello World system.
                        ScriptLog: This is a test of the Wanderlust Hello World system.
                        ScriptLog: This is a test of the Wanderlust Hello World system.
                        ScriptLog: This is a test of the Wanderlust Hello World system.
                        ScriptLog: This is a test of the Wanderlust Hello World system.
                        ...
                        (...several thousand lines later...)
                        ...
                        ScriptLog: This is a test of the Wanderlust Hello World system.
                        ScriptLog: This is a test of the Wanderlust Hello World system.
                        ScriptLog: This is a test of the Wanderlust Hello World s
                        It was cut off when I had no choice but to hard power cycle my PC :-/

                        Comment


                          #13
                          Code:
                              while(1==1){
                                  Log(WLhelloWorldString);    // Write our log message
                                  TextToSpeech(WLhelloWorldString, 5 );
                              }
                          I hope you realize that this is an infinite loop that halts the game. It will fill your log file for a while and after about a million (or more) lines the game will detect the infinite loop and crash, probably leaving behind over a GB of identical lines in the log file. Never ever (!) use unconditional loops, except in state code, and even then only when the loop executes a latent function once in a while. As long as non-latent UnrealScript functions are executed, the game will halt, waiting for the function to return.

                          Comment


                            #14
                            Originally posted by Wormbo
                            I hope you realize...
                            I think it's quite obvious that I realize this, but what do I DO about it? I need it to send a message once or twice every second for the duration of the game...

                            Comment


                              #15
                              Originally posted by KrisWood
                              What needs to happen is as follows:

                              Game server starts, makes a connection to the AI server, AI server tells the game server the last known positions of all non player characters and what they were doing, game server spawns them,
                              ... so that's in prebeginplay, I think ?

                              Originally posted by KrisWood
                              and AI server takes control. Then communication needs to continue going back and forth as the AI server manipulates the non player characters by sending instructions over the TCPLink and the game server sends info about the surroundings of the NPCs to the AI server.
                              sounds like you want to subclass controller or one of its family. You could have a RemoteController that controls the NPCs' pawns... Instead of dealing with a UT2004 client and joysticks and mice and stuff it would use this TCPlink you talk about... Hmmm... Dunno how world state information gets back to the AI "virtual player" in that setup though...[/QUOTE]

                              Comment

                              Working...
                              X