Discuss Scratch

minekraftkid
Scratcher
100+ posts

[Help] "Echo's" when multiple users write to cloud variables. (And other problems)

Cloud Variable Rubber-Banding (Still Unsolved)
The System
I am working on a simple multiplayer cloud system. In a single cloud variable, each player is represented by 8 numbers, allowing for 32 players in a single variable.
The player's data is formatted as follows:
(player costume + timer bit)(Dimension Index)(Position Index) // for example: 32100001 
Player Costume + Timer Bit:
This encodes 1-44 possible costumes, and also stores a constantly changing 1 or 0 to allow for active player tests

Dimension Index:
Currently an arbitrary number, but will be used later.

Position Index:
This encodes the players position, and rescales it into a 300*300 grid. (The level bounds are 360*360). It then converts the 300*300 grid into a list, and gives the index of the players position, which will always be between 1 and 90000.


To check for player inactivity, each user constantly compares each entry's timer bit to it's last, counting each repetition, and resetting if it changes. After a certain number of repeats, the user will set the inactive index to zeroes.

The Problem
Updating Cloud Variable Problem:
Randomly, the cloud variable will “rubber-band” causing it to jump backward and forward between current and old values. I have no idea what causes this. The only thing I have heard is that this can happen sometimes if a script attempts to update the cloud too frequently, however I have not been able to find a delay that does not cause this.
I have no idea why this occurs.

a user would never have to account for index changes, however it would require me to rethink the script that finds the next open player slot.
The Project
If you have any insights, I'd be happy to hear them. I've linked the example project below:
Cloud Variable Testing

Last edited by minekraftkid (Jan. 24, 2023 21:29:36)

blablablahello
Scratcher
1000+ posts

[Help] "Echo's" when multiple users write to cloud variables. (And other problems)

this might be nuking a fly, but you could use a python program to manage the player's leaving instead so that you know EXACLTY who would process the leaving (the bot)
minekraftkid
Scratcher
100+ posts

[Help] "Echo's" when multiple users write to cloud variables. (And other problems)

blablablahello wrote:

this might be nuking a fly, but you could use a python program to manage the player's leaving instead so that you know EXACLTY who would process the leaving (the bot)

Yeah after working on this more, it seems like the only way to be able to actively kick disconnected players and ignore inputs from people with high ping would be to have a central sever that was making the calls. Thanks for the suggestion.
Redstone1080
Scratcher
1000+ posts

[Help] "Echo's" when multiple users write to cloud variables. (And other problems)

minekraftkid wrote:

(#3)

blablablahello wrote:

this might be nuking a fly, but you could use a python program to manage the player's leaving instead so that you know EXACLTY who would process the leaving (the bot)

Yeah after working on this more, it seems like the only way to be able to actively kick disconnected players and ignore inputs from people with high ping would be to have a central sever that was making the calls. Thanks for the suggestion.
If you're doing this, you might want to consider the scratchcloud module. Apparently it's really fast. can't find link for now… will edit when found
know0your0true0color
Scratcher
500+ posts

[Help] "Echo's" when multiple users write to cloud variables. (And other problems)

Redstone1080 wrote:

minekraftkid wrote:

(#3)

blablablahello wrote:

this might be nuking a fly, but you could use a python program to manage the player's leaving instead so that you know EXACLTY who would process the leaving (the bot)

Yeah after working on this more, it seems like the only way to be able to actively kick disconnected players and ignore inputs from people with high ping would be to have a central sever that was making the calls. Thanks for the suggestion.
If you're doing this, you might want to consider the scratchcloud module. Apparently it's really fast. can't find link for now… will edit when found
https://pypi.org/project/scratchcloud/
minekraftkid
Scratcher
100+ posts

[Help] "Echo's" when multiple users write to cloud variables. (And other problems)

know0your0true0color wrote:

https://pypi.org/project/scratchcloud/
Thanks. I’ve managed to make a semi stable system that works fairly well without the need for a bot here. However I still have not been able to find the source of the echoing and rubber-banding that seems to randomly happen. The only potential information I’ve seen is that this can happen if you attempt to update the cloud variable too frequently, but I cannot find any mention of how short is too short. If anybody has any insight, it would be appreciated.
Chiroyce
Scratcher
1000+ posts

[Help] "Echo's" when multiple users write to cloud variables. (And other problems)

Cloud variables are extremely wonky - they aren't really stable enough for real time games that require a lot of data to be sent.

minekraftkid wrote:

However I still have not been able to find the source of the echoing and rubber-banding that seems to randomly happen.
Have you tried inspecting the websocket connection? Try to open two different browsers, log into different accounts on them, then right click -> inspect -> switch to the network tab. Reload the page, then filter for “WebSocket” or “Other” (depending on the browser) and click on the resources that says “clouddata.scratch.mit.edu” — then you can precisely monitor what data is sent at what time, and to who is sending it.
minekraftkid
Scratcher
100+ posts

[Help] "Echo's" when multiple users write to cloud variables. (And other problems)

Chiroyce wrote:

Have you tried inspecting the websocket connection? Try to open two different browsers, log into different accounts on them, then right click -> inspect -> switch to the network tab. Reload the page, then filter for “WebSocket” or “Other” (depending on the browser) and click on the resources that says “clouddata.scratch.mit.edu” — then you can precisely monitor what data is sent at what time, and to who is sending it.
I have not. I will definitely try this. Thanks!

Powered by DjangoBB