Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suitable For Multiplayer Game State Sync? #2

Open
soundyogi opened this issue Apr 18, 2017 · 5 comments
Open

Suitable For Multiplayer Game State Sync? #2

soundyogi opened this issue Apr 18, 2017 · 5 comments

Comments

@soundyogi
Copy link

Title says it :)
Sorry if it is a stupid question.

Very Interesting Project!

@carboniris
Copy link

What kind of game? WebRTC has a bit of latency but probably not enough to cause any issues with what you're doing.

@soundyogi
Copy link
Author

I am more concerned about hyperlog + redux - I guess the server would send updates every 100ms or so.
Mostly Entity Velocities and so on. In my tests mith webrtc-swarm I had latencies around 150ms so thats ok I guess.

I just will have to try I guess :>

@philholden
Copy link
Owner

philholden commented Apr 18, 2017

I have not profiled the latency. It is certainly low enough to work for some games. I am really loving generals.io and it would work well for that kind of game. Please let me know if you profile the round trip time.

I have written another reducer called-back-to-the-present it is based on requestAnimationFrame it creates a log of keys pressed by players on each frame. It optimistically generates an immutable copy of the state for each frame on each client. This is regenerated if new info about a previous frame comes in. But when there is consensus i.e. all clients have sent a keystroke or keepalive past a given frame the state for old frames can be garbaged.

So there are two logs one for key presses that does not get garbaged and can be used for replays and one for game state positions, velocities etc we keep this as short as possible.

When new clients connect they receive a copy of the consensus state from a peer i.e. the latest frame that we know will never change. All other peers are informed of the new comer and send any actions after the consensus. Then the newcomer becomes a normal peer.

This should work for up to about 10 peer there is no swarm so traffic grows factorially with number of players. But the engine should be general purpose enough for any arcade game.

I will see if I can dig it out. I have not tested it properly but think I got it working.

@philholden
Copy link
Owner

I found it and pushed it here:

https://github.com/philholden/back-to-the-present

@soundyogi
Copy link
Author

You are totally awesome man! I will look into it, Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants