Heroes of Might and Magic Community
visiting hero! Register | Today's Posts | Games | Search! | FAQ/Rules | AvatarList | MemberList | Profile


Age of Heroes Headlines:  
5 Oct 2016: Heroes VII development comes to an end.. - read more
6 Aug 2016: Troubled Heroes VII Expansion Release - read more
26 Apr 2016: Heroes VII XPack - Trial by Fire - Coming out in June! - read more
17 Apr 2016: Global Alternative Creatures MOD for H7 after 1.8 Patch! - read more
7 Mar 2016: Romero launches a Piano Sonata Album Kickstarter! - read more
19 Feb 2016: Heroes 5.5 RC6, Heroes VII patch 1.7 are out! - read more
13 Jan 2016: Horn of the Abyss 1.4 Available for Download! - read more
17 Dec 2015: Heroes 5.5 update, 1.6 out for H7 - read more
23 Nov 2015: H7 1.4 & 1.5 patches Released - read more
31 Oct 2015: First H7 patches are out, End of DoC development - read more
5 Oct 2016: Heroes VII development comes to an end.. - read more
[X] Remove Ads
LOGIN:     Username:     Password:         [ Register ]
HOMM1: info forum | HOMM2: info forum | HOMM3: info mods forum | HOMM4: info CTG forum | HOMM5: info mods forum | MMH6: wiki forum | MMH7: wiki forum
Heroes Community > Library of Enlightenment > Thread: Calculating The Probabilities Of Spells Appearing
Thread: Calculating The Probabilities Of Spells Appearing
BTB
BTB


Famous Hero
Moist & Creamy
posted October 06, 2020 11:41 AM
Edited by BTB at 18:29, 09 Oct 2020.

Calculating The Probabilities Of Spells Appearing

So, if you look on TheLazy, it shows the actual calculated odds of each spell appearing in each town. I want to know the formula that was used to reach these conclusions since I'm working on a mod that changes these and I'd like to know what the results are. I have a formula that I think is mostly complete, but I feel like it's missing something.

Looking at level 1 spells, for which there are 16 in total, the formula I have so far is:

(X = Base odds of spell being chosen)

Slot 1: X
Slot 2: X / (100 - ((100 - X) / 15)) * (1 - Slot 1)
Slot 3: X / (100 - ((100 - X) / 14)) * (1 - Slots 1~2)
Slot 4: X / (100 - ((100 - X) / 13)) * (1 - Slots 1~3)
Slot 5: X / (100 - ((100 - X) / 12)) * (1 - Slots 1~4)

True odds: Slot 1 + Slot 2 + Slot 3 + Slot 4 + Slot 5

The thing that confuses me most is that, if every spell is weighted evenly, then the true odds of every spell adds up to 500% with this formula, which tracks. When you start changing the values around, even though they all still add up to 100%, the true odds no longer add up to 500%.

