Recommendations for this map

Ok well I've set out to write 3 libraries that will determine your best possible stat outfit. (pain in the ass, yes I know) Well anyway, I've just about finished the data entry for my moxie one and I came to a conclusion that it might not be stored in the best possible way for reference.

Right now my map is set up as
Code:
item[int, slot] staticMoxieIncreasingEquipment;

But I'm debating about int index there. Should I run the index all the way from the beginning to the end as one sequence, or should I break at each slot and start it at zero. This way it divides the items up by ranges within the map. It won't be hard to change the code between each formats but I was just looking for some input. What do you guys/girls think about it? I've been staring at the code for so long that I'm having trouble focusing on future issues.
 

Veracity

Developer
Staff member
Consider this:

Code:
item [slot, int] staticMoxieIncreasingEquipment;

This is a map keyed by slot of maps keyed by int of items. Since there are, effectively, only 4 slots you care about (hat, shirt, pants, acc1), that means KoLmafia will create a total of 5 maps: those 4 and one map to hold the others.

Doing it the other way around creates one map for each "index".
All of the "index 1" items will be grouped together in one map.
All of the "index 2" items will be grouped together in one map.
All of the "index 3" items will be grouped together in one map.

That doesn't seem useful.

Additionally, if you have your first map indexed by slot, you can use the concept of a "slice".

Code:
item [slot, int] staticMoxieIncreasingEquipment;
item [int] moxieHatMap = staticMoxieIncreasingEquipment[ hat ];

moxieHatMap[ 0 ] = $item[ xxx ];
moxieHatMap[ 1 ] = $item[ xxx ];
moxieHatMap[ 2 ] = $item[ xxx ];

foreach hat in moxieHatMap
    print( "Hat # " + hat + " is " + moxieHatMap[ hat ] );
 
*snipping quote of entire message in post just above it...*

That makes much more sense. That way I can, like you said, pull slices out for my processing. Thanks so much!
 

Nightmist

Member
In my own equipment map I'm using a huge single map of stats and a single less huge reference map.
Code:
float [ item, string] EquipmentDatabase_Stats;
item [ slot, int] EquipmentDatabase_Reference;
The string in the stats map defines what the float value is for and the reference just helps me get the "item" value too look for in the stats map.

Eg.

Code:
float [ item, string] EquipmentDatabase_Stats;
EquipmentDatabase_Stats [ $item[Bigger Bugfinder Blade], "Power"] = 200;
EquipmentDatabase_Stats [ $item[Bigger Bugfinder Blade], "StatReqAmount"] = 85;
EquipmentDatabase_Stats [ $item[Bigger Bugfinder Blade], "StatReqType"] = 1;
EquipmentDatabase_Stats [ $item[Bigger Bugfinder Blade], "MuscleAdd"] = 11;
EquipmentDatabase_Stats [ $item[Bigger Bugfinder Blade], "MysticalityAdd"] = 11;
EquipmentDatabase_Stats [ $item[Bigger Bugfinder Blade], "MoxieAdd"] = 11;
and
Code:
item [ slot, int] EquipmentDatabase_Reference;
EquipmentDatabase_Reference [ $slot[weapon], 1] = $item[Bigger Bugfinder Blade];
EquipmentDatabase_Reference [ $slot[weapon], 2] = $item[Bugfinder Blade];
EquipmentDatabase_Reference [ $slot[weapon], 3] = $item[plexiglass pike pike];
EquipmentDatabase_Reference [ $slot[weapon], 4] = $item[star crossbow];
This is a very very OLD script I haven't updated for ages so theres probably better ways but atleast I can say that it works in the end. The main reason I did this was because of the "percentage" based increasers which if you plan to "optimize and expand" the script should be kept as a possibility.
 
Top