Announcement

Collapse
No announcement yet.

Procedural maze replication

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

    Procedural maze replication

    I created a maze generating algorithm that fills an integer array with 1's and 0's, depending on where a wall should be and where a path should be. I'm then using that array to add instanced static mesh blocks as the walls. The maze generator is an otherwise empty actor, so I can move it around.

    Click image for larger version

Name:	c70333a547b89321c490e7b6f294174a.png
Views:	1
Size:	173.1 KB
ID:	1142165

    Simply replicating the process will generate a new maze for each client, although collision remains from the original server maze. Now I'm trying to wrap my head around how to generate the maze once on the server and use the same layout to be created on the clients. I can stop the client from spawning it's own version, but I have no idea how to create the same version on a client.

    Is there any way I can take the already made maze array and just spawn my meshes in the same pattern for just the clients?

    #2
    You need to replicate the entire level array OR replicate a seed for your random number generator and plug it into the random number generator for all clients which will produce a reproducible maze across all clients.

    Also you should look into taking part of the level generation to bsp or just a single tile like the floor for example, there are plenty of tiles already, so a good optimization is to turn the floor into one big tile, i like to make it a bsp, since i never move a generated level.
    Last edited by SaxonRah; 12-21-2014, 09:37 PM.
    Youtube
    Machine Learning C++ Plugin
    Lindenmayer System C++ Plugin

    Comment


      #3
      I'm having some trouble replicating the array itself. In this example the authority prints out the loop of array values and the test string, while the remote skips completely over the array and just prints out the test string. I do have the array set to be replicated as well.

      Click image for larger version

Name:	9afab7417587cb6107f4fddb9639e093.png
Views:	1
Size:	130.0 KB
ID:	1064397


      Also not sure what you mean about the floor, it's just a giant slab of bsp atm anyway.
      Last edited by Bohrium; 12-21-2014, 10:02 PM.

      Comment


        #4
        Originally posted by Bohrium View Post
        I'm having some trouble replicating the array itself. In this example the authority prints out the loop of array values and the test string, while the remote skips completely over the array and just prints out the test string. I do have the array set to be replicated as well.




        Also not sure what you mean about the floor, it's just a giant slab of bsp atm anyway.
        I thought you had individual floor tiles. you already have a gigantic bsp floor , forget that bit.

        But try making two different custom event functions, one for generating the maze array. and the other for reading the array and printing out the tiles. And then setup the custom events to be replicated, the generation would be server only and the read and print would be client and make the functions behave like you want em to. for example if you watched the blueprint networking tutorials he goes into how you can get different replication results from the options.

        You might find it easier to simply replicate a single value for the seed to the random number generator. and just sending that number to the client
        Youtube
        Machine Learning C++ Plugin
        Lindenmayer System C++ Plugin

        Comment


          #5
          Hello,
          I did something like that : http://fen-ue4.blogspot.fr/ with a part dedicated to the algorithm creating an array and a part using instanced meshes to create it in level, as said Saxonrah. If it can gives you ideas for yours.

          Comment


            #6
            Originally posted by SaxonRah View Post
            You might find it easier to simply replicate a single value for the seed to the random number generator. and just sending that number to the client
            This is the way to do it

            Comment


              #7
              I switched to using a seed value to make replication easier. As long as the seed remains unchanged, the mazes will be identical, just the way I want them to be. However when I change the seed, the client builds a completely different maze from the server. I change the seed on the server side. Wait for the client to receive the new value, double check the value, print out the seed to visually see that it's the same on both server and client and after that generate a maze with the same seed value on the client, which produces a completely different maze.

              So the maze generation with the same seed works, because by default it generates the same kind of maze.
              Replication works, because I get a visual confirmation from the printed messages that the seed has changed.
              But the maze is different if I try to change the seed before either of the mazes are generated and I have no clue why.

              Click image for larger version

