[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 390: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 120: preg_filter(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 120: preg_filter(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 120: preg_filter(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 120: preg_filter(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 120: preg_filter(): The /e modifier is no longer supported, use preg_replace_callback instead
QCF Design Community • View topic - Ok, so how does the shop algorithm actually work?


Ok, so how does the shop algorithm actually work?

All things Desktop Dungeons

Re: Ok, so how does the shop algorithm actually work?

Postby Gakato on Wed Dec 09, 2015 4:21 pm

Gakato
 
Posts: 118
Joined: Mon Dec 30, 2013 10:31 pm

Re: Ok, so how does the shop algorithm actually work?

Postby Astral on Wed Dec 09, 2015 5:30 pm

Yeah that was my bad :P

I forgot that I rearranged the indices to go from 1-38, so that needed the change in n-1 to n as well.
I should think more before posting...

And thanks for the info about arrays, that was interesting to read :)
Somebody spilled raspberry juice all over the place!
User avatar
Astral
 
Posts: 562
Joined: Fri Jan 17, 2014 10:56 pm

Re: Ok, so how does the shop algorithm actually work?

Postby Tinker on Wed Dec 09, 2015 7:10 pm

"Thinker", just without the "ache".
User avatar
Tinker
 
Posts: 2000
Joined: Fri Oct 31, 2014 8:51 am

Re: Ok, so how does the shop algorithm actually work?

Postby Phoil on Thu Dec 10, 2015 10:11 am

I put together a simple calculator at: http://jsfiddle.net/Phoil/h9g0d7ka/

If someone wants to host that somewhere better that's fine by me.
Phoil
 
Posts: 19
Joined: Thu Sep 03, 2015 10:06 am

Re: Ok, so how does the shop algorithm actually work?

Postby Tinker on Thu Dec 10, 2015 8:55 pm

"Thinker", just without the "ache".
User avatar
Tinker
 
Posts: 2000
Joined: Fri Oct 31, 2014 8:51 am

Re: Ok, so how does the shop algorithm actually work?

Postby Tinker on Sat Dec 12, 2015 5:28 pm

I did a bit of toying around with the calculator. So my first question was, what's the odds to find Vampiric Blade (index #13, as it's 14th item in the list), and what's the best odds to get that item if I want to rig stuff.

In a fully-unlocked kingdom, assuming 8 stores, you have [8|14|38=] 27% chance to find it in store.
-> If you prepare Quest Items, the chance goes up to [8|6|38=] 34%.
-> If you prepare Quest Items and veto the higher-ranked five Quest Items (Fire Heart, Hero's Helm, Battlemage Ring, Venom Dagger, Whurrgarbl), your chance goes up to [8|1|33=] 43%; adding two more vetos (to reduce number of items) only helps a bit, getting you [8|1|31=] 45%.
-> If you want to play purist, you can still veto items to help your odds. In this case, vetoing as many as possible Basic Items and/or some of the five quest items mentioned above helps the most. You get almost [8|7|31=] 39% chance this way if you veto 7 items, so actually better than just with quest items prep.

If you are rigging your kingdom, and unlock items selectively, you can get a bit better numbers. Assuming that you have only unlocked this single quest item, and have fully-upgraded Bazaar (so you get 8 stores, and look for the 9th item out of 17), you have a base [8|9|17=] 52% chance to find it in store.
-> If you prepare Quest Items, you chance goes up to [8|1|17=] 72%.
-> Having some items vetoed (maximum 3 is possible without the other class challenges) helps a bit, pushing chances up to [8|1|14=] 82% if you have prepped Quest Items.
-> If you want to play purist, vetoing 3 Basic Items gives you [8|6|14=] 70% chance (almost as good as the Quest Items prep).
--> It seems quite logical that unlocking the other two mage items (Blue Bead and Mage Plate) to get one more veto slot should help odds as both of those items are under Vampire Blade in the ranking. It doesn't really help though. Your chances to find the sword will be at least a tad bit lower, even if you use the new veto slot optimally. Going for the veto slot only makes sense if you need two items from the given guild; then getting the third just for the veto slot will generally help your chances (worst case you veto the item itself; but usually you can veto something higher-ranked).

Couple of random (not necessarily surprising) conclusions:

* In a fully-unlocked kingdom, you ought to get an average of 2.8 Basic Items, 4.8 Quest Items and 0.4 Elite Items in a standard 8-shop run. Prepping Quest items ought to give you 1.2 Basic Items, 6.4 Quest Items, and 0.4 Elite Items. Prepping Elite Items ought to give you 2.8 Elite Items, 2.3 Basic Items, and 2.9 Quest Items.
* Generally, the first 2/3 of the items behave differently than the last 1/3 of items. While it is generally true that adding higher-ranked items decreases shop spawn chance, and vetoing higher-ranked items increases shop spawn chance, they behave differently when it comes to adding/removing lower-ranked items: the first 2/3 ranked items will have their chance to be found reduced, while the last 1/3 will have it increased, if you add more lower-ranked items! Must be that whole sqare-root thingy.
* Veto slots can be valuable. Vetoing higher-ranked items boost odds of finding specific items a lot. Interestingly, vetoing lower-ranked items doesn't necessarily help with the odds (see above). So choosing what to veto is really important.
* Selective unlocks are, like, hacking the game. The probability boost can be huge. Using a combination of selective unlocks, veto slots and preparations can give you a near-100% chance to find what you need in store. It's too bad that there are no good or bad items, and you need different items for different builds, i.e. you'd need several kingdoms with each rigged differently to really benefit from this. I guess this is where Veto Slots come into the picture, you can easily reset them with a Tinker run or two, and play a slightly differently skewed shop pool.

I'm sure this is just scratching the surface. I haven't actually done anything with this yet, but I'm thinking about trying some Purist stunts to see if using veto slots smartly & picking right unlocks really helps the odds enough... ;)
"Thinker", just without the "ache".
User avatar
Tinker
 
Posts: 2000
Joined: Fri Oct 31, 2014 8:51 am

Re: Ok, so how does the shop algorithm actually work?

Postby Tinker on Sat Jan 02, 2016 7:29 pm

I re-wrote the Shop Spawn page on the Wiki. Since I'm using big words, it might be good for someone smart to proofread if what I'm writing is actually true... :lol:

Also posted an external link to Phoil's awesome calculator.
"Thinker", just without the "ache".
User avatar
Tinker
 
Posts: 2000
Joined: Fri Oct 31, 2014 8:51 am

Re: Ok, so how does the shop algorithm actually work?

Postby Tinker on Sat Jan 16, 2016 12:04 pm

So here's an illustrated explanation of how the shop spawn works, using today's Daily (DERP-16/01/2016, Gnome Tinker in Rock Garden):

I charted it up in a spreadsheet, I hope it's not impossible to read.

Image

So how things work...
1. The default lookup indexes for today are: -3, -8, -13, -15, -19, -22, -24, -26, -28, -30 (it's quite rare by the way, how few big numbers there are, due to the square-root thingy bigger numbers are most likely)
2. The default list uses Basic Items -> Quest Items -> Elite Items sequence

I. No shop items prepared
1. As the list length stays 38 items, the default lookup indexes do not change and stay -3, -8, -13, -15, -19, -22, -24, -26, -28, -30
2. As no items are removed from the list, they will correspond to the following items: Spoon (7), Hero's Helm (9), Venom Dagger (11), Vampiric Blade (13), Martyr Wraps (15), Gloves of Midas (18), Mage Plate (22), Viper Ward (24), Witchalok Pendant (29), Alchemist's Scroll (34).

II. One shop item prepared
1. The default indexes get re-calculated based on the new list length of 37 items (as we took out one item, the one we prepared). This is impossible to predict, but generally, lookup indexes will either stay what they were, or get shifted one number closer to zero. In this particular case, the new indexes will be: -3, -8, -13, -15, -19, -21, -23, -25, -28, -29. Higher lookup indexes are more likely to "round down", whereas lower indexes are almost guaranteed to stay what they were (key word, "almost"... :) ).
2. Now, depending on which item you prepared, the list gets "cut" at a different point. For example, if you prepared the Battlemage Ring, you see that lookup indexes -28 and -29 will pick up an earlier item, as they skip the "no longer existing" Battlemage Ring. Conversely, if you prepare the Crystal Ball, which is much lower in the list, only the first two lookup indexes (-3 and -8) will pick up the item they are supposed to, all other lookup indexes will point to an item that is one slot higher, as they skip the (no longer listed) Crystal Ball.

III. Two shop items prepared
1. The default indexes get re-calculated based on list length 36, again resulting in some indexes getting rounded closer to zero. In this particular case, they become: -3, -8, -12, -15, -18, -21, -22, -25, -27, -28.
2. Now, you will have two items taken out of the list, in this case it will be the Crystal Ball and one of (Battlemage Ring / Bloody Sigil / Whurrgarbl). So you see how the list is now "cut" in two places: where the Crystal Ball would normally be, and in one other place (corresponding to the other item you prepped). You will see that this will result in the lookup indexes picking up what they are supposed to pick up only at the very end of the list (i.e. below where the Crystal Ball would have been); above that, they will skip 1 slot (or, above the other prepared item's original place, they will actually skip 2 slots).

There were no item group preparations today (Quest Items / Elite Items), but all they would do really is re-arrange the listing of the item groups, and so the lookup indexes would pick up the same slots, modified only by what they skip... ;)
"Thinker", just without the "ache".
User avatar
Tinker
 
Posts: 2000
Joined: Fri Oct 31, 2014 8:51 am

Re: Ok, so how does the shop algorithm actually work?

Postby ~'(^ + ^)'~ on Sat Feb 13, 2016 7:25 am

User avatar
~'(^ + ^)'~
 
Posts: 774
Joined: Wed Mar 05, 2014 2:51 pm

Re: Ok, so how does the shop algorithm actually work?

Postby Tinker on Sat Feb 13, 2016 8:17 pm

"Thinker", just without the "ache".
User avatar
Tinker
 
Posts: 2000
Joined: Fri Oct 31, 2014 8:51 am

PreviousNext

Return to Desktop Dungeons

Who is online

Users browsing this forum: No registered users and 107 guests