Multiplayer billiards game physics simulation [clo

2019-04-13 16:11发布

I’m building an online multiplayer billiards game and I’m struggling to think of the best approach to multiplayer physics simulation. I have thought of a three possible scenarios, each having its own advantages and disadvantages and I would like to hear some opinion of those that either have implemented something similar already or have experience in multiplayer online games.

1st Scenario: Physics simulation on the clients: The player in turn to take a shot sends the angle of the shot and power to the server, and the sever updates all clients with these values so they can simulate the shot independently.

Advantages:

  1. Low server overheat

Disadvantages:

  1. Problems with synchronization. Clients must simulate the exact simulation regardless of their frame rate. (Possible to solve with some clever algorithm like one described here)
  2. Cheating. Players can cheat by tweaking the physics engine. (Possible to determine when making a comparison at the end of the shot with other players ball positions. If only two players are at the table (i.e. not spectaculars) then who the cheater is?)

2nd Scenario:

Physics simulation on one (i.e. “master”) client (e.g. who ever takes the shot) and then broadcast each physics step to everyone else.

Advantages:

  1. No problems with synchronization.

Disadvantages:

1.Server overheat. Each time step the “master” client will be sending the coordinates of all balls to the server, and the server will have to broadcast them to everyone else in the room. 2. Cheating by the “master” player is still possible.

3rd Scenario: The physics will be simulated on the server.

Advantage:

  1. No possibility to cheat as the simulation is run independent of clients.
  2. No synchronization issues, one simulation means everyone will see the same result (event if not at the same time because of network lag)

Disadvantages:

  1. Huge server overload. Not only the server will have to calculate physics 30/60 times every second for every table (there might be 100 tables at the same time) but also will have to broadcast all the coordinates to everyone in the rooms.

EDIT Some of similar games to the one I’m making, in case someone is familiar with how they have overcame these issues:

http://apps.facebook.com/flash-pool/
http://www.thesnookerclub.com/download.php
http://gamezer.com/billiards/

1条回答
forever°为你锁心
2楼-- · 2019-04-13 16:25

I think that the 3rd one is the best.

But you can make it even better if you compute all the collisions and movement in the server before sending them to the clients (every collisions and movements, etc...) then clients just have to "execute" them.

If you do that you will send the informations only once per shot, that will greatly reduce the network issue.

And as JimR wrote, you should use velocity or movement equation instead of doing small step by small step incremental simulation (like the Runge-Kutta method)

The information that the server send to the client would look like this:

Blackball hit->move from x1,y1 to x2,y2 until time t1
Collision between blackball and ball 6 at time t1
Ball 6 -> move from x3,y3 to x4,y4 until time t3
Blackball -> move from x5,y5 to x6,y6 until time t4
Collision between Ball 6 and Ball 4 at time t3
and so on until nothings move anymore

Also, you are likely to need a bunch of classes representing the differents physics equations and have a way to serialize them to send them to the clients (Java or C# can serialize objects easily).

查看更多
登录 后发表回答