Jump to content

View more

Image of the Day

Inventory ! Va falloir trouver une autre couleur pour le cadre D: #AzTroScreenshot #screenshotsaturday https://t.co/PvxhGL7cOH
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

Sign up now

Shared Terrain Discovery

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 Dewar   Members   


Posted 05 April 2014 - 10:50 AM

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.

Attached Thumbnails

  • discovery.png

#2 hplus0603   Moderators   


Posted 05 April 2014 - 11:48 AM

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.)
enum Bool { True, False, FileNotFound };

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.