Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

XML is a good choice if you're not limited by size and it is supported natively (eg in .NET and Flash) but if you want a slim format you can create your own format and parser quite easy. I normally use 1 character eg. comma to seperate each object. To decode the string do a split on comma. Now each object needs different properties so seperate these with a different character eg semi colon, and use another character to seperate the property names from property vales, eg. Colon. All thus can be decoded easily without regex just by using string.split. Here is an example:

id:1;x:5;y:45.2;angle:45,id:28;x:56;y:89;angle:12;health:78

you can save even more space by keeping property names down to 1 character, eg h for health. Eg.

i:1;x:5;y:45.2;a:45,i:28;x:56;y:89;a:12;h:78

Compare to JSON alternative:

{"o":[{"i":1, "x":5, "y":45.2, "a":45}, {"i":28, "x":56, "y":89, "a":12, "h":78}]}

Also, if you want to get the size of your numbers down, you can encode them using the full set of printable UTF16 characters. This thread inspired me to ask a question over on Stack Overflow of how much data you could pack into one on-screen charactera question over on Stack Overflow of how much data you could pack into one on-screen character. The answer seem to be somewhere over 40,000 values for an integer, if you don't mind having brail, Kanji and chess pieces: ♔♕♖♗♘♙♚♛♜♝♞♟

To get a further size reduction, you can use read/write order to determine which value is which, so the first two characters represent the id, the next two are the x position, the next two the y, then the angle, then health, etc. So:

F5DGP@%&002DFTK#OP1F

could store all the same information as the other examples.

Tile grids can be stored as just a string with each character representing a different type of tile eg:

i789pog5h3kl

where I might mean lava, 9 mean grass etc

XML is a good choice if you're not limited by size and it is supported natively (eg in .NET and Flash) but if you want a slim format you can create your own format and parser quite easy. I normally use 1 character eg. comma to seperate each object. To decode the string do a split on comma. Now each object needs different properties so seperate these with a different character eg semi colon, and use another character to seperate the property names from property vales, eg. Colon. All thus can be decoded easily without regex just by using string.split. Here is an example:

id:1;x:5;y:45.2;angle:45,id:28;x:56;y:89;angle:12;health:78

you can save even more space by keeping property names down to 1 character, eg h for health. Eg.

i:1;x:5;y:45.2;a:45,i:28;x:56;y:89;a:12;h:78

Compare to JSON alternative:

{"o":[{"i":1, "x":5, "y":45.2, "a":45}, {"i":28, "x":56, "y":89, "a":12, "h":78}]}

Also, if you want to get the size of your numbers down, you can encode them using the full set of printable UTF16 characters. This thread inspired me to ask a question over on Stack Overflow of how much data you could pack into one on-screen character. The answer seem to be somewhere over 40,000 values for an integer, if you don't mind having brail, Kanji and chess pieces: ♔♕♖♗♘♙♚♛♜♝♞♟

To get a further size reduction, you can use read/write order to determine which value is which, so the first two characters represent the id, the next two are the x position, the next two the y, then the angle, then health, etc. So:

F5DGP@%&002DFTK#OP1F

could store all the same information as the other examples.

Tile grids can be stored as just a string with each character representing a different type of tile eg:

i789pog5h3kl

where I might mean lava, 9 mean grass etc

XML is a good choice if you're not limited by size and it is supported natively (eg in .NET and Flash) but if you want a slim format you can create your own format and parser quite easy. I normally use 1 character eg. comma to seperate each object. To decode the string do a split on comma. Now each object needs different properties so seperate these with a different character eg semi colon, and use another character to seperate the property names from property vales, eg. Colon. All thus can be decoded easily without regex just by using string.split. Here is an example:

id:1;x:5;y:45.2;angle:45,id:28;x:56;y:89;angle:12;health:78

you can save even more space by keeping property names down to 1 character, eg h for health. Eg.

i:1;x:5;y:45.2;a:45,i:28;x:56;y:89;a:12;h:78

Compare to JSON alternative:

{"o":[{"i":1, "x":5, "y":45.2, "a":45}, {"i":28, "x":56, "y":89, "a":12, "h":78}]}

Also, if you want to get the size of your numbers down, you can encode them using the full set of printable UTF16 characters. This thread inspired me to ask a question over on Stack Overflow of how much data you could pack into one on-screen character. The answer seem to be somewhere over 40,000 values for an integer, if you don't mind having brail, Kanji and chess pieces: ♔♕♖♗♘♙♚♛♜♝♞♟

To get a further size reduction, you can use read/write order to determine which value is which, so the first two characters represent the id, the next two are the x position, the next two the y, then the angle, then health, etc. So:

F5DGP@%&002DFTK#OP1F

could store all the same information as the other examples.

Tile grids can be stored as just a string with each character representing a different type of tile eg:

i789pog5h3kl

where I might mean lava, 9 mean grass etc