A final complication is that when working with smaller pools, it seems possible for the odds of one spell to be affected by the weight of others. If, for example, there were only two slots and three spells, then one spell weighted at 20% has different true odds depending on the weight of the other two (figured out by individually calculating each possible scenario - something that's not practical with 16 spells and 5 slots). I'm guessing (hoping, more accurately) there's a certain threshold ratio of slots to spells we can pass where that is no longer true, but I can't think of a logical proof to explain WHY.

Any help?

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
phoenix4ever
phoenix4ever


Legendary Hero
Heroes is love, Heroes is life
posted October 06, 2020 02:39 PM

Sorry I am not sure how these are exactly calculated myself.
I do know there are only 15 level 1 spells though. 15 level 2, 3 and 4 as well and 9 level 5 spells.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
BTB
BTB


Famous Hero
Moist & Creamy
posted October 06, 2020 03:09 PM
Edited by BTB at 15:09, 06 Oct 2020.

Yeah, this is assuming a modded game where there are different numbers of spells on each level than the base game, hence me wanting to get the exact formula.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
phoenix4ever
phoenix4ever


Legendary Hero
Heroes is love, Heroes is life
posted October 06, 2020 03:21 PM

Ah okay so you moved some spells up and down levels?
Yeah I considered doing that myself, but as you know it messes with spell probabilities, so I probably wont do that, especially since I have no idea how to change Cove's spell probabilities.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
BTB
BTB


Famous Hero
Moist & Creamy
posted October 06, 2020 04:51 PM

Well, my math is pretty sound from what I figure - only thing that breaks it is if you move too close to a weird threshold like the "three spells/two slots" scenario I mentioned earlier. Aside from that, the current math seems to be close enough for government work.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Mortarial
Mortarial


Hired Hero
posted October 06, 2020 05:26 PM

[url=http://heroescommunity.com/viewthread.php3?TID=17964&PID=1381141#focus]The explanation[/url]

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
phoenix4ever
phoenix4ever


Legendary Hero
Heroes is love, Heroes is life
posted October 06, 2020 05:29 PM
Edited by phoenix4ever at 19:21, 06 Oct 2020.

BTB said:
Well, my math is pretty sound from what I figure - only thing that breaks it is if you move too close to a weird threshold like the "three spells/two slots" scenario I mentioned earlier. Aside from that, the current math seems to be close enough for government work.

That's cool.
Can I ask which spells you have moved and to which levels?

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
BTB
BTB


Famous Hero
Moist & Creamy
posted October 06, 2020 09:38 PM

phoenix4ever said:
BTB said:
Well, my math is pretty sound from what I figure - only thing that breaks it is if you move too close to a weird threshold like the "three spells/two slots" scenario I mentioned earlier. Aside from that, the current math seems to be close enough for government work.

That's cool.
Can I ask which spells you have moved and to which levels?


https://cdn.discordapp.com/attachments/692895170722660434/763122785333280859/Spells.jpg

The ones with asterisks are spells that were renamed to be more inline with Might & Magic 7:

View Air    -> Wizard Eye
View Earth    ->  Clairvoyance
Precision   -> Fate
Animate Dead  ->  Reanimate
Air Shield  -> Shield
Fire Shield   ->  Pain Reflection
Teleport    -> Jump
Frost Ring    ->  Ice Blast

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Phoenix4ever
Phoenix4ever


Legendary Hero
Heroes is love, Heroes is life
posted October 06, 2020 10:14 PM

Interesting. It seems like you have also removed some spells completely?

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
BTB
BTB


Famous Hero
Moist & Creamy
posted October 06, 2020 10:17 PM
Edited by BTB at 22:18, 06 Oct 2020.

Yeah, I trashed the stuff that nobody wants. I'm a firm believer in the "less is more" approach to design, so if the overall product is stronger for cutting something, it needs to go.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Phoenix4ever
Phoenix4ever


Legendary Hero
Heroes is love, Heroes is life
posted October 06, 2020 10:23 PM

Makes sense. The only spell I find completely useless is Disguise. View Air and View Earth I almost never cast either.
But I rather look for ways to buff useless stuff, than to trash it.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
BTB
BTB


Famous Hero
Moist & Creamy
posted October 06, 2020 10:32 PM
Edited by BTB at 22:32, 06 Oct 2020.

Phoenix4ever said:
Makes sense. The only spell I find completely useless is Disguise. View Air and View Earth I almost never cast either.
But I rather look for ways to buff useless stuff, than to trash it.


I try to determine whether or not something is worth salvaging. If it's a good concept with a flawed execution, I will. If making it work is just going to be more trouble than it's worth, I don't. I also consider whether or not it fills a needed role within the game or if it's just going to feel tacked on.

I never cast View Earth/Air, either, but then again I tend to play on maps I already know. I want to find a way to make their casting cost 0 with relevant magic expertise, but that's currently backburnered.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Phoenix4ever
Phoenix4ever


Legendary Hero
Heroes is love, Heroes is life
posted October 06, 2020 11:24 PM

Is'nt it possible to somehow link those spells to Titan's Lightning Bolt, so spell cost becomes 0?

Ugh I want to remove Disguise too, but the problem is it will make Blind and Visions more common. I also hate how ballista/cannon/arrow towers shoots at blinded targets. You don't happen to know how to prevent that?
I also considered switching Blind and Hypnotize, Blind is clearly much better.
Slow and Haste could easily go up a level or two. Maybe also Shield, Bless, Cure and Dispel.
And yeah Armageddon is powerful enough to be level 5.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
BTB
BTB


Famous Hero
Moist & Creamy
posted October 06, 2020 11:30 PM

Removing Disguise doesn't make anything more likely to appear except whatever spell you give its probability points to; remember that every level for each town adds up to 100.

No clue how to prevent random targeting objects from hitting blind enemies.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Phoenix4ever
Phoenix4ever


Legendary Hero
Heroes is love, Heroes is life
posted October 06, 2020 11:41 PM

I guess I could add the probabilities from Disguise to another spell, except I can't change Cove. But it would also mean I would only have 14 level 2 spells, so Blind and Visions would also be easier to get from level 2 shrines. Guess I could move Hypnotize down to level 2 then maybe...
Sorry for my rambling.

Just had a random thought:
Do you think it's possible to only have 3 (4 if Tower with Library) level 2 spells appear in Mage Guilds?

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
BTB
BTB


Famous Hero
Moist & Creamy
posted October 06, 2020 11:58 PM

Possible? Of course.

Do I know how? Absolutely not.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
BTB
BTB


Famous Hero
Moist & Creamy
posted October 09, 2020 06:22 PM
Edited by BTB at 18:40, 18 Oct 2020.

Mortarial said:
The explanation


So, if you have Python... here's how to nail down your odds for good:

import random

SEARCHED = "Slow"
MAX_DEPTH = 5
spells = [
   ["Wizard Eye",4],
   ["Disrupting Ray",6],
   ["Air Resistance",4],
   ["Haste",12],
   ["Clairvoyance",4],
   ["Magic Arrow",6],
   ["Earth Resistance",4],
   ["Slow",4],
   ["Fortune",12],
   ["Curse",8],
   ["Fire Resistance",12],
   ["Fire Wall",24],
   ["Cure",0],
   ["Bless",0],
   ["Water Resistance",0],
   ["Ice Bolt",0],
]

slot_probabilities = [0 for _ in range(MAX_DEPTH)]
nodes = 0
def compute_prob(arr, depth=0, base_prob=1.0):
   global nodes
   nodes += 1
   if nodes%1000000==0:
       print(nodes)

   if depth >= MAX_DEPTH:
       return

   total_w = 0
   for spell in arr:
       total_w += spell[1]

   for spell in arr:
       if spell[0]==SEARCHED:
           slot_probabilities[depth] += base_prob*spell[1]/total_w
       else:
           new_arr = arr[:]
           new_arr.remove(spell)
           compute_prob(new_arr, depth+1, base_prob*spell[1]/total_w)

compute_prob(spells)

print("total chance: {}".format(sum(slot_probabilities)))
print(slot_probabilities)

(NOTE: "MAX_DEPTH" is the number of spell slots)

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Jump To: « Prev Thread . . . Next Thread »
Post New Poll    Post New Topic    Post New Reply

Page compiled in 0.0485 seconds