Name:	1f41ca6b3efbbfc97855b0b67baf107b.png
Views:	1
Size:	325.8 KB
ID:	1064477

              There's no actual errors on the nodes, I just forgot to compile after moving something around.

              Comment


                #8
                Hello Bohrium, procedural level and character replication over a network is of interest to me as well. I have yet to start on the level generator, but, current thought is to require all clients to be connected to server prior to generation, than replicate level construction to all at game start. If a client leaves the game in progress, they are not allowed to return. This one-way door is also a security measure.

                Im curious about your success with this.
                HeadlessStudios.com is now part of TheGameDevStore.com

                Comment


                  #9
                  You should be able to just stored all the level data in arrays and pass that data to the other players on the network. I don't see why you would need to lock people out after game start unless that met a design goal.
                  Map Generator 1.0
                  Map Generator 2.0
                  Map Generator 3.0

                  Comment


                    #10
                    Originally posted by Zeustiak View Post
                    You should be able to just stored all the level data in arrays and pass that data to the other players on the network. I don't see why you would need to lock people out after game start unless that met a design goal.
                    In theory a simple Anti-cheat mechanism, that serves as part of the Labyrinth's operation... One way in, one way out. A form of Perma-death, Contestants are made fully aware of, upfront. From a anti-cheat perspective, its desired that only the Server has full knowledge of the Labyrinth. There are additional mechanisms that implicity and explicity force Contestants to maintain close proximity to each other, reducing the amount of Labyrinth exposed to the Clients.

                    @Bohrium did you get this working?
                    HeadlessStudios.com is now part of TheGameDevStore.com

                    Comment


                      #11
                      I've Blueprinted a basic Depth-First Search Maze Generator and at a point where I can experiment with replication. I'm now seeing the issue first-hand: two different mazes being generated between Client and Server.

                      This is a challenging problem to solve. I've deduced this problem down to replication of the RndNumber generated by the seed, not the seed itself. I concur with the replication of the entire maze structure array to clients. Another approach is for the Client to request and obtain this value from the Server during Maze Generation when Spawning the Structure (Server RPC? See Technical Note in Rules for Calling Functions). This approach could be applicable to any situation where a random value produced on the Server needs to be replicated to Clients.

                      The method used to generate the maze will determine implementation. I use Static Meshes for each Wall/Floor component individually, thus I also have option to replicate by Spawning Component with the resultant Location Vector calculated with RndNumber generated. I'm still experimenting with this and will post when I find a solution i like.
                      HeadlessStudios.com is now part of TheGameDevStore.com

                      Comment


                        #12
                        Hey TechLord. I'm interested with what you said about the random numbers being generated by the seed being different from client to server. This shouldn't be the case. One thing to note it will always generate the same set of numbers where each time a number is requested it moves to the next one in the sequence. If your having an issue with the mazes being different your most likely requesting additional numbers from server to client which is most likely causing the issue.

                        For example if I generated a maze with a given seed and then without destroying the blueprint got it to generate another maze they would be different as it would continue the steam sequence. However if I destroyed the blueprint and spawned a new one in with the same seed they'll be the same maze.
                        Looking for blueprint tutorials? Then visit my blog... voxagon

                        Comment


                          #13
                          Hi pattym. I appreciate the response. I need to review my code, its possible the replication settings are not properly configured. I've been working on other aspects of the maze and will revisit this issue over the weekend. I'm using the RandomInteger Blueprint Node to generate the maze, I have direct control of the seeding. Its my understanding Random Number generators use UNIX timestamp as a seed. I'm not certain if any special treatment is applied with the replication of Random generated number, but, I would expect the resultant value to be replicated by the server, not the seed. My maze generator is based on this the Depth-First Search Algo highlighted on Mazeworks.com. I've elected to generate dungeon rooms wall by wall with Statics Meshes (not instanced meshes) for greater flexibility & control.

                          HeadlessStudios.com is now part of TheGameDevStore.com

                          Comment


                            #14
                            I can see your issue. You need to swap out your random integer to one pulled from a stream. The standard random int node will always generate different numbers and doesn't work off any seed.

                            Random Streams

                            I made a tutorial a few weeks back on a random maze generator. It uses random streams and should (not actually tested) replicate as long as the players all have the same seed. Not sure if you'll find it useful but here's the link. Maze Gen Tut
                            Looking for blueprint tutorials? Then visit my blog... voxagon

                            Comment


                              #15
                              Thanks again, pattym. I can see value in a Sequence Generator and it would not be difficult to swap with the current RND Node. I see the challenge as replication of the value(s), whether its a seed or list of randomly generated values. I suspect I don't have the network replication settings configured properly on the variable that stores the seed. I will try both methods and post my findings.
                              HeadlessStudios.com is now part of TheGameDevStore.com

                              Comment

                              Working...
                              X