added 185 characters in body
Source Link
Iain
  • 6.6k
  • 3
  • 35
  • 46

XML is a good choice if you're not limited by size and it is supported natively (eg in .NET and Flash) but if you want a slim format you can create your own format and parser quite easy. I normally use 1 character eg. comma to seperate each object. To decode the string do a split on comma. Now each object needs different properties so seperate these with a different character eg semi colon, and use another character to seperate the property names from property vales, eg. Colon. All thus can be decoded easily without regex just by using string.split. Here is an example:

id:1;x:5;y:45.2;angle:45,id:28;x:56;y:89;angle:12;health:78

you can save even more space by keeping property names down to 1 character, eg h for health. Eg.

i:1;x:5;y:45.2;a:45,i:28;x:56;y:89;a:12;h:78

Compare to JSON alternative:

{"o":[{"i":1, "x":5, "y":45.2, "a":45}, {"i":28, "x":56, "y":89, "a":12, "h":78}]}

Also, if you want to get the size of your numbers down, you can encode them into ASCIusing the full set of printable UTF16 characters. If you use a standard 256 asci charset you can encodeThis thread inspired me to ask a question over on Stack Overflow of how much data you could pack into one on-screen character. The answer seem to be somewhere over 40,000 values for an integer between 0 and 255 into one character. If, if you use 2 that's 256x256 = 65536 possible numbersdon't mind having brail, which should be enough to store a relative position in your play area.Kanji and chess pieces: ♔♕♖♗♘♙♚♛♜♝♞♟

To get a further size reduction, you can use read/write order to determine which value is which, so the first two characters represent the id, the next two are the x position, the next two the y, then the angle, then health, etc. So:

F5DGP@%&002DFTK#OP1F

could store all the same information as the other examples.

Tile grids can be stored as just a string with each character representing a different type of tile eg:

i789pog5h3kl

where I might mean lava, 9 mean grass etc

XML is a good choice if you're not limited by size and it is supported natively (eg in .NET and Flash) but if you want a slim format you can create your own format and parser quite easy. I normally use 1 character eg. comma to seperate each object. To decode the string do a split on comma. Now each object needs different properties so seperate these with a different character eg semi colon, and use another character to seperate the property names from property vales, eg. Colon. All thus can be decoded easily without regex just by using string.split. Here is an example:

id:1;x:5;y:45.2;angle:45,id:28;x:56;y:89;angle:12;health:78

you can save even more space by keeping property names down to 1 character, eg h for health. Eg.

i:1;x:5;y:45.2;a:45,i:28;x:56;y:89;a:12;h:78

Compare to JSON alternative:

{"o":[{"i":1, "x":5, "y":45.2, "a":45}, {"i":28, "x":56, "y":89, "a":12, "h":78}]}

Also, if you want to get the size of your numbers down, you can encode them into ASCI. If you use a standard 256 asci charset you can encode an integer between 0 and 255 into one character. If you use 2 that's 256x256 = 65536 possible numbers, which should be enough to store a relative position in your play area.

To get a further size reduction, you can use read/write order to determine which value is which, so the first two characters represent the id, the next two are the x position, the next two the y, then the angle, then health, etc. So:

F5DGP@%&002DFTK#OP1F

could store all the same information as the other examples.

Tile grids can be stored as just a string with each character representing a different type of tile eg:

i789pog5h3kl

where I might mean lava, 9 mean grass etc

XML is a good choice if you're not limited by size and it is supported natively (eg in .NET and Flash) but if you want a slim format you can create your own format and parser quite easy. I normally use 1 character eg. comma to seperate each object. To decode the string do a split on comma. Now each object needs different properties so seperate these with a different character eg semi colon, and use another character to seperate the property names from property vales, eg. Colon. All thus can be decoded easily without regex just by using string.split. Here is an example:

id:1;x:5;y:45.2;angle:45,id:28;x:56;y:89;angle:12;health:78

you can save even more space by keeping property names down to 1 character, eg h for health. Eg.

i:1;x:5;y:45.2;a:45,i:28;x:56;y:89;a:12;h:78

Compare to JSON alternative:

{"o":[{"i":1, "x":5, "y":45.2, "a":45}, {"i":28, "x":56, "y":89, "a":12, "h":78}]}

Also, if you want to get the size of your numbers down, you can encode them using the full set of printable UTF16 characters. This thread inspired me to ask a question over on Stack Overflow of how much data you could pack into one on-screen character. The answer seem to be somewhere over 40,000 values for an integer, if you don't mind having brail, Kanji and chess pieces: ♔♕♖♗♘♙♚♛♜♝♞♟

To get a further size reduction, you can use read/write order to determine which value is which, so the first two characters represent the id, the next two are the x position, the next two the y, then the angle, then health, etc. So:

F5DGP@%&002DFTK#OP1F

could store all the same information as the other examples.

Tile grids can be stored as just a string with each character representing a different type of tile eg:

