• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Shorting Save/Load code

Status
Not open for further replies.
Level 9
Joined
Jul 10, 2011
Messages
562
hey all...

im not sure whether this should be here or in the trigger section but...okay...

here the question:

i wanna decrease the size of the save/load code but im not sure which solution is better.
i use acehearts at the moment...maybe later ill change it but thats the easiest one for me at the moment.

so now to my ideas:

if i have for example 8354 EXP (level 7 ; 1354 exp in level 7) and wanna save it which way i should save it to make the code as short as possible?

1. directly ; means i save 8354 EXP as one point
2. i use 2 points and save the level and the exp in that level
3. i split the exp in X different numbers (here: 8 , 3 , 5 , 4) save them as 4 points and multiply them on loading again to the original number


thanks in advance


greetz clapto


p.s. ill also use that for stats for example...
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
For even greater numbers, you could also do it to the power of 2/3.
Then, when loading, you do the opposite (^(3/2))
This is lossy compression, but works great with large numbers.
E.G: 157 683^(2/3) + 0.5 -> 2919
2919^(3/2) -> 157707
That's a difference of 24 while the integer was decreased with over 150 000.

The problem with saving xp this way is that, because it is lossy, you might gain/lose a level, though this should be very rare (in your example, there's an 8 XP difference).
With smaller numbers (like 100 or something), you're not going to decrease it by that much either and the compression becomes pretty clear.
So I suggest you use this once the values become rather big (over 10k or something).

Your suggestions are also mostly for large integers, the 3rd one seems pretty useful for 4-digit numbers though (maybe even 3-digit numbers).
Your stats are going to be that high?
 
Level 9
Joined
Jul 10, 2011
Messages
562
in late game the stats become that high...yes.

and i understand it right you would use the third option or the way you said, right?
 
Level 18
Joined
Mar 7, 2005
Messages
824
I'm not very familiar with Save/load codes, but I guess some of those things could decrease the length of the code:
  • add more custom/rare characters like ! " § $ % & / @
  • add upper AND lower case characters abc... ABC...
  • reduce the XP values, like using just 10 xp per level up and reducing the gain amount later on. with this you can avoid large numbers that might reach the million..
  • try to save only the important things (level won't be needed to save, if you save xp instead), or storing things into simple integer arrays to reduce their values (dunno if this works, but my guess is, that abilities have raw codes, and i guess those will be use to save/load, or? so just store them into an array called Abilities and count them. so maybe BuffA would be 11 instead of A001 or whatever the values are, but i might be wrong).

Basically just try to save as few as necessary and as much as needed, while reducing everything to lower or smaller numbers/amount that needs to be saved.
 
Level 17
Joined
Nov 13, 2006
Messages
1,814
i think if u have enough long string then i can save a aproximativ value, example if u are lv7 and for level 7 u need 8000 exp and for lv 8 u need lets say 9,500 exp then u can save the %, so
9500-8000=1500
u got 8354, what is 354 more than the requiment for level 7, its mean 354*100/1500=23.6% so u can save this value, 23.6 what is could be only 2 character if u use string with "a-zA-Z0-9*-+" etc :p
so u save lv and exp%, whatever the main advantage at high numbers not with low numbers
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
The later lessons in this map go over compression techniques -> http://www.hiveworkshop.com/forums/...ading-interactive-saving-loading-tutorial.w3m

pharaoh discussed one of the compression techniques in the map and even gave the exact number : ).

It is better to save the level and the exp (relative to the level) rather than just the exp, this way you will never have the player lose a level.

The first method before the number^2/3 was done was to save the xp as a percent of progress with the level. However, the number^2/3 thing gave WAY better results : ).

It is true that AceHart's may seem to be the easiest, but the save/load with snippets thing I wrote includes functions that will save stuff for you in the most compact manner possible, like a unit's inventory, a unit's level/xp, a unit's position, and so on. These algorithms are already coded so that you don't have to figure them out : ).

It also includes advanced catalogs to reduce your code even further. All of the algorithms use conditional save/load btw, which means that only relevant data is stored. If the unit has only 3 items and a 6 slot inventory, it isn't going to save 6 items, rather it'll save 4 ^)^.

The catalogs are highly advanced and awesome ;o. You know how AceHart's uses arrays for like item ids and so on? Catalogs are like super pimp multi-dimensional arrays with ubersauce.

Let's say that you want to save an inventory, so you create an item catalog. You could give items a level, make the items only usable by certain classes, link the item to a version of your map, and so on. All of these conditions can be passed into the catalog. The catalog will in turn give you the most compact set of items possible, dropping all items that don't meet all of those conditions ;o.

So if you have an item usable by a Paladin but you are saving a Mountain King, that item won't be included in the catalog, meaning that your max items value goes down, meaning that your code becomes smaller : ).
 
Status
Not open for further replies.
Top