Skip to content

After 30,000 Wish spell casts, we can finally answer this 18 years old question

MyragMyrag Member Posts: 328
Don't ask me why. I don't know why, I just did it.

TL;DR

Question:
Does wisdom above 18 increase probability of good wish results

Answer:
No

Long Version

I wrote a bot program which did run the regular game (2.5.16 version) with no mods installed and used sorcerer casting wish spells under improved alacrity. Bot then read results from the game screen and saved output to the file. File later was simply processed to calculate results. 10,000 casts per three wisdom values 18, 21 and 25 for total of 30,000 casts and 150,000 wish options scanned.

Below are my findings.

If you are interested here is showcase of bot in action.


So first of all

18 Wisdom 21 Wisdom 25 Wisdom
Wish Good Bad ? Count Chance% Count Chance% Count Chance%
Abi-Dalzim's horrid wilting on everyone in the area, including the party. BAD 1927 19.3% 1966 19.7% 2022 20.2%
All party members gain the temporary ability Greater Deathblow. GOOD 1983 19.8% 1965 19.7% 1916 19.2%
All party members gain the temporary ability Hardiness. GOOD 1980 19.8% 2050 20.5% 2038 20.4%
Breach on all enemies in the area. GOOD 2028 20.3% 1979 19.8% 2010 20.1%
Bring a "meteor swarm" down upon the caster. BAD 2025 20.3% 2049 20.5% 2022 20.2%
Cast a double-length time stop and improved alacrity on the caster. GOOD 2052 20.5% 1960 19.6% 2046 20.5%
Create a random potion in the caster's inventory. GOOD 2001 20.0% 1941 19.4% 1987 19.9%
Create a random wand in the caster's inventory. GOOD 2070 20.7% 2046 20.5% 2020 20.2%
Everyone in the area, both party members and enemies, become intoxicated. BAD 1955 19.6% 1976 19.8% 1987 19.9%
Haste everyone in the area, including enemies. BAD 1909 19.1% 2012 20.1% 2005 20.1%
Heal everyone, party members and enemies included. BAD 2029 20.3% 1910 19.1% 1960 19.6%
Improved haste on all enemies in the area. BAD 2036 20.4% 2049 20.5% 1954 19.5%
Improved haste on all party members. GOOD 1991 19.9% 1981 19.8% 2028 20.3%
Incur bad luck on everyone in the area, including party members. BAD 2016 20.2% 2025 20.3% 1992 19.9%
Level drain two levels from each party member. BAD 2036 20.4% 2002 20.0% 1992 19.9%
Magic resistance on everyone in the area, including enemies. BAD 1950 19.5% 1966 19.7% 2064 20.6%
Make it as if the entire party has just rested a full night and rememorized all their spells. GOOD 2008 20.1% 2073 20.7% 1981 19.8%
Miscast magic on everyone in the area, including party members. BAD 2064 20.6% 2049 20.5% 1979 19.8%
Party loses 10,000 gp. BAD 2038 20.4% 1995 20.0% 2024 20.2%
Raise all party members' characteristics to 25 for 4 rounds. GOOD 1956 19.6% 1939 19.4% 2033 20.3%
Restoration on all party members. GOOD 1982 19.8% 1984 19.8% 1978 19.8%
Resurrection on all dead party members. GOOD 2028 20.3% 2027 20.3% 2018 20.2%
Temporarily reduce the Wisdom of all party members to 3. BAD 1932 19.3% 2053 20.5% 1954 19.5%
Temporarily remove half of the caster's HP. BAD 1989 19.9% 1984 19.8% 1982 19.8%
Temporarily set Strength to 18 for everyone in the area, including enemies. BAD 2015 20.2% 2019 20.2% 2008 20.1%

So the conculsions from this table are.

Question:
Are all options of equal chance?

Answer:
Yes. Around 20% to get each option during single cast, this is because there are exactly 25 options and you choose 5 of them.


Question:
Does wisom increase the chances of any option?

Answer:
No


So additionaly let's check how many good/bad options do you get on average in each cast.

18 Wisdom 21 Wisdom 25 Wisdom
Good Results Count Chance% Count Chance% Count Chance%
0 377 3.8% 402 4.0% 351 3.5%
1 2040 20.4% 2107 21.1% 2096 21.0%
2 3778 37.8% 3748 37.5% 3778 37.8%
3 2821 28.2% 2720 27.2% 2807 28.1%
4 900 9.0% 933 9.3% 858 8.6%
5 84 0.8% 90 0.9% 110 1.1%


So the conculsions from this table are.

