New Content - Implemented Manual of Numberology

Veracity

Developer
Staff member
Unfortunately, I'd turned off my debug log, for some reason, when I cast the skill in the relay browser. However, my session log tells me that it redirects to a choice.

Code:
cast 1 Calculate the Universe
Took choice 1103/1: unknown
choice.php?forceoption=0&whichchoice=1103&pwd&option=1&num=2549
You acquire an item: magicalness-in-a-can
That is presumably why my code to set _universeCalculated to true when you cast the skill didn't actually get fired. I'd guess that it should be moved from UseSkillRequest to ChoiceManager.
 

Crowther

Active member
I just rediscovered this problem. Since I was trying to discover the URL's needed to cast this skill, I was running debug when it happened. This problem being _universeCalculated not being set to true when casting the skill.
 

Attachments

  • DEBUG_20151020.txt
    434.5 KB · Views: 100

Veracity

Developer
Staff member
A lot of spading has been done for this. It appears that when you Calculate the Universe and give it a number, it uses that seed in a formula with other factors - which has been spaded - and uses the last 2 digits of the result to index a table from 00 to 99. The spading spreadsheet proposes that the formula is:

(abs(floor(seed)) + ascensions + moonsign ID aka index) * (spleen full + level) + turns left

The spreadsheet also compiles reported data on what various results give you. There are conflicts, so spading is not complete.

Not every "result" is possible at any particular time. Ascensions, moonsign are constants, level changes slowly, spleen and turns left change quickly. There's a nice script available which tells you which "results" are possible given the current state of the variables. Adventure once and run it again, and you end up with different possibilities.

I've started this to let us think about what support we could/should build in. Much of the following should, perhaps, be in a user script. Lets talk about it.

Casting the skill sends you to a choice that has an extra parameter for passing in the seed. That means that you can't cast it from the Use Skill frame. It might be nice to have a cli command or ASH function - "numberology N", say - which casts the skill and passes in the seed. It would be easy to write an ASH function for that.

It would be easy to write an ASH function to compute a result given a seed and your current character state.
It would be not horrendous to write an ASH function which returns an map of all currently possible results and the seed you use to get them. That's essentially what the reverse-numberology ASH script does, except it prints the result.
Eventually, once spading is complete, given a list of all results that are not "try again", it would be easy to generate a list of all possible outcomes, given your current state.

And given that, we could have a dynamic daily deed, say, with a dropdown showing what outcomes are currently available. The dropdown would change each time you adventure, change your spleen, or change level.

I don't know. How much do we build in, and how much do we leave to scripts?

Thoughts?
 

Darzil

Developer
Personally I like the idea of everything up to and including a dynamic daily deed, given that this is a skill that everyone who gets it will want to use once per day and not forget.
 

Crowther

Active member
I honestly don't know what's best in ASH vs Java. I was just planning to write a between battle script to detect when I could get a certain number and then use it. That's how I noticed the preference wasn't getting set. I figured I'd write my script, post it, then Bale would post a better one and I'd use his.

It would be nice if there was a way to use the skill without visit_url(), which I avoid if possible. I don't think run_choice() will work, because of the additional "num=" parameter. Then again, visit_url() isn't that bad.

The other issue is iterating over 100 odd numbers in ASH. I'd be doing that every adventure until the right number is found. That can take a while if, say, you just finished CS and your level is 10 and your spleen is 15 so you only get 4 choices. This is why I really want to automate it.
 

Veracity

Developer
Staff member
I just rediscovered this problem. Since I was trying to discover the URL's needed to cast this skill, I was running debug when it happened. This problem being _universeCalculated not being set to true when casting the skill.
I moved this over to the Manual of Numberology New Content thread I started since it is an issue in our support for that item. Thanks for the DEBUG log!
 

Bale

Minion
It would be easy to write an ASH function to compute a result given a seed and your current character state.
It would be not horrendous to write an ASH function which returns an map of all currently possible results and the seed you use to get them. That's essentially what the reverse-numberology ASH script does, except it prints the result.
Eventually, once spading is complete, given a list of all results that are not "try again", it would be easy to generate a list of all possible outcomes, given your current state.

And given that, we could have a dynamic daily deed, say, with a dropdown showing what outcomes are currently available. The dropdown would change each time you adventure, change your spleen, or change level.

I don't know. How much do we build in, and how much do we leave to scripts?

Thoughts?

I was thinking of something like our mad hatter support. The hatter command will tell you all the available buffs with current hats if you don't give it a parameter or go to get the buff if you give it a parameter. For the "numberology" command it can return a list of all currently possible results, plus the number of turns until it can provide +3 adventures, if that is not currently available.

