Asynchronous Play

8 replies [Last post]
paul-yolo
User offline. Last seen 2 years 8 weeks ago. Offline
Joined: 2022-02-22
Posts: 3

Hi all,

Great game, having a blast with some buddies !

I'm now trying to get as close as possible to the optimal server configuration for our use case.

As the title says, the idea would be to play asynchronously, or at least emulate the behavior.

For now we are playing with the timeless scheme which works really well, we can just play our turn when we can an just go back to work until we are called to play again.

I would like to go one step further : when a player disconnect, not to skip his turn if it comes to him before he comes back.
I understand that this is not really a use case handle by the current design but I would appreciate if you any of you have some ideas about how to do that, either with configuration or code modification.

I looked a bit in the code to see if I could find some obvious stuff I could modify but didn't :p

Cheers !

nemo
nemo's picture
User offline. Last seen 3 weeks 12 hours ago. Offline
Joined: 2009-01-28
Posts: 1861

This is an interesting play style that I don't think has ever come up before. It would probably require a special config flag to *not* skip teams where the player is away.

If you wanna help work on it, feel free to come by the chat.

--
Oh, what the heck. 1PLXzL1CBUD1kdEWqMrwNUfGrGiirV1WpH <= tip a hedgewars dev

nemo
nemo's picture
User offline. Last seen 3 weeks 12 hours ago. Offline
Joined: 2009-01-28
Posts: 1861

I guess the crude workaround right now would be honour system eh.
Next person doesn't do anything if someone was skipped, and just have everyone else skip a turn when they rejoin.
And, if person after you was already disconnect, don't end your turn until they rejoin. That one might be harder to coordinate, but result in fewer skips.

--
Oh, what the heck. 1PLXzL1CBUD1kdEWqMrwNUfGrGiirV1WpH <= tip a hedgewars dev

paul-yolo
User offline. Last seen 2 years 8 weeks ago. Offline
Joined: 2022-02-22
Posts: 3

Yeah sadly async multiplayer is not that common, but I do think it's getting a bit more traction lately, the pandemic probably helps.
It's really lowers the friction in a lot of contexts.
For example I'm now trying to set some games within my company (we are all remote) so we can interact on more than just work, async games (and hedgewars type of games espacially) are a great match.
For obvious reason just stopping everyone to start a game is not ideal even if doable to a certain extent.

I'll try to come by the chat when I'll have a minute, in the meantime I'll probably look around for some dev documentation see if I can get a grasp of how the game is made.
If you have some pointer to what could be the most relevant parts for this, I'll be grateful !

Cheers

nemo
nemo's picture
User offline. Last seen 3 weeks 12 hours ago. Offline
Joined: 2009-01-28
Posts: 1861

So, IMO if you wanted to test an engine mod, you'd probably want to add a game scheme flag similar to other flags like, say, solid land (the one that makes land resistant to explosions but not drilling).

I would use that one as an example of places to modify.
(engine flag definition)
https://hg.hedgewars.org/hedgewars/file/tip/hedgewars/uConsts.pas#l256
(definition in frontend)
https://hg.hedgewars.org/hedgewars/file/tip/QTfrontend/model/gameSchemeModel.cpp#l33
(rendering in UI)
https://hg.hedgewars.org/hedgewars/file/tip/QTfrontend/ui/page/pagescheme.cpp#l95
https://hg.hedgewars.org/hedgewars/file/tip/QTfrontend/ui/page/pagescheme.cpp#l598

Then, the only trick is to use the flag without screwing up the engine. This part of code is kinda sensitive to things like that, and unc0rr got this working only after more than a few desyncs. I'm not too sure what happens if a person rejoins *during* their turn while they are gone.

I guess you could try it and see.
It *might* be as simple as checking the flag here:
https://hg.hedgewars.org/hedgewars/file/tip/hedgewars/uGearsHedgehog.pas#l1617

But it's possible more stuff would need to be handled. That said, reviewing how he hooked up chTeamBack it seems like it might just work.

Addendum. alfadur offers this commentary on the approach above.
13:46 < alfadur> looks reasonable, but I'm not too sure what would actually happen
13:47 < alfadur> maybe as an alternative could make the server pretend everyone is online

That is, just based on room config have the server lie to the clients. That would require a server modification to test - I'll let him tag the appropriate spots for that. Also since it's not in the engine you couldn't, say, add a banner indicating what was going on in-game. The server could trigger multiplayer pause or do chat messages though.

--
Oh, what the heck. 1PLXzL1CBUD1kdEWqMrwNUfGrGiirV1WpH <= tip a hedgewars dev

paul-yolo
User offline. Last seen 2 years 8 weeks ago. Offline
Joined: 2022-02-22
Posts: 3

Nice, thanks you for the tips !

I share the feeling that the flag idea you proposed could have some nasty side effects.
I'll explore this anyway.

Those are not tech I'm really used to program with but that can be fun to try to fiddle with.

nemo
nemo's picture
User offline. Last seen 3 weeks 12 hours ago. Offline
Joined: 2009-01-28
Posts: 1861

Cool. Good luck.
Build instructions here.
https://www.hedgewars.org/kb/BuildingOnLinux

--
Oh, what the heck. 1PLXzL1CBUD1kdEWqMrwNUfGrGiirV1WpH <= tip a hedgewars dev

unC0Rr
unC0Rr's picture
User offline. Last seen 1 year 4 weeks ago. Offline
Joined: 2006-11-27
Posts: 576

As I see it, you shouldn't be modifying deepest parts of engine to achieve the goal. To my mind, there are two possible reasonable implementations:

1) Requires support from server side, it would work like this:
You create a game with a special flag to it, and server would remember the state of the game, and once it is a turn of a person who is missing, the game stops. When the player joins the server, he is automatically offered to make his move.

Pros: simple for players
Cons: requires quite a lot of changes to server, requires patching of the engine and possibly frontend

2) Make a special frontend to support this workflow:
You create a game setup, a text string is provided for you to share with other players, which basically contains a save file up to your move. You make a move, and the string is updated with additional informations. The string for the whole game would grow roughly to the size of a typical demo file, that is few kilobytes. Alternatively, the string is created for the latest move only, and everyone has to collect all of them to be able to play. You then share the string by any means available in the modern world.

Pros: no requirement for online connection (you can play via pigeon post if you like), easy to implement, no need to wait for next hedgewars release, could work with older versions of the game
Cons: requires tedious management of game session by players themselves

nemo
nemo's picture
User offline. Last seen 3 weeks 12 hours ago. Offline
Joined: 2009-01-28
Posts: 1861

unc0rr could the tedious save management be offloaded on the server using persistent rooms?
Or... some sort of "autosave from last game in the room" then people could just quit and idle in the room after their turn.

would mean a lot of loading lag though unless saves added some expensive checkpointing.. idling in the game avoids that.

--
Oh, what the heck. 1PLXzL1CBUD1kdEWqMrwNUfGrGiirV1WpH <= tip a hedgewars dev

User login

Copyright © 2004-2024 Hedgewars Project. All rights reserved. [ contact ]