0
\$\begingroup\$

I am sorry in advance if it's not perfectly clear.

I would like to make a game with let's say the following map (in real it will be a 3D globe).

enter image description here

Now this map contain point, and each point is a place where user can build stuff.

enter image description here

The distance between point is very important, and also, the location of each one of them (not on water and equally distant to each others)

The problem I face, is I don't know how to sync the point with the server. explaining :

I want the point to be equally distant between each others, and only on lands. Generate them is easy from the game itself. but since the game will have a server that control what is build on each case by multiple player, I should generate them in the server. but I don't know how can I do this. since only the game itself know the map and where it can place the point.

Should I generate them in the game, than copy the amount I can fit and write it in the server like if i can fit 200points, I make the server generate 200 points with id from 0 to 200 and the UI will draw them in order ?

I need a little help to find the good direction to explore.

Thank you

\$\endgroup\$
1
\$\begingroup\$

Client-side generation

It seems to be the easiest way for you, because

Generate them is easy from the game itself.

It's usually synchronized by using the same random seed generated by the server. It reduces the load on your server, because it does not have to execute a (probably) expensive generation algorithm and transfer a (probably) large volume of data to clients.

You should generate a seed and send it to clients. On client side, reseed the RNG and generate the map. Because seeds are the same, maps will be the same too.

Server-side generation

It will be useful if, for example, you don't want to reveal the entire map to players and their hacked clients. It's somewhat harder because

  • The server may be written on another language, so you have to port your generation algorithm and make no bugs;
  • You must optimize generation, transferring and storing maps. If you have an algorithm that takes 5 seconds on client machine, imagine what happens if 100 players decide to start a game. But if there are no such bottlenecks, there is no need to optimize.
\$\endgroup\$
  • \$\begingroup\$ Excuse me, I would like to generate the point on the server once, and use them (until I decide to change map) The problem is, I am quite confused on how to have the exact same result in my server and my client. Like, how would I store the coordinate position, so that the server generate them, and the client no matter the scale of the map would be able to display them at the good point \$\endgroup\$ – Bobby Aug 24 at 8:07
  • \$\begingroup\$ @Bobby, when you have the same random number generator on server and client, initialized with the same seed, it's guaranteed that results will be exactly the same. \$\endgroup\$ – trollingchar Aug 26 at 6:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.