I would also appreciate an additional ash function that returns a map of available results as integers so that a script can choose from them. Just to make scripting easy for the skill. And perhaps an ash command to use the skill as well.
 
Would you want a planning feature as well, so you could compare possibilities from 0 to N turns out? Or for spleen tweaking too, for that matter. Or, the inverse, how many turns / spleen until a given result is available?
 

Crowther

Active member
Would you want a planning feature as well, so you could compare possibilities from 0 to N turns out? Or for spleen tweaking too, for that matter. Or, the inverse, how many turns / spleen until a given result is available?
Oooh, now I want EatDrink to handle it for me!
 

Theraze

Active member
Oooh, now I want EatDrink to handle it for me!

Eh, if you know you want to use 11 spleen, you can already tell ED to only use 11 spleen and nothing else and find your best option(s) for that. In terms of ED handling deciding what your best MoN options are and calculating them programagically... unlikely.
 

heeheehee

Developer
Staff member
For what it's worth, this is an exercise in modular arithmetic. The value you get is of the form ax + b, where a and b are integers depending on your player state, and x is the value you chose. We want to look at the number % 100, so the important thing to do is look at gcd(a, 100), as that'll give you the spacing between values you can get, with an offset of b (x=0 -> b, x=1 -> a + b, x=2 -> 2*a + b, etc).

obviously a = spleenfull + level; b is slightly more complicated: (ascensions + moonsign index) * (spleenfull + level) + turns left.

gcd can be computed very efficiently using Euclid's gcd algorithm. If you really wanted, you could attempt to calculate a pseudoinverse (when it exists), but yeah. Not super complicated either way you want to do the problem.

edit with demonstration: http://pastebin.com/LMB23L22
 
Last edited:

Veracity

Developer
Staff member
A good first step would be to simply have "numberology X" cast the skill and run the choice; I am tired of running reverse-numberology, seeing the number I want, and then having to go to the Relay Browser to cast it from the skills menu.

Can you walk away from the choice, or do you have to type in some number once you cast the skill? If the latter, the "numberology" command should validate the argument to not be a "try again" number - which means we'd need to not only be able to calculate what result a seed gives you, but have the list of invalid results.
 

lostcalpolydude

Developer
Staff member
You can walk away from the choice (you couldn't initially, but people kept getting stuck in it), but the skill is used up anyway. (You can go back to choice.php to finish using it still, as long as you don't do anything to change that.) CDMoyer wasn't interested in changing that behavior, so the number needs to be validated before casting the skill.
 

Veracity

Developer
Staff member
Revision 16396 starts this. In my current character state:

> reverse-numberology.ash

Lifetimes: 387
Moon Sign (Vole): 3
Melancholy plus advancement: 36 (15 + 21)
Adventures remaining: 30

[02] Enter 12 to get a result of 14502
[06] Enter 1 to get a result of 14106
[10] Enter 15 to get a result of 14610
[14] Enter 4 to get a result of 14214
[18] Enter 18 to get a result of 14718
[22] Enter 7 to get a result of 14322
[26] Enter 21 to get a result of 14826
[30] Enter 10 to get a result of 14430
[34] Enter 24 to get a result of 14934
[38] Enter 13 to get a result of 14538
[42] Enter 2 to get a result of 14142
[46] Enter 16 to get a result of 14646
[50] Enter 5 to get a result of 14250
[54] Enter 19 to get a result of 14754
[58] Enter 8 to get a result of 14358
[62] Enter 22 to get a result of 14862
[66] Enter 11 to get a result of 14466
[70] Enter 0 to get a result of 14070
[74] Enter 14 to get a result of 14574
[78] Enter 3 to get a result of 14178
[82] Enter 17 to get a result of 14682
[86] Enter 6 to get a result of 14286
[90] Enter 20 to get a result of 14790
[94] Enter 9 to get a result of 14394
[98] Enter 23 to get a result of 14898

> numberology

[2] Enter 12 to get 100 Sleepy
[6] Enter 1 to get 100 Wings
[10] Enter 15 to get 100 Steroid Boost
[14] Enter 4 to get moxie weed
[18] Enter 18 to get bottle of booze
[22] Enter 7 to get pygmy phone number
[26] Enter 21 to get Try Again
[30] Enter 10 to get fight ghuol
[34] Enter 24 to get + Mainstat
[38] Enter 13 to get + Mysticality
[42] Enter 2 to get Try Again
[46] Enter 16 to get Try Again
[50] Enter 5 to get - Mysticality
[54] Enter 19 to get Try Again
[58] Enter 8 to get 10 Teleportitis
[62] Enter 22 to get Try Again
[66] Enter 11 to get magicalness-in-a-can
[70] Enter 0 to get + Mainstat
[74] Enter 14 to get Try Again
[78] Enter 3 to get + Mysticality
[82] Enter 17 to get Try Again
[86] Enter 6 to get Try Again
[90] Enter 20 to get - Muscle
[94] Enter 9 to get Try Again
[98] Enter 23 to get + Mysticality