Question:
What is the chance to get zero good options?

Answer:
Only ataround 3.5-4% casts you won't get any option which can be considered always good.



So how many good and bad results did we get.


18 Wisdom 21 Wisdom 25 Wisdom
Result Count Chance% Count Chance% Count Chance% Wishes Chance%
BAD 27921 55.8% 28055 56.1% 27945 55.9% 14 56.0%
GOOD 22079 44.2% 21945 43.9% 22055 44.1% 11 44.0%


So the conculsions from this table are.

Question:
Are good/bad options happening more often?

Answer:
Because there are 14 bad options and 11 good options they will appear in 56% to 44% spread.


FAQ

Question:
Did you dcoument the results?
Answer:
Yes. They are here https://docs.google.com/spreadsheets/d/1PwVY3Cyk5JwqCmIjzd6YM1Qu0pW_BlrJRPWrGTAKCuo/edit?usp=sharing

Question:
How long did it take you to do this?
Answer:
Script ran for 30 hours in total.

Question:
What tool did you use?
Answer:
AutoHotKey

Now we can finally invest those wisdom points into divine casters for extra casts.

Thank you for reading.
Post edited by Myrag on

Comments

  • gorgonzolagorgonzola Member Posts: 3,864
    really interesting, thanx!
    so we now know for sure that wis over 18 is not helping, thing that was a common knowledge, but was never proved true.
    but now we also know that each possible outcome has the same 20% probability, thing that before your experiment was quite uncertain.
    Myrag said:



    Now we can finally invest those wisdom points into divine casters for extra casts.

    this is something i almost ever do with a charname sorcerer.
    but sometimes i use mod sorcerers, tashia and kelsey, that don't meet the requirement, and other times i use the mage npcs, even if a mage is less suited to make the best use of wish.
    anyway with charname, mod sorcerers or npc mages i think that the wish spell is best used trough a PI clone for a couple of reasons.
    you multiply your wish casts by the number of PI you have memorized, and you avoid the effects of some bad choices:
    "Party loses 10,000 gp." if you kill the PI or if it kills himself with spells, but not if is dispelled, must use skull traps or other damaging ones, you can collect the money on the ground, same is true for the potions and wands you can get from other choices.
    "Temporarily remove half of the caster's HP." is a PI who cares?
    and as long as a PI is used, at least in vanilla, a potion in quick slot fixes a low wis without spending the potion.
  • MyragMyrag Member Posts: 328
    edited October 2018

    so we now know for sure that wis over 18 is not helping, thing that was a common knowledge, but was never proved true.

    Before doing this test I did search forums and websites and there was no 'common agreement' in any of those so I wouldn't say it was common knowledge, an assumption would be the word I would use. People did test but they did cast spell up to 100 times which seemd to be too small of a sample for something which has 25 available options.

    you can collect the money on the ground, same is true for the potions and wands you can get from other choices

    In 2.5 this doesn't happen. I think it might have been fixed already. Any items that PI gets are not dropped upon death or dispel.
    deltago said:

    Not to be greedy, but a good experiment might be to do all the values from 9-18 to actually see the curve the game actually uses when casting the spell. How worse is a score of 16 compared to 18 when casting the spell for example.

    There is no need to test that via bot now. Since we know all options have equal chance you can simply grab a table of available wish options for each wisdom breakpoint and do a simple division to get percentiles.
  • gorgonzolagorgonzola Member Posts: 3,864
    @Myrag assumption or common knowledge, that is exactly what i meant, as i told that it had never been proved. i apologize for my poor knowledge of the english language :)
    about the trick to collect items from a dead clone i did not know it as i don't upgrade the game, as i don't like those tricks fixed :D imo freedom should be left to the player if to use them or not.
    still in the original game, that i find myself playing more often than the EE and also other players still use it works and is pretty useful.
  • CamDawgCamDawg Member, Developer Posts: 3,438
    edited October 2018

    @CamDawg: I was hoping to avoid mentioning that, but yes. The Wish responses aren't hardcoded, so you can view the outcomes by checking the dialog files in Near Infinity. I've actually had trouble understanding the exact pathways in those dialogues (that is, the probability of a Wish-rest), but you can tell there's no effect of higher Wisdom because the dialog triggers include no checks for WIS beyond 18.

    It's not the most intuitive of dialogues because SetupWish is not straightforward, and I think the IESDP entry is not quite correct given the results above.

    Essentially, SetupWish tells the game to go start rolling through a specific column in wish.2da, e.g. casters with >= 18 wisdom use the fourth column. The entries in the column are numbers, corresponding to setting the global WishPowerXX to 1, in turn enabling a dialogue reply. Now, the IESDP claims that the column gets parsed, top-to-bottom, with a 50% chance for each entry to be selected. If this was the case, then the first entry should have a 50% chance to always be a selection and we'd see a steady progression downward in the probabilities as we proceed down the list. This is not reflected in @Myrag 's testing, suggesting the IESDP is in error.

    It seems that, instead, five entries are selected with equal weight from the (in case of >= 18 wisdom) 25 available, resulting in the roughly equal 20% chance we see in the actual field testing.

  • valamyrvalamyr Member Posts: 130
    This is great, and the method and sample size seem quite conclusive.

    Thank you for your service.
  • MyragMyrag Member Posts: 328
    @CamDawg no worries. You are not ruining any parades here.

    One thing that I thought that wasn't conclusive is that this wouldn't be the first case where some parts of spell are hardcoded in the game itself (I'm looking at you stoneskin color change).

    You are 100% correct and I did check dialog files before. I assumed I will get above results anyway but I thought it will be a fun little project and opportunity for me to learn new scripting language, and it was. :smile:

    Very often on forums I see people debating things and doing manual tests to prove theory so I thought this could come handy in future to test things.
  • ProbablyNotANumberProbablyNotANumber Member Posts: 26
    edited October 2018
    Ha! Unless this is a 30,000 times unlikely coincidence, this whole project was prompted by me pondering out loud over here, right ? I wish you'd have poked so I wouldn't have spammed the place. :D

    Anyway, thanks a ton for solving the issue.


    Very often on forums I see people debating things and doing manual tests to prove theory so I thought this could come handy in future to test things.
     

    Clearly it would, if people can learn your method. To that end, would you mind sharing your AutoKey source code and setup, if it is not too time consuming ?
  • MyragMyrag Member Posts: 328
    edited October 2018

    Ha! Unless this is a 30,000 times unlikely coincidence, this whole project was prompted by me pondering out loud over here, right ? I wish you'd have poked so I wouldn't have spammed the place. :dizzy:

    Unlikely but it did happen. I didn't read comments on wiki. I just thought that for 25 options 10,000 tests will be enough to determine single wisdom value. :smile:

    I will share the code after I clean it up. It's super messy since it was my first time writing using this scripting language. It is 100 liner written in 2 hours so.
  • ProbablyNotANumberProbablyNotANumber Member Posts: 26
    edited October 2018
    Thanks, looking forward to it. Don't worry if it's not perfect, you know what you're bound to think about any code you write now in 5 years anyway, regardless of efforts. :p

    Well this is a major coincidence as our timing is synced down to the day. I kind of like these things because we're never completely independent from one another. Maybe someone posting somewhere else sparked your will to do this test by talking about Wish, and that someone actually was talking about it because he stumbled on the wiki yesterday (and so on). Whether pure coincidence or indirect dependence, that came RIGHT on spot to end my questioning, so thank you :D

    That is, unless it works differently on BG2:TOB non-EE... :dizzy:
  • MyragMyrag Member Posts: 328
    edited October 2018
    @ProbablyNotANumber sorry I forgot I promised the script. Here it is, it's very messy as I didn't get down to it in the end.

    #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. ; #Warn ; Enable warnings to assist with detecting common errors. SendMode Input ; Recommended for new scripts due to its superior speed and reliability. SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. global counter := 0 Esc:: BreakLoop = 1 return ^j:: counter := 1 Loop, { if (BreakLoop = 1) break ; Reload Game Send, R Sleep, 1500 ; Wish CastWish() CastWish() CastWish() CastWish() CastWish() ; Wait 3 seconds for genies to spawn Sleep, 3000 ; Genie #1 TestGenie() TestGenie() TestGenie() TestGenie() TestGenie() } BreakLoop = 0 return CastWish() { Sleep, 200 Send, M Sleep, 200 Send, {Space} } CheckScreen(image) { CoordMode Pixel, Window ImageSearch, FoundX, FoundY, 100, 630, 800, 800, *20 *TransBlack %image%.png if ErrorLevel = 2 FileAppend, %counter% Could not conduct the search.`n, test.txt else if ErrorLevel = 1 ; Didn't find option Sleep, 1 else FileAppend, %counter% %image%`n, test.txt } TestGenie() { Sleep, 1000 Send, 1 Sleep, 200 Send, {Space} Sleep, 200 Send, {Space} Sleep, 200 CheckScreen("adhw") CheckScreen("death") CheckScreen("hard") CheckScreen("breach") CheckScreen("swarm") CheckScreen("ia") CheckScreen("potion") CheckScreen("wand") CheckScreen("toxic") CheckScreen("haste") CheckScreen("healall") CheckScreen("ihe") CheckScreen("ihpm") CheckScreen("badluck") CheckScreen("drain") CheckScreen("magic") CheckScreen("rest") CheckScreen("miscast") CheckScreen("money") CheckScreen("stats") CheckScreen("resto") CheckScreen("ress") CheckScreen("wisdom") CheckScreen("half") CheckScreen("strength") Sleep, 200 Send, 1 counter++ Sleep, 200 return var }


    Then I simply have folder with all 25 screenshots of the answers like those.





    What script does is probably very unoptimzied way to do this but

    • Reload game (binded to R button)
    • Wait 1,5 seconds for game to reload
    • Cast wish (x5) (binded to 'W' button)
    • Wait 3 seconds for wish genies to spawn and trigger dialog
    • Test wish response (x5)
      • Wait 1 second for genie to initiate dialogue
      • Send button '1' to select first dialogue option
      • Send space twice to progress the dialog twice
      • For each of 25 options try to find it on game screen. If a match is found then write down to a file which cast it was and which option was found.


    Again here is the video how it works.



    Also, I checked EE autoroller which appearently is written also in AutoHotKey that there is much more clever way to do this by reading values from game memory rather than simplistic way from the screen. Which without right conditions is very error prone. In my case I specifically positioned my sorc in watchers keep so that dialogue spawns with entire black background so it's wasy to match screens. My current script won't work without special setup (i.e. it assumes sorcerer can cast 5 wish spells, that cast time i 0 from vecna and aop, game is saved with improved alacrity buff on, background of dialogue is black).

    Net net, I would read results from the memory next time but it was still a fun project.

  • ProbablyNotANumberProbablyNotANumber Member Posts: 26
    edited October 2018
    Amazing, thank you! I was heavily rooting for a simple solution and clearly that's it, interacting with UI and reading text coming from it all made simple!


    I actually like that CheckScreen function. Using memory would have been my first idea, reading from screen data sounds complicated. Yet look at how simple it is with ImageSearch. Reading from memory is faster, but not as interesting as text recognition, if it really is what's going on.

    (Edit: Oooh, it's not text recognition, you're using a template image of the dialog line and checking if it exists on screen ? Crafty.)


    You could improve your process next time you need it, by creating custom items and creatures with NearInfinity: In the current case, that would have erased the whole "reload the game" part and increased Wish chain casting beyond 5 at a time, while avoiding crippling consequences for the character. Both techniques combined should make things way more convenient, and reduce that 30 hours duration. I'll post a couple files soon if you want to "get a grasp" with actively using NearInfinity (instead of just reading from it), like you did for me with AutoHotKey.


    Here they are, just skip the stupidly long wall of text till the first link, and read a bit around it to see what it does and what's the point. You should quickly find whether you can make use of this approach to answer BG2 oddity questions with a better quality of life and reduced time loss. Can't beat automation, but can combine well and probably comes in handy in more cases.

    I have an unknown though. Is it fine to share this type of file, can you even make use of them on BG2:EE ? I can only test on vanilla.
    Post edited by ProbablyNotANumber on
  • MyragMyrag Member Posts: 328
    edited October 2018

    (Edit: Oooh, it's not text recognition, you're using a template image of the dialog line and checking if it exists on screen ? Crafty.)

    Correct. I used ImageSearch which also allows for specification of how much of RBG gamma can the searched image be off. I wish I could specify % of matched image instead i.e. if image matches it at 80% of pixels then I accept it. This would disregard transparent effects etc. but it's still cool for me to be able to do this.

    You could improve your process next time you need it, by creating custom items and creatures with NearInfinity: In the current case, that would have erased the whole "reload the game" part and increased Wish chain casting beyond 5 at a time, while avoiding crippling consequences for the character. Both techniques combined should make things way more convenient, and reduce that 30 hours duration. I'll post a couple files soon if you want to "get a grasp" with actively using NearInfinity (instead of just reading from it), like you did for me with AutoHotKey.

    I use NI like every day for powergaming/other purposes. Sometimes I also fix stuff myself there. I often change colors of items if I don't like them for RP reasons, or glow effects etc. As to spawning items/gear I always try to be as close to natural game as possible to avoid possibilities or incorrect results. But it would work, yes. It's harder with dialog as it has different background every time. Also some mods change background under items so it's also hard to match image there from NI only which only contains item image with transparent background. ImageSearch function is not that smart.
Sign In or Register to comment.