Jump to content
  • Advertisement
Sign in to follow this  

Shared Terrain Discovery

This topic is 2020 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In my 2D tile game I've implemented a line-of-sight system where the client's player can see all unobstructed tiles and those tiles are remembered so as the client's player move around their LOS and view of real tiles changes and those they have previously discovered are rendered in their remembered state and are dulled to distinguish them from what is in LOS.  Revisiting previous areas will update stored tiles.  The algorithm for tile discovery is something I'm looking to optimise but currently works well for a single client player.


My current problem is how best to share the knowledge of the terrain across a team of players.  As player A moves across the map and discovered terrain I want player B to see those tiles appear.  I'll also want new clients that join to get the full discovered state of the map.  Currently I see three options for this:


A: Player A does tile discovery client side and sends out discovered tile data to server.  Server distributes discovered tile data to all other clients.


B: As all players are predicted in each client (until they receive a player data update) they should have fairly accurate position/velocity data for each other player.  Therefore each client can run the tile discovery code for themselves and each other player.  If there are 4 players on a team then this means 4 x the work for tile discovery.


C: Perform all discovery on server.  Player A moves, server uses (predicted) position of player A to discover tiles and sends data for all clients (possibly including A) to memorise state of and render discovered tiles.  I like this but any latency would result in a strange experience for a client as the player moved position and tiles appeared late and I think I need to rule it out on that basis.


I'm going to start going through these options here and seeing what will work out best but I'd appreciate any thoughts and ideas especially if anyone has dealt with a similar problem before.  Thanks.

Share this post

Link to post
Share on other sites
I would probably do C. Each tile needs three possible states (so, two bits):
1) undiscovered
2) discovered but currently not seen
3) currently seen

You can view this as a 2-bit pixmap that covers the entire play area, and then compress it using RLE or similar mechanisms for transmission.

Or, if you implement deterministic simulation, and just send commands to the server, you can do discovery entirely based on the received player commands and deterministic simulation.

A little bit of which you choose depends on whether the client processes know all the data already, or whether you want to keep undiscovered tiles absolutely un-known to the client processes (not just hidden in the GUI.)

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!