> numberology? 1028

1028 -> 51078 (78) = + Mysticality

> numberology 8

Calculate with 8 here
- The "numberology" command with no arguments could/should filter out the Try Again results.
- The "prize" strings are very basic, from the spading spreadsheet. For things which give N items, they should say N. For things which give + or - a stat, we should give the stat range, once it is spaded.
- The command to actually Calculate the Universe doesn't do it yet.
- There is currently no ASH support.

The "Try Again" prize string is NumberologyManager.TRY_AGAIN, so it will be trivial to filter on that prize.

We probably should have a NumberologyRequest to handle the skill usage + choice redirect.

This is all I have time for today. I won't be hurt if somebody else has more time and wants to refine things. :)
 

Bale

Minion
Can we have an ash function: int [int] numberology()

which returns a list of all currently available numberology options:
2 => 100 Sleepy
6 => 100 Wings
10 => 100 Steroid Boost
14 => moxie weed
18 => bottle of booze
22 => pygmy phone number
26 => Try Again
30 => fight ghuol
34 => + Mainstat
38 => + Mysticality
42 => Try Again
46 => Try Again
50 => - Mysticality
54 => Try Again
58 => 10 Teleportitis
62 => Try Again
66 => magicalness-in-a-can
70 => + Mainstat
74 => Try Again
78 => + Mysticality
82 => Try Again
86 => Try Again
90 => - Muscle
94 => Try Again
98 => + Mysticality

And a function: boolean numberology(int result) which returns false if the requested numberology is impossible.

So that if I want +Mainstat I can do this:
if(numberology() contains 80) numberology(80);

It would be the scripter's responsibility to know what numberology integer result corresponded to the result he desires because if we tried to do that as a more readable string, misspelling and bad word choices would make the results a nightmare.
 

Bale

Minion
Thinking about it, even better would be: int [int] numberology(int turns)
Which returns a list of all results that are valid in the designated number of turns.

And boolean get_numberology(int turns)
That way I could run code like this...

Code:
boolean get_numberology_adv() {
   if(numberology(0) contains 34)
      return get_numberology(34);
   for t from 1 to 9
      if(numberology(t) contains 34) {
         print("You can get 3 adventures from Nnumberology in "+ t +" turns.");
         return false;
      }
   return false;
}
 

Veracity

Developer
Staff member
I've been thinking about this more. There are conceptually three low-level primitives, not all of which necessarily need to be exposed to ASH or the CLI:

boolean calculate_the_universe( int seed )

This is the raw interface to the skill/choice. It can return false if you've already used the skill today or if using the seed would leave you in the choice, since it's a "try again". In light of what lost said, if you've cast the skill once today, you cannot cast it again, even if you walked away from the choice. So this primitive should, at least, not cast the skill if we've seen the choice. Should it try to run the choice anyway, just in case you walked away but did not adventure? If we really want to let the user submit multiple seeds until the get a result - any result - like the native skill interface/choice does, yes - but I'd prefer that KoLmafia only let you do sensible things and only submit this if it will finish getting a result.

int numberology( int seed, int delta)

This returns the numeric "result" (0-99) for the given seed given your char state + delta turns

int reverse_numberology( int result, int delta )

This returns the numeric "seed" (0-99) which will lead to the specified result given your char state + delta turns, or -1 if it is not possible.

Both of the last two would be overloaded with single parameter versions which assume delta = 0.

Now, as I said, these are primitives: the only reason the user would want the raw "seed" is if they were manually using Calculate the Universe in the Relay Browser, say - or if we actually provided the CLI command or ASH script to do that low level call.

I think the CLI command should work like this:

numberology

As now, but instead of "Enter X to get PRIZE" phrase it as "Calculate the Universe with X to get PRIZE" - which is the same thing, but hopefully makes it clearer that X is for use in the Calculate the Universe skill in the Relay Browser.

numberology? X

Will say either:

"numberology X" (PRIZE) is currently available

or

"numberology X" (PRIZE) will be available in Y turns

And then:

numberology X

Will say either:

"X" is "Try Again". Choose a different prize.

or

"numberology X" (PRIZE) is not currently available but will be available in Y turns

or it will calculate the seed and submit the request to calculate_the_universe() and will report on the result.

In other words, from the CLI, the "seed" and the low-level call to Calculate the Universe is not exposed; all the CLI user cares about is getting a specific result.
 

Veracity

Developer
Staff member
Even more thought: the reverse_numberology primitive is as Bale suggested:

