Closed v0ltumna closed 7 years ago
Great, thank you. I will merge this in as soon as I have time to make the minor adjustments I mentioned in the previous PR. Probably by the weekend.
I pulled this to test it out today, and I realize there is 1 more issue I had not considered.
To minimize the network traffic, the game compresses down the information about the playfield as much as possible. This means that currently only 3 bits will be used to store the value of a square in the playfield. 3 bits = 0-7 (only 8 different) and adding a color pushes this up to 9.
It is a very easy change to make, but it will increase the network load by 1 bit/square. In the extreme case when a playfield is almost full it would mean roughly 17*10 = 170 bits 170/8 = 21,25 bytes or somewhere around 25%
In the other extreme when the playfield is empty it makes no difference at all.
Currently the server sends around 7 packets per second. 7 * 21,25 = 148 bytes/sec With 7 players it would increase the network load by roughly 1kb/s for all clients, and 1kb/s per client for the server.
If we did this we would also have a lot of unused data sent as 4 bits/square would give us 0-15 instead of 0-7, but we would only use 0-8. If we do this it would make sense to add an additional 7 colors to at least use the network traffic efficiently or just stick to 7 colors (go ahead and change one of the colors to orange :smile: )
Not sure what is the best course. The main points to consider.
To give some rough number the server sends between 200-500 bytes/sec per client right now. This will keep increasing a bit when we start adding cheat protection. How much I'm not sure yet.
There might also be additional improvements available to optimize this that I'm not aware of.
My suggestion is that we just drop the orange color, alternatively change the yellow to orange? So we can keep the network code as it is for now. Adding an additional color in the future will be an easy task later as well if we decide to go down that path. The changes to loading default options and saving the colors are great changes though, and I would really like to have them in the next release. Hoping to do that in 1 week or so.
I can do this myself if you want, but I want to make sure you get credit for this contribution.
I went ahead and removed the orange color. As for adding colors this will be possible, but I need set up a system where the server and clients exchange color options to keep the network usage from growing.
When this has been done we can easily add any number.
This adds orange as another color which is usually selectable (ok, its mainly because I usually pick it :) ). Furthermore the change of colors is now saved into the configuration file. The behavior of loading the configuration is also changed, only data which is not set will be reset to standard now. This is a repost from master in develop. I will look for additional changes kroyee mentioned, perhaps we can talk about it so that its easier for me to dig into the source.