HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Code length reduction

04-29-2004, 05:31 PM#1
Kackwiesel
Hi,
I dont know if this is the right forum.. but do you know some methods to reduce the length of a code number?
My Savesystem code has 35 Symbols, it Saves Gold (99999 rounded up to 4 Symbols), 99 Lumber, XP (99999 rounded up to 4 symbols), Items (finally :D) up to 999 difftend items (3 symbols for one item) and the Herotype (2 symbols), and a mix of all + Playername, to proof if its valid (5 symbols).
Do you have some ideas how to reduce the length of such a code without loseing to much data? A length of 30 symbols would be excellent.^^
04-29-2004, 06:26 PM#2
Wyll
Well offhand you could store level instead of exp. Though that will probably only save you 1 digit.

If your using numbers only then try converting it to hex or your own system. Like 36 as a base (0-9 and a-z). So instead of a number of 24 you can use N. You'll be able to reduce a lot of 3 digit numbers down to 2, and 4 down to 3 as well. If you can keep your item ID's below 360 you can be sure that each only uses 2 digits which saves you 6 digits right there.
04-29-2004, 07:04 PM#3
Kackwiesel
Great idea! 360 should be enough. Saving the level instead of XP could be anoying, but it prevents leaving and slows the leveling.. maybe I do this, too. I have to rework my encryption system, because its integer based, but I think its worth to do it.

-XP down to 1 symbol
-Hero_ID down to 1 symbol
-Items down to 12 symbols

But what is with numbers like 9999 for Gold? How would it look like in such a system? Can you give an example for that? If its to much work for you to do an fast example, so I can do it myself. But I have atm no clue how this could look like.
04-29-2004, 07:17 PM#4
ThyFlame
You can make the letter into a number when you decode and the number into the letter when you encode the final time. You still use integers to do the encode/decode.
04-29-2004, 08:23 PM#5
Wyll
Yes it is hard to convert on the fly when your dealing with 36 characters for each digit. 9999 gold would turn out to be something like q7q. So you can keep gold amounts down to 3 digits. I'm looking at an example conversion here and they used 32 characters, removing ones like o, l, and q so they aren't confused with other letters or numbers.
04-30-2004, 09:31 AM#6
Kackwiesel
Ok, big thx for your help. I have found a good site about conversion, so I can do this myself now. :)

9999 should be 7 25 27 -> 7pr

The item maximum should be zz -> 35*36^1+35*36^0 = 1295

This was a great help! Now my code will be much shorter.
05-20-2004, 06:41 PM#7
Nandon
I am currently modding a map that already has a save code feature built in but doesnt allow for many items to be saved. Could you help me out and show me some code or give me an idea of how to save more items? like when i try to assign "ab" for it messes up cause other items are only 1 integer. Or should i just dump all the 1 integers and go with 2 for all of them? does that work or is there something special to do for 2 integers? thanks for the help
05-20-2004, 06:54 PM#8
MysticGeneral
Check out kattana's jass site. You'll find some useful stuff there. What you're looking for is a ascii to character. You can have the code down to 1/4 of the size if you really try.
05-20-2004, 08:42 PM#9
ThyFlame
I would like to point out that if you are using the playername as part of your security, use a case or use 52 letters (uppercase and lowercase). It saves a lot of hassle.


On another note, this thread was 3 weeks dead. It should not have been revived.
05-21-2004, 01:35 PM#10
Cubasis
While being a dead subject, here is deffinetely the way to create the SHORTEST save/load codes available. It is basicly a API where you can do anything. However, as it's in JASS, it can be a lil hard to use, so it kinda needs a guide. But what makes it so small, is that it's 100% bit-oriented. So you assign the exact ammount of bits for a value, as it needs. It also uses case-32 (a-z A-Z 0-9 minus some of the most confusing symbols).

So different values can be stored in the same character etc.

http://kattana.users.whitehat.dk/viewfunc.php?id=288


~Cubasis