int [int] reverse_numberology( int delta )

to get the whole map of possibilities.

Continuing pondering...
 

Veracity

Developer
Staff member
Yes.

> numberology

[0] Calculate the Universe with 14 to get: 0 Meat
[4] Calculate the Universe with 3 to get: 100 Embarrassed
[8] Calculate the Universe with 17 to get: 100 Hardly Poisoned at All
[12] Calculate the Universe with 6 to get: figth Gnollish Gearhead
[16] Calculate the Universe with 20 to get: magicalness-in-a-can
[20] Calculate the Universe with 9 to get: - Mainstate
[36] Calculate the Universe with 15 to get: 2 Adventures
[40] Calculate the Universe with 4 to get: 40 Meat
[44] Calculate the Universe with 18 to get: bottle of booze
[48] Calculate the Universe with 7 to get: fight your butt
[68] Calculate the Universe with 2 to get: + Mysticality
[88] Calculate the Universe with 22 to get: magicalness-in-a-can

> numberology 69

"numberology 69" (3 Adventures) is not currently available but will be in 3 turns.
Adventure once.

> numberology

[3] Calculate the Universe with 3 to get: 100 Confused
[7] Calculate the Universe with 17 to get: 100 Beaten Up
[11] Calculate the Universe with 6 to get: Drunkenness (-1,+3)
[15] Calculate the Universe with 20 to get: 15 Meat
[19] Calculate the Universe with 9 to get: + Moxie
[23] Calculate the Universe with 23 to get: + Muscle
[27] Calculate the Universe with 12 to get: + Moxie
[35] Calculate the Universe with 15 to get: + Muscle
[43] Calculate the Universe with 18 to get: + Muscle
[47] Calculate the Universe with 7 to get: + Moxie
[51] Calculate the Universe with 21 to get: fight War Frat 151st Infantryman
[63] Calculate the Universe with 13 to get: + Muscle
[71] Calculate the Universe with 16 to get: - Mysticality
[75] Calculate the Universe with 5 to get: bottle of booze
[83] Calculate the Universe with 8 to get: + Muscle
[87] Calculate the Universe with 22 to get: + Moxie
[99] Calculate the Universe with 14 to get: bottle of booze

> numberology 69

"numberology 69" (3 Adventures) is not currently available but will be in 2 turns.
Adventure once.

> numberology

[2] Calculate the Universe with 3 to get: 100 Sleepy
[6] Calculate the Universe with 17 to get: 100 Wings
[10] Calculate the Universe with 6 to get: 100 Steroid Boost
[14] Calculate the Universe with 20 to get: moxie weed
[18] Calculate the Universe with 9 to get: bottle of booze
[22] Calculate the Universe with 23 to get: pygmy phone number
[30] Calculate the Universe with 1 to get: fight ghuol
[34] Calculate the Universe with 15 to get: + Mainstat
[38] Calculate the Universe with 4 to get: + Mysticality
[50] Calculate the Universe with 21 to get: - Mysticality
[58] Calculate the Universe with 24 to get: 10 Teleportitis
[66] Calculate the Universe with 2 to get: magicalness-in-a-can
[70] Calculate the Universe with 16 to get: + Mainstat
[78] Calculate the Universe with 19 to get: + Mysticality
[90] Calculate the Universe with 11 to get: - Muscle
[98] Calculate the Universe with 14 to get: + Mysticality

> numberology 69

"numberology 69" (3 Adventures) is not currently available but will be in 1 turn.
Adventure once.

> numberology

[1] Calculate the Universe with 3 to get: seal-clubbing club
[5] Calculate the Universe with 17 to get: 100 Far Out
[9] Calculate the Universe with 6 to get: 100 Knob Goblin Perfume
[13] Calculate the Universe with 20 to get: Nothing. Maybe.
[17] Calculate the Universe with 9 to get: 1 Adventure
[21] Calculate the Universe with 23 to get: 1 Fite
[33] Calculate the Universe with 15 to get: magicalness-in-a-can
[37] Calculate the Universe with 4 to get: 3 Fites
[45] Calculate the Universe with 7 to get: magicalness-in-a-can
[49] Calculate the Universe with 21 to get: + Mysticality
[57] Calculate the Universe with 24 to get: + Moxie
[69] Calculate the Universe with 16 to get: 3 Adventures
[77] Calculate the Universe with 19 to get: spooky stick
[89] Calculate the Universe with 11 to get: + Mainstat
[93] Calculate the Universe with 0 to get: 93 Meat
[97] Calculate the Universe with 14 to get: magicalness-in-a-can

> numberology? 69

"numberology 69" (3 Adventures) is currently available.

> numberology 69

Calculate the Universe with 16 here
Revision 16398 does that. More later.
 
Top