any RTS game state byte array size advice?

Hi
I'm considering all the ways for my Java RTS server to encode the game-state in a byte array for each client's valid vision.
 Obviously, thousands of units are possible, also, if ordinance is included as a unit.
I have 2 byte integers and a band of tuples for each unit's x,y location and a boolean for whether or not the unit exists.
The whole issue is how many units to make room for, even with supply limits for units.
In an 8 FFA or a 4 v 4 game, thousands of units will exist.
How big could my byte[] be? 4096 ? 32k 64k
- for optimal transfer? what should my data structure look like?
Thanks
LVL 1
beavoidAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CEHJCommented:
You might look into the Linux program called 'Bup'. It's a backup utility but has a highly efficient binary diff routine at its heart

https://github.com/bup/bup
0
beavoidAuthor Commented:
Thanks.

That's quite a long page.
What section did you have in mind? It seems to be tailored for OS people, not coders.
What does binary diff mean?
0
dpearsonCommented:
How big could my byte[] be? 4096 ? 32k 64k
- for optimal transfer? what should my data structure look like?

I would suggest making the message size flexible - not a fixed byte array.  To do that put the length of the data at the front of the "array" - so you know how many bytes of data to actually read in a given message.

That format will allow you to send a message for 10,000 units each taking 100 bytes (1MB total) very occasionally (like at the very start of the game) and then use the same format to send updates on the 200 units that moved where you only send the new x,y coords in maybe 2K.

That's much better than saying "the worst case is 10,000 units with 100 bytes each - so every update I need to send 1MB of data to each client".

Hope that helps,

Doug
0
beavoidAuthor Commented:
Thanks,
So, UDP messages are sent and received at the same size, any size?
That's super.
But, aren't  the TCP side of the game-state updates fixed byte[] size?
How can this be handled for arbitrary unit counts?
Or are the TCP packets whatever size they are created at?
So, I send the exact same byte[] in TCP and UDP?
Should I have the second and third bytes in the array, combined, base 256, be the byte array size?
In practice, how many units in one frame max out at any given time? My brother and I have had some massive 3 vs 3 situations. But that is just client side game state.

Thx
0
dpearsonCommented:
You can choose to send datagrams (or TCP packets) using a fixed size if you want - but then encode your actual message as a series of those datagrams.

E.g. Say you choose a 1000 byte fixed datagram size.
If you wish to send a 6,500 byte message, it would be encoded into 7 datagrams of 1,000 bytes each (500 bytes at the end would be wasted space..or the start of the next message).

To make this work then yes - the first 2 bytes would encode the length of the total message - which can be independent of the datagram/packet size.  You code would just keep reading datagrams until it had a complete message (6,500 bytes in this example) and then it would parse all 6,500 bytes in one go.  It would know when the message was complete and ready for parsing because it would look at the first 2 bytes and know the total length was 6,500.

Makes sense?

Doug
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Game Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.