Best sushi for profit

Winterbay

Active member
Sushi 2.3

This script tries to look over your sushi-eating options and make the bets choices based on a given meat-per-adventure. It can be used directly or imported into another script as described further down. In order to get the script to your Mafia installation type the following command into the CLI and press enter:
Code:
svn checkout https://svn.code.sf.net/p/winterbay-mafia/sushi/code/

In order to make sure the script is always up to date you can turn on the "Update installed SVN projects on login" in the Preferences (found at the bottom under General for now).

Requires zlib.

Features:
  • Given a value_of_adventure, goes through all potential sushis (including simple fish meat) with and without the two sake versions and sorts by potential profit.
  • Can use this information to eat that same sushi. It then eats as many of it as possible.
  • Given a name of a sushi, or part of a name, returns the total cost for it.
  • Sets two boolean zlib-variables at first run, sushi_debug for some debug-printing and sushi_askme which if set to true will pop a question if you try to call it to eat without having a sushi rolling mat.
  • Also sets an integer zlib-variable, sushi_fish_juice_multiplier, which controls the relative value of fish juice boxes, defaults to 8

How to use:
Code:
sushi -1
Prints out a pretty list of all sushis, their total cost, turns of fishy given and average adventures gained from it.

Code:
sushi value_of_adventure
Fills you up with the best sushi (up to your max fullness). Yay for userfriendliness!
If you set sushi_onhand to true this will only eat things you can make from your inventory.

Code:
ash import <sushi.ash>; cost_of_sushi(string name)
Returns the cost of all sushis that contains name. Can also be called with an added boolean if you just want the one name (must be exact then).
A useful alias for this is:
Code:
sushicost => ash import <sushi.ash>; cost_of_sushi($string[%%]);

Code:
ash import <sushi.ash>; test_sushi(int value_of_adventure)
Returns a record containing the sushi that gives the highest profit together with turns of fishy gained and which type of booze (if any) to drink it with.

Code:
ash import <sushi.ash>; eat_sushi(int amount, int value_of_adventure, string booze)
Eats amount of sushi and drinks booze first. Booze can be:
  • infused sake
  • sake
  • no booze (or basically any other string)

This function is overloaded for easier use:
Code:
eat_sushi(int amount,int value_of_adventure) //Eats the specified amount of the best kind of sushi
eat_sushi(int value_of_adventure) //Fills you up with the best kind of sushi

I think that's it. Comments and bug reports are more than welcome :)

