Bug - Fixed Tavern Cellar infinite loop

From my gCLI:

[62] Tavern Cellar
Validating adventure sequence...
Requests complete.

Request 1 of 109 (Woods: Tavern Cellar) in progress...

[62] Tavern Cellar
Encounter: The Tavern Cellar

Request 1 of 109 (Woods: Tavern Cellar) in progress...

[62] Tavern Cellar
Encounter: The Tavern Cellar

Request 1 of 109 (Woods: Tavern Cellar) in progress...

[62] Tavern Cellar
Encounter: The Tavern Cellar

Request 1 of 109 (Woods: Tavern Cellar) in progress...

[62] Tavern Cellar
Encounter: The Tavern Cellar

Request 1 of 109 (Woods: Tavern Cellar) in progress...

[62] Tavern Cellar
Encounter: The Tavern Cellar

Request 1 of 109 (Woods: Tavern Cellar) in progress...

[62] Tavern Cellar
Encounter: The Tavern Cellar

Request 1 of 109 (Woods: Tavern Cellar) in progress...

[62] Tavern Cellar
Encounter: The Tavern Cellar

Request 1 of 109 (Woods: Tavern Cellar) in progress...

[62] Tavern Cellar
Encounter: The Tavern Cellar

Request 1 of 109 (Woods: Tavern Cellar) in progress...

[62] Tavern Cellar
Encounter: The Tavern Cellar

Request 1 of 109 (Woods: Tavern Cellar) in progress...

[62] Tavern Cellar
Encounter: The Tavern Cellar

Request 1 of 109 (Woods: Tavern Cellar) in progress...

[62] Tavern Cellar
Encounter: The Tavern Cellar

Request 1 of 109 (Woods: Tavern Cellar) in progress...

[62] Tavern Cellar
Encounter: The Tavern Cellar

Request 1 of 109 (Woods: Tavern Cellar) in progress...

[62] Tavern Cellar
Encounter: The Tavern Cellar

Request 1 of 109 (Woods: Tavern Cellar) in progress...
KoLmafia declares world peace.

[62] Tavern Cellar
Encounter: The Tavern Cellar

Surely this is unintentional?
 

Theraze

Active member
If you told it to autoadventure at the cellar without unlocking it, that isn't a bug... that's the way the cellar works. Same thing happens if you try to buy tavern beer without unlocking it... fails as well.
 
I did unlock it, then told it to autoadventure at the Tavern Cellar. I made sure to talk to Bart Ender before clicking.
 

Theraze

Active member
Well, easiest way to make it work right is to use Quests->Tavern to autosolve it... I'll take a look at how it works later, but it might be like Hidden City in that it just keeps visiting the last square. If so, this wouldn't be a bug, but more a 'feature' of the tavern... if you want to adventure there manually, you need to set your new square between every adventure, or finish it up to the faucet so that your square just keeps killing more rats.
 

Ferdawoon

Member
Tavern Cellar, once pipe is closed

Using r9801.
Trying to farm rat whiskers to get some meat in Fistcore, I tried to use the Tavern Cellar zone. I am lvl13 and have cleared the cellar.

I am not sure if this is a bug, but instead of going to the pipe and squeezing out a new rat and fight it (the choice is set to Fight. If I change it to Show in browser it keep looping and no notification that I ususally see when I set something to Show in Browser) it enter a loop or something and dont really do anything. I hesitated to call this a bug or a feature request as I'm not really sure what is the intended behaviour. What I wonder is, could it be made so that once the ratpipeline is closed, clear the rest of the dark zones and then go to the pipe to keep fighting rats there?

gCLI output (the sessionlog is pretty much the same, just different layout):
Code:
[1397] Tavern Cellar
Encounter: The Tavern Cellar

Calling Universal Recovery for type=HP, amount=0
Calling Universal Recovery for type=MP, amount=0

Visit to Woods: Tavern Cellar in progress...

[1397] Tavern Cellar
Encounter: The Tavern Cellar

Calling Universal Recovery for type=HP, amount=0
Calling Universal Recovery for type=MP, amount=0

Visit to Woods: Tavern Cellar in progress...

[1397] Tavern Cellar
Encounter: The Tavern Cellar

If I change the choice to SHow in Browser, and then back to Fight, if I then clck Auto (the button at the top of the screen in the webbrowser) it seem to get stuck and not pick Fight as it is set to. Clicking Auto worked before I changed it from Fight to Show in Browser and then back to Fight.
 
Last edited:

slyz

