Feature - Implemented CLI request to drink 1 booze > 2 booze drunk

In the middle of drinking a bunch of booze from the CLI in r13087 (raising my Wine Tasting mini score) I entered "drink 1 oh, the hu" to drink a single Oh, the Humanitini.
Mafia purchased and drank two of them.

Code:
> drink 1 oh, the hu

Searching for "Oh, the Humanitini"...
Search complete.
Purchasing Oh, the Humanitini (2 @ 2,799)...
Purchases complete.
Drinking 2 Oh, the Humanitini...
You gain 11 Adventures
You gain 20 Muscleboundness
You gain 21 Magicalness
You gain 23 Chutzpah
You gain 31 hit points
You gain 2 Drunkenness
You lose some of an effect: Ode to Booze
You gain 10 Adventures
You gain 21 Strengthliness
You gain 24 Mysteriousness
You gain 25 Sarcasm
You gain 39 hit points
You gain 2 Drunkenness
You lose some of an effect: Ode to Booze
Finished drinking 2 Oh, the Humanitini.
The rest of the day's drinking passed without incident.
I've checked my aliases and none of them are substrings of any of that command (not sure how that would have caused it anyway, but wanted to make sure).
Is there any other relevant info I can give?

Edit - oh wait, is this because it interpreted it as a comma delimited request to drink 1 "oh" and 1 "the hu" ?
 
Last edited:

Veracity

Developer
You got it. Unfortunate result, but it did exactly what you told it to do. Which is to say, this is Not A Bug.
 

Mr_Crac

New member
KoLmafia buying two things instead of one

What has just happened here?

Code:
[color=green]> buy 1 Oh, the Humanitini[/color]

Searching for "Oh, the Humanitini"...
Search complete.
Purchasing Oh, the Humanitini (1 @ 2,600)...
Purchases complete.
Using cached search results for Oh, the Humanitini...
Purchasing Oh, the Humanitini (1 @ 2,795)...
Purchases complete.

I now do have two of these "Oh, the Humanitini" drinks in my inventory, even though I explicitly gave the command to buy just one.
Anybody else have experienced something like this? KoLmafia version used was r13124.

Could it maybe have to do with the previous commands I used on the CLI, which were these:
buy 1 Humanitini
drink 1 Humanitini
buy 1 More Humanitini than Humanitini
drink 1 More Humanitini than Humanitini

The purpose of all this is me getting the Spirited Drinker trophy.

EDIT:
Okay, if I am an idiot and accidentally gave the same command twice (i.e. the second command being "buy 1 Oh, the Humanitini" instead of "drink 1 Oh, the Humanitini"), would then the output look exactly as above?
Then it is probably rather a user error.
 
Last edited:

Veracity

Developer
Leave out the comma and let fuzzy matching Do The Right Thing.

> buy 1 Oh the Humanitini

Searching for "Oh, the Humanitini"...
Search complete.
Purchasing Oh, the Humanitini (1 @ 2,895)...
Purchases complete.
 

Veracity

Developer
Given that the "buy" command - and many other commands that take a "comma separated list of things" - has a very simple-minded way of extracting the "list of things" - it splits the parameters at commas, the "correct" input cannot have a comma as a character in the name of the "thing" that you are buying. In fact, if you look at the help string for the "buy" command, that should be obvious:

buy <item> [@ <limit>] [, <another>]... - buy from NPC store or the Mall.

As you can see from the documentation, what you typed - "buy 1 Oh, the Humanitini" - says to buy 1 "Oh" and 1 "the Humanitini". Which is to say, KoLmafia did exactly what you told it to do.

Now, if you want a way to "escape" a comma (or even a "@", to prevent it from delimiting the "limit"), you might want to use "\", for example, to escape the following character. In that case you could use "Oh\, the Humanitini". You may think that there should be such a syntax (even though you didn't try using it yourself :)), but considering that such syntax does not exist, never has existed, and certainly is not documented to exist, the absence of such syntax is in no way a Bug. It could be a reasonable Feature Request - although one that I will certainly not take up myself.

Presumably it wouldn't be THAT hard to write a function which would be the equivalent of

String[] itemNames = parameters.split( "\\s*,\\s*" );

(which is the simple-minded method this command - and many others - use to get comma-separated "things") but would allow splitting while obeying escapes. It would be a fair amount of work to make all existing commands that use the old function use the new one instead.
 

lostcalpolydude