i789pog5h3kl

where I might mean lava, 9 mean grass etc

added 328 characters in body; edited body
Source Link
Iain
  • 6.6k
  • 3
  • 35
  • 46

XML is a good choice if you're not limited by size and it is supported natively (eg in .NET and Flash) but if you want a slim format you can create your own format and parser quite easy. I normally use 1 character eg. comma to seperate each object. To decode the string do a split on comma. Now each object needs different properties so seperate these with a different character eg semi colon, and use another character to seperate the property names from property vales, eg. Colon. All thus can be decoded easily without regex just by using string.split. Here is an example:

id:1;x:5;y:45.2;angle:45,id:28;x:56;y:89;angle:12;health:78

you can save even more space by keeping property names down to 1 character, eg h for health. Eg.

i:1;x:5;y:45.2;a:45,i:28;x:56;y:89;a:12;h:78

Compare to JSON alternative:

{"o":[{"i":1, "x":5, "y":45.2, "a":45}, {"i":28, "x":56, "y":89, "a":12, "h":78}]}

Also, if you want to get the size of your numbers down, you can encode them into ASCI. If you use a standard 256 asci charset you can encode an integer between 0 and 255 into one character. If you use 2 that's 256x256 = 6300065536 possible numbers, which should be enough to store a relative position in your play area.

To get a further size reduction, you can use read/write order to determine which value is which, so the first two characters represent the id, the next two are the x position, the next two the y, then the angle, then health, etc. So:

F5DGP@%&002DFTK#OP1F

could store all the same information as the other examples.

Tile grids can be stored as just a string with each character representing a different type of tile eg:

i789pog5h3kl

where I might mean lava, 9 mean grass etc

XML is a good choice if you're not limited by size and it is supported natively (eg in .NET and Flash) but if you want a slim format you can create your own format and parser quite easy. I normally use 1 character eg. comma to seperate each object. To decode the string do a split on comma. Now each object needs different properties so seperate these with a different character eg semi colon, and use another character to seperate the property names from property vales, eg. Colon. All thus can be decoded easily without regex just by using string.split. Here is an example:

id:1;x:5;y:45.2;angle:45,id:28;x:56;y:89;angle:12;health:78

you can save even more space by keeping property names down to 1 character, eg h for health. Eg.

i:1;x:5;y:45.2;a:45,i:28;x:56;y:89;a:12;h:78

Compare to JSON alternative:

{"o":[{"i":1, "x":5, "y":45.2, "a":45}, {"i":28, "x":56, "y":89, "a":12, "h":78}]}

Also, if you want to get the size of your numbers down, you can encode them into ASCI. If you use a standard 256 asci charset you can encode an integer between 0 and 255 into one character. If you use 2 that's 256x256 = 63000 possible numbers, which should be enough to store a relative position in your play area.

Tile grids can be stored as just a string with each character representing a different type of tile eg:

i789pog5h3kl

where I might mean lava, 9 mean grass etc

XML is a good choice if you're not limited by size and it is supported natively (eg in .NET and Flash) but if you want a slim format you can create your own format and parser quite easy. I normally use 1 character eg. comma to seperate each object. To decode the string do a split on comma. Now each object needs different properties so seperate these with a different character eg semi colon, and use another character to seperate the property names from property vales, eg. Colon. All thus can be decoded easily without regex just by using string.split. Here is an example:

id:1;x:5;y:45.2;angle:45,id:28;x:56;y:89;angle:12;health:78

you can save even more space by keeping property names down to 1 character, eg h for health. Eg.

i:1;x:5;y:45.2;a:45,i:28;x:56;y:89;a:12;h:78

Compare to JSON alternative:

{"o":[{"i":1, "x":5, "y":45.2, "a":45}, {"i":28, "x":56, "y":89, "a":12, "h":78}]}

Also, if you want to get the size of your numbers down, you can encode them into ASCI. If you use a standard 256 asci charset you can encode an integer between 0 and 255 into one character. If you use 2 that's 256x256 = 65536 possible numbers, which should be enough to store a relative position in your play area.

To get a further size reduction, you can use read/write order to determine which value is which, so the first two characters represent the id, the next two are the x position, the next two the y, then the angle, then health, etc. So:

F5DGP@%&002DFTK#OP1F

could store all the same information as the other examples.

Tile grids can be stored as just a string with each character representing a different type of tile eg:

i789pog5h3kl

where I might mean lava, 9 mean grass etc

added 1 characters in body
Source Link
Iain
  • 6.6k
  • 3
  • 35
  • 46
Loading
added 133 characters in body
Source Link
Iain
  • 6.6k
  • 3
  • 35
  • 46
Loading
added 374 characters in body
Source Link
Iain
  • 6.6k
  • 3
  • 35
  • 46
Loading
Source Link
Iain
  • 6.6k
  • 3
  • 35
  • 46
Loading