Version history:
v1.0 - First release
v1.2 - Added two overloaded functions for eat_sushi so that you do not need to specify all information unless so wanted (Thanks bale!). Also added a prettier output of the table of results (Shamelessly stolen from one of the TP-scripts and adapted).
v1.3 - Fixed a bug that would stop you from eating sushi if you were at maximum inebriety
v1.4 - Fixed a very small bug in the version check, it pointed to the wrong thread (and also borrowed some code form zlib).
v1.5 - Fixed (for real) the bug with eating at full inebriety. Also circumvented potential prolems with CLI-execute returning false while it should've returned true (I hope).
v1.6 - Include zlib, change check-version to zlib's version, add two zlib settings (sushi_debug for debug printing and sushi_askme for asking to stop if you have no mat). Only include anything above basic meat if you have a mat.
v1.7 - Include basic support for fish juice boxes, fix printing of stuff if you have no mat,fix sorting of sushi to use the correct sorted sushi and not the latest one, also refactor some code to be more pleasing and add a new zlib setting, sushi_fish_juice_multiplier, indicating how to value a fish juice box, default 8
v1.8: - Make sure that eat_sushi fills you up and make main take an integer. If this integer is -1 print out costs of all sushis, otherwise fill you up on the best possible sushi.
v1.9: - Incorporate Garbled's (Thanks!) code for only eating things you have on hand. This is controlled by a new zlib-setting, sushi_onhand which if set to true will make you only eat things you can make from inventory
v2.0: - Fix for upcoming changes to script parsing, i.e. sloppy code...
v2.1: - to_item($item) is a completely useless conversion. Don't use that...
v2.2: - Add Bento Boxes and Sushi Doilies to the things to take into consideration (uses bento boxes if available, but won't buy for itself). Also remove version checking as the script is now handled via SVN.
v2.3: - Set autoBuyPriceLimit to either the max price of an ingredient or autoBuyPriceLimit so that we don't crash if an ingredient is expensive
Don't abort if the script decides that "no booze" is the correct option
 
Last edited:

Bale

Minion
Finally found an excuse to try this out today. The script could be easier to use, but not more effective.
 

Winterbay

Active member
Any ideas on how to improve ease of use would be very welcome. I'm especially unsatisfied with the output of the cost of all sushis and so on. I feel that would be much better as a table but I suck at html and the scripts I've looked at that uses that sort of output have not helped unfortunately :(
 

Bale

Minion
Tables are pretty easy.

Just start with <table>
Then start and end each row with <tr> and </tr>
In each row you need to bracket each data cell with <td> and </td>
Finally end with </table>

For example:
<table>
<tr><td>Row one, cell one</td> <td> Row one, cell two </td> </tr>
<tr> <td>Row two, cell one</td> </tr>
</table>
 

Winterbay

Active member
Hmm... I may have a rough outline now. How do you get one cell to take the place of four cells? I'd like to have the type of sushi in the table but at the moment it puts that name in cell 1 and leaves the rest of that row empty (no cell, no nothing) until the next row.

Edit: Never mind, I found it.
 
Last edited:

Bale

Minion
I assume that what you found is <td colspan='4'>

Also, if you want to have a blank cell, use <td> </td>. Without the non-breaking space it will skip the cell instead of leaving it empty.

I just remembered to tell you that there's one important addendum to printing a table in KoLmafia. You need to do it with a single print_html() or else it won't work. I suggest defining output as a buffer or a string and build it up as you iterate. Then use a single print_html(output).
 
Last edited:

Winterbay

Active member
Yeah. I managed to find and mangle part of one of the TP-scripts which used a lot of appends and then finally did a print html.
 

Bale

Minion
To make this a little simpler to use I added the following 2 functions to my copy.

PHP:
boolean eat_sushi(int amount,int value_of_adventure) 
{
	sorted_sushis test = test_sushi(value_of_adventure);
	return eat_sushi(amount, value_of_adventure, test.booze);
}

boolean eat_sushi(int value_of_adventure) 
{
	return eat_sushi((fullness_limit() - my_fullness())/3, value_of_adventure);
}

That way I don't have to worry about things the script can calculate for me.
 

Winterbay

Active member
That is a good idea. I think I have similar calls but in the script that calls it instead :)
Merging those two functions into the script is probably a better idea.
 

Winterbay

Active member
Version 1.3 has been uploaded and fixes a bug that would stop you from eating sushi if your inebriety was above what a sake needs.
 

Bale

Minion
Since I'm in aftercore until the current world event ends I'm making good use of this script farming the sea. Such awesome meat to be made down there.

Thanks again for this script. It makes my sushi eating so much easier.

Code:
alias eatsushi => ashq import "sushi";  eat_sushi((fullness_limit() - my_fullness() -2)/ 3, 3500)
 

Winterbay

Active member
Version 1.4 is live with a better version checking (it now correctly points to this thread and not to BCCascend... and is clickable!).
 

Winterbay

Active member
Version 1.5 has been posted and should fix any potential problems with Mafia's CLI-execute not reporting the actual success or not of the command it is given.
 

Winterbay

Active member
Version 1.6 has been uploaded and the script now requires zlib since it uses two zlib-variables.

* Setting "sushi_debug" to true (default is false) will create a "sushi.txt" with a dump of the scripts information in your datafolder.
* Setting "sushi_askme" to true (default is false) will prompt you as soon as you call a function that would eat anything if you do not have a mat.

The script now won't suggest any sushi above basic fish meat if you do not have a mat. I will probably add fish juice boxes as well in the near future but I don't have time at the moment.
 

Winterbay

Active member
Version 1.7 uploaded with the following change log:

* Include basic support for fish juice boxes
* Fix printing of stuff if you have no mat
* Fix sorting of sushi to use the correct sorted sushi and not the latest sorted one
* Refactor some code to be more pleasing
* Add a new zlib setting, sushi_fish_juice_multiplier, indicating how to value a fish juice box, default 8

Currently (tested on an account without sushi mat) the breakpoint where the juice boxes appears to be better than basic fish-meat is a factor between 100 and 110. If anyone has any suggestions on how to weight the fish juice box better I'm all for it (sushis are weighted based on how many you can actually eat, slightly harder to do that for the boxes).
 

Banana Lord

Member
Is there a way to have it not use caviar? Often it's much cheaper to buy fish juice boxes.

EDIT: It also seems to favour the more expensive kinds of sake. I haven't actually calculated it, but is that really more profitable than using pete's sake?
 
Last edited:

Winterbay

Active member
If you can come up with a good way to calculate the worth of a fish juice box I would be all ears. Currently it does a calcualtion based on your value_of_adventure multiplied by turngen+turns of fishy which automatically puts the juice at a disadvantage. The zlib-variable sushi_fish_juice_multiplier is thought as a way to compensate for this based on user preference.
Also: The box costs 20k meat at the moment and gives 20 turns of fishy while a maki with dragonfish caviar costs ~24k and gives 50 turns of fishy which is roughly twice the amount of fishy.

The always drinking of improved sake may actually be a bug. I need to look at that code some more, but I sense an error from a cursory look based on a sorting that happens.
 

Banana Lord

Member
The value of the juice box is going to change depending on what the user is doing (which, as you say, makes things tricky). If it was me, I would add an option along the lines of "sushi_use_caviar" and let the user decide. That way you could leave juice box-fuctionality out of the script altogether. Or maybe you could change the hypothetical setting above to "sushi_turnsOfFishy" and have the script acquire at least that many turns of fishy as cheaply as possible. My current solution is to run this script before ED, and then run a mini-script of my own creation after ED to use juice boxes to make have_effect($effect[fishy]) >= my_adventures().

Ah but when we compare caviar with the juice box what we're really interested in is turns of fishy. Caviar gives 5 turns of fishy for ~8K, while the box gives 20 turns for ~20K.
 

slyz

Developer
The "price" of the maki should include the opportunity cost of using up fullness, shouldn't it?
You would need an average adventure per fullness (a user setting, probably). The opportunity cost would be:

(user adv per full - maki's adv per full) * fullness * ValueOfAventure

Does this sound right?
 
Top