Developer
If I were to attempt to work on some feature request related to this, it would probably be recognizing if 2 of the items in a comma-separated list are the same, and if they have commas in their name, and doing some special handling in that case. I don't actually do much buying or using from the CLI outside of things I doalmost every day (the Item Manager is so much safer for avoiding user error), so I'm not likely to look at that any time soon.
 
Regarding Veracity's suggestion about escape characters: I don't think that would be helpful. The problem here is people not understanding how the command is interpreted, and gettting a result they don't expect. If you know that you'd need to an escape char, then you wouldn't need to use them anyway - you'd just omit the comma. :)

lostcalpolydude said:
If I were to attempt to work on some feature request related to this, it would probably be recognizing if 2 of the items in a comma-separated list are the same, and if they have commas in their name, and doing some special handling in that case. I don't actually do much buying or using from the CLI outside of things I doalmost every day (the Item Manager is so much safer for avoiding user error), so I'm not likely to look at that any time soon.

I'm not sure how well that would work. A lot of the time one of the terms would be non-unique (for example the various Crimbo Carols). I was thinking about making a FReq to parse possible substrings within comma delimited lists, match them against relevant items, and abort with an ambiguity message if any are found (as the strings with commas in them are by nature ambiguous, as they can also refer to multiples of the same item).

e.g. for "item1, item2, item3, item4", in addition to matching each item individually, you would also match for items:
"item1, item2, item3, item4"
"item1, item2, item3"
"item2, item3, item4"
"item1, item2"
"item2, item3"
"item3, item4"

So the number of terms to be matched in a comma-delimited list of n items would change from n to (n*(n+1))/2
I guess that could start to impact performance in sufficiently long comma-delimited lists, so not sure if it's worth it.

I just did this out of interest. There are actually more items with commas in them than I thought!
Code:
> ashq foreach i in $items[] {if (index_of(to_string(i),",")>-1)print(i);}

Happy Birthday, Claude! cake
"I Love Me, Vol. I"
Staff of Ed, almost
Maxing, Relaxing
A Crimbo Carol, Ch. 1
A Crimbo Carol, Ch. 2
A Crimbo Carol, Ch. 3
A Crimbo Carol, Ch. 4
A Crimbo Carol, Ch. 5
A Crimbo Carol, Ch. 6
Victor, the Insult Comic Hellhound Puppet
myrrh-soaked, chocolate-covered bacon bath ball
Notes from the Elfpocalypse, Chapter I
Notes from the Elfpocalypse, Chapter II
Notes from the Elfpocalypse, Chapter III
Notes from the Elfpocalypse, Chapter IV
Notes from the Elfpocalypse, Chapter V
Notes from the Elfpocalypse, Chapter VI
holy bomb, batman
A Crimbo Carol, Ch. 1 (used)
A Crimbo Carol, Ch. 2 (used)
A Crimbo Carol, Ch. 3 (used)
A Crimbo Carol, Ch. 4 (used)
A Crimbo Carol, Ch. 5 (used)
A Crimbo Carol, Ch. 6 (used)
Aye Aye, Captain
Aye Aye, Tooth Tooth
Oh, the Humanitini
Earth, Wind and Firewater
tiny plastic Hank North, Photojournalist
 

Veracity

Developer
The problem here is people not understanding how the command is interpreted, and gettting a result they don't expect.
Correct. Unfortunately, they are getting exactly the result the SHOULD expect, were they to do "help buy", for example; what part of "comma delimited list" is unclear? :)

The proposals to reparse the list in various ways just to see if it has items with commas in them smell like "kludge" to me, I'mm sorry to say.
 

guyy

New member
The simple solution would be to try to match the entire command, and only divide it up by commas if that doesn't work.

Most cases of this, other than typos, would probably go away with that change. If you're submitting a list, you'd probably notice that the commas are ambiguous. But if you're just asking for one item that happens to have a comma in its name, it's counterintuitive to realize that its interpretation will be "the user wants me to buy a holy bomb and a batman, which are the same thing, so I'll buy two."
 

lostcalpolydude

Developer
I attached a patch that I think will first check the parameter to see if it's a single item that can be matched, and then move on to a comma-separated list check when it isn't. There's enough going on in that code that I don't want to commit it without either more time to look at it or someone else also looking at it and making sure I didn't miss something. It will also give me some time to actually try out that code change to see any unfortunate results firsthand, if there is something wrong with it.
 

Attachments

  • comma.patch
    933 bytes · Views: 22

Fluxxdog

New member
What happens with combinations of comma-containing names, such as "Aye Aye, Tooth Tooth, Oh, the Humanitini"?
 
Top