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

Optimize sending map data by using binary strings #33

Open
Danielv123 opened this issue Apr 23, 2024 · 0 comments
Open

Optimize sending map data by using binary strings #33

Danielv123 opened this issue Apr 23, 2024 · 0 comments

Comments

@Danielv123
Copy link
Owner

Currently the colors for map data is sent as hexadecimal strings where 8 bytes are used to represent color: AABBCCDD for rgba. Lua and factorio supports putting binary data in strings using string.char(0-255) which allows us to compress it to 4 bytes.

For additional compression we could also take advantage of the actual color palette in use being far more restricted by finding all relevant map colors, transferring them to the controller once and then using a single byte to index the color. This would give us a nice and compact 1 byte per tile for dump_mapview.

Similar reductions can also be done to the position coordinates. Currently the position is sent as a string, but sending long decimal numbers as strings takes a lot of space. The position could be sent losslessly as 2x8 bytes or truncated as 2x4 bytes, bringing us to a worst case of 9 bytes per tile before compression.

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

No branches or pull requests

1 participant