Developer
It looks like Mafia simply visits cellar.php when you choose "Tavern Cellar" in the Adventure tab. I guess you would be better off writing a little script or an alias to adventure there, by visiting these URLs:
Code:
cellar.php?action=explore&whichspot=XX
choice.php?pwd&whichchoice=512&option=1
where XX is the number of the spot that contains the faucet.
 

Theraze

Active member
Well, when you click Auto, it's already loaded the page... at that point, "Auto" means Show in Browser. To have the window know what you've changed it to, you'd need to (manually) refresh the page again AFTER your change. That's not a bug... that's just the way static/loaded pages work.

But yes... easiest thing to do is just make a script. Very easy to do and should keep everything working easily.
 

Ferdawoon

Member
Well, when you click Auto, it's already loaded the page... at that point, "Auto" means Show in Browser. To have the window know what you've changed it to, you'd need to (manually) refresh the page again AFTER your change. That's not a bug... that's just the way static/loaded pages work.
I assume this is in response to my mention that I changed the choice setting in Mafia without any effect, but I did try it over several adventures. I clicked the normal choice to fight in the webbrowser, got a new rat out of the pipe and clicking Auto it still would not enter a fight. Or do I have to close the webbrowser window and load it again whenever I change the setting for a choice adventure?

But yes... easiest thing to do is just make a script. Very easy to do and should keep everything working easily.
It looks like Mafia simply visits cellar.php when you choose "Tavern Cellar" in the Adventure tab. I guess you would be better off writing a little script or an alias to adventure there, by visiting these URLs:
Code:
cellar.php?action=explore&whichspot=XX
choice.php?pwd&whichchoice=512&option=1
where XX is the number of the spot that contains the faucet.
Cheers, will do that. Just wondered as Mafia entered a loop when doing one adv in that zone, and that did not feel like intended behaviour. Either a "This cellar is cleared" message or make it start squeezing rats from the pipe is something that I would expect as someone who have no real idea what is going to happen.
 
Well, when you click Auto, it's already loaded the page... at that point, "Auto" means Show in Browser.

That's all well and good, but the OP was not talking about doing this from a browser, but from the adventure tab for x adventures. I've run into the same thing, and while a script *would* work, it does not seem like proper behavior for the adventure tab to just get into an infinite loop doing nothing when told to go to the tavern cellar. Perhaps having a faucet and mansion subzone choice in the adventure tab would work? The point of the adventure tab *is* to easily automate turns.

Anyway, yes, the easiest thing to do for us is to make a script. The best thing, however, isn't always the easiest thing :). (Not that making a script is always that easy, first you have to figure out what you're doing if you're not familiar with the system you're scripting. And that assumes that you have programming ability to begin with, which not everybody does.)

Edit: Once you factor in that the location number in the cellar isn't based on a 2D array, and the fact that visiting the url's in question doesn't actually automatically advance combat, the script can be a slight pain. Here's my hackish solution, which hopefully illustrates why a proper native fix would be nice:
Code:
void squeeze_rat() {
	visit_url("cellar.php?action=explore&whichspot=x");
	adventure(1, $location[Tavern Cellar]);
}

void main() {
	for i from 1 to y {
		squeeze_rat();
	}
}
Where x is that space number, and y is how many turns it's to run. Yes, you have to edit the script each time you want to run it.
Also, if you have any unresolved goals, they'll screw it up.
 
Last edited:

Theraze

Active member
Regarding that, you should be reading the tavern layout preference, finding the faucet, and automatically adventuring there. No reason to hardcode it. Regarding the manual adventure 1 bit, I'd suggest doing another visit_url to make your choice and following that up with a run_combat() instead. Alternatively, you can follow jason's excellent suggestion of (!adventure(number, location)) to make it not abort on goals.

Not sure if it's related to this bug or not, but after trying and having this replicate yesterday, mafia got into an infinite loop when it was supposed to abort on the pirate destination, repeatedly visiting. Aborting manually didn't do anything, but manually launching the relay browser and making my choice stopped it. Anyways, not sure if this getting stuck makes that stuck as well, or if I'm just lucky.

I'll try to look at putting a patch together that makes adventuring in the tavern repeat the last square visited, like the Hidden City. If we don't currently have a preference for last square visited, what's our best choice... aborting immediately with a message that says you can't automate this, adventuring in the top numbered square, picking a black square, or the faucet? My guess is that most adventuring there would expect the faucet, but if you adventure there pre-faucet, what do we do...? Can't remember since I poked at tavern last, but... eh, I'll see what I come up with. Maybe make it go through the black squares if they exist, if all solved then go to the faucet. Since after you find the Baron's mansion, everything else is a rat, right?
 

lostcalpolydude

Developer
Staff member
You can't adventure in a single square repeatedly like you can in the Hidden City. Once the rat is dead (or the crate is broken, or whatever), the square is no longer available. Even losing to a rat might clear the square, I don't know.
 

Winterbay

Active member
I think the only square you can repeatedly adventure in is the faucet which spits out a rat everytime you open it after you shut it down the first time.
 

Theraze

Active member
You can't adventure in a single square repeatedly like you can in the Hidden City. Once the rat is dead (or the crate is broken, or whatever), the square is no longer available. Even losing to a rat might clear the square, I don't know.
Yes... but in the Hidden City, it will repeatedly try to adventure in the last square which is generally the temple, where it can't. Unless you've gone back after you finished and changed to a new square. Always have to do that if I need pygment or a blow gun. :)
 
Regarding that, you should be reading the tavern layout preference, finding the faucet, and automatically adventuring there.

But, see, I have no idea what you're talking about there. Apparently there's some function or array or something that I can access that Mafia itself populates as to what's in which square, hidden in the nonexistent documentation? Be that as it may, I obviously have no idea what it is or how to use it. (And trust me, each time I try to do something with ash scripting, and it's almost always incredibly simple, I take forever trying to find any sort of documentation, and almost always failing.)

Anyway, the black squares then faucet order is what I expected the functionality to be, so that's probably the advisable way for it to work. At least, it gets my vote.
 

Veracity

Developer
Staff member
Apparently there's some function or array or something that I can access that Mafia itself populates as to what's in which square, hidden in the nonexistent documentation?
Move your eyes to the top of the page. Look at the buttons marked "Forum", "What's New", "Daily Builds" and ... "Wiki"? What is that? Could it be documentation?

Nah. You've told us that the documentation is "nonexistent". Can't be.

And trust me, each time I try to do something with ash scripting, and it's almost always incredibly simple, I take forever trying to find any sort of documentation, and almost always failing.
When I start KoLmafia, I see a Help menu on the far right. Among other things, it has the following links:

KoLmafia Thread (the G-D thread on the KoL forums)
KoLmafia Forums (here)
KoLmafia Wiki (surprise! the Wiki)
KoLmafia FAQ (the FAQ on the Wiki)
Unofficial Guide (Singin' Sally's new user guide)

When I look at the G-D thread, which is (possibly) where a lot of new users go first, the first post - the introduction, so to speak - There are quick links to:

Sourceforge Project Link
KoLmafia Forums
KoLmafia Wiki
Report a Bug
Official Builds
Daily Builds

I really am not sure how we could make the documentation any more obvious.

Anyway, the black squares then faucet order is what I expected the functionality to be, so that's probably the advisable way for it to work. At least, it gets my vote.
As has been pointed out elsewhere, KoLmafia development is not a democracy.
 

slyz

Developer
I had forgotten about that preference!

"tavernLayout" is a Mafia preference where the layout of the tavern is stored:
Code:
> get tavernLayout

1511110000200001000011113
where:
Code:
0 = Darkness
1 = Explored / Stairs Up
2 = Dead adventurer
3 = A Rat Faucet
4 = A Tiny Mansion
5 = Various Barrels
If you want to find visit the square with the Faucet, you simply need to do:


PHP:
int faucet = 1 + get_property( "tavernLayout" ).index_of( "3" );
if ( faucet < 1 ) abort( "Mafia doesn't know where the Faucet is." );

void squeeze_rat() {
	visit_url( "cellar.php?action=explore&whichspot=faucet" );
	visit_url( "choice.php?whichchoice=512&option=1" );
	run_combat();
}
 

fronobulax

Developer
Staff member
nonexistent documentation

Cheap shot and not the kind of comment that encourages people to actually give a rat's tootie (*snicker*) about your questions.

If you had gone here and then said that you could not figure out how to use the information in the preferences lastTavernSquare and tavernLayout and mentioned that it is confusing because people use both property and preference to describe the same KoLmafia feature, you might have gotten a more helpful answer.







That said, your comment was annoying (there's that word again) but you are correct in that the documentation is less than helpful. Feel free to confirm what I am about to say and then edit the wiki. You convert a row and column to a square by
Code:
square = ( row - 1 ) * 5 + ( col - 1 )
. The character at position square in tavernLayout tells you what is there.

0 -> Darkness
1 -> Explored (or Stairs Up)
3 -> Rat Faucet
4 -> A Tiny Mansion

I presume the leftmost digit in tavernLayout is indexed by zero, but I often make "off by one" errors especially when I don't look things up for a particular language. I'm guessing that row and col range from 1 to 5, each, inclusive, but I don't know how to label the tavern grid in a browser. I also don't know whether the URL uses "square" or (row, col) but all these can be figured out and I will let someone else do that.
 
Top