Page 1 of 7 1 2 3 ... LastLast
Results 1 to 10 of 62

Thread: Best sushi for profit

  1. #1
    Senior Member Winterbay's Avatar
    Join Date
    Feb 2010
    Posts
    5,033

    Default Best sushi for profit

    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 by Winterbay; 07-17-2013 at 08:18 PM. Reason: New version uploaded
    My scripts:
    Best sushi for Profit
    Winterbay's Helpful Automatic Monsterbasher (WHAM)

    Scripts maintained by me:
    Autobasement
    Smashlib

    A small programmer joke:
    Wife: Honey, please go to the market and buy 1 bottle of milk. If they have eggs, bring 6.
    The man came back with 6 bottles of milk.
    Wife: Why did you buy 6 bottles of milk.
    Man: Because they had eggs...

    The 6 Stages of Debugging: 1 )That can't happen. 2) That shouldn't happen. 3) Hmmm, weird. 4) Why does that happen? 5) Oh, I see. 6 )How did that ever work?

    All programs can be optimized, and all programs have bugs; therefore all programs can be optimized to one line that doesn’t work. /Bob Fitch, Blizzard

  2. #2
    Minion Bale's Avatar
    Join Date
    Jun 2008
    Posts
    13,287

    Default

    Finally found an excuse to try this out today. The script could be easier to use, but not more effective.
    If people like my scripts, please send me stuffed Hodgmen.
    Universal Recovery, OCD Inventory Control, CounterChecker, newLife, ChIT.


  3. #3
    Senior Member Winterbay's Avatar
    Join Date
    Feb 2010
    Posts
    5,033

    Default

    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
    My scripts:
    Best sushi for Profit
    Winterbay's Helpful Automatic Monsterbasher (WHAM)

    Scripts maintained by me:
    Autobasement
    Smashlib

    A small programmer joke:
    Wife: Honey, please go to the market and buy 1 bottle of milk. If they have eggs, bring 6.
    The man came back with 6 bottles of milk.
    Wife: Why did you buy 6 bottles of milk.
    Man: Because they had eggs...

    The 6 Stages of Debugging: 1 )That can't happen. 2) That shouldn't happen. 3) Hmmm, weird. 4) Why does that happen? 5) Oh, I see. 6 )How did that ever work?

    All programs can be optimized, and all programs have bugs; therefore all programs can be optimized to one line that doesn’t work. /Bob Fitch, Blizzard

  4. #4
    Minion Bale's Avatar
    Join Date
    Jun 2008
    Posts
    13,287

    Default

    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>
    If people like my scripts, please send me stuffed Hodgmen.
    Universal Recovery, OCD Inventory Control, CounterChecker, newLife, ChIT.


  5. #5
    Senior Member Winterbay's Avatar
    Join Date
    Feb 2010
    Posts
    5,033

    Default

    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 by Winterbay; 03-25-2011 at 09:34 AM.
    My scripts:
    Best sushi for Profit
    Winterbay's Helpful Automatic Monsterbasher (WHAM)

    Scripts maintained by me:
    Autobasement
    Smashlib

    A small programmer joke:
    Wife: Honey, please go to the market and buy 1 bottle of milk. If they have eggs, bring 6.
    The man came back with 6 bottles of milk.
    Wife: Why did you buy 6 bottles of milk.
    Man: Because they had eggs...

    The 6 Stages of Debugging: 1 )That can't happen. 2) That shouldn't happen. 3) Hmmm, weird. 4) Why does that happen? 5) Oh, I see. 6 )How did that ever work?

    All programs can be optimized, and all programs have bugs; therefore all programs can be optimized to one line that doesn’t work. /Bob Fitch, Blizzard

  6. #6
    Minion Bale's Avatar
    Join Date
    Jun 2008
    Posts
    13,287

    Default

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

    Also, if you want to have a blank cell, use <td>&nbsp;</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 by Bale; 03-25-2011 at 09:51 AM.
    If people like my scripts, please send me stuffed Hodgmen.
    Universal Recovery, OCD Inventory Control, CounterChecker, newLife, ChIT.


  7. #7
    Senior Member Winterbay's Avatar
    Join Date
    Feb 2010
    Posts
    5,033

    Default

    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.
    My scripts:
    Best sushi for Profit
    Winterbay's Helpful Automatic Monsterbasher (WHAM)

    Scripts maintained by me:
    Autobasement
    Smashlib

    A small programmer joke:
    Wife: Honey, please go to the market and buy 1 bottle of milk. If they have eggs, bring 6.
    The man came back with 6 bottles of milk.
    Wife: Why did you buy 6 bottles of milk.
    Man: Because they had eggs...

    The 6 Stages of Debugging: 1 )That can't happen. 2) That shouldn't happen. 3) Hmmm, weird. 4) Why does that happen? 5) Oh, I see. 6 )How did that ever work?

    All programs can be optimized, and all programs have bugs; therefore all programs can be optimized to one line that doesn’t work. /Bob Fitch, Blizzard

  8. #8
    Minion Bale's Avatar
    Join Date
    Jun 2008
    Posts
    13,287

    Default

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

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

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

    That way I don't have to worry about things the script can calculate for me.
    If people like my scripts, please send me stuffed Hodgmen.
    Universal Recovery, OCD Inventory Control, CounterChecker, newLife, ChIT.


  9. #9
    Senior Member Winterbay's Avatar
    Join Date
    Feb 2010
    Posts
    5,033

    Default

    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.
    My scripts:
    Best sushi for Profit
    Winterbay's Helpful Automatic Monsterbasher (WHAM)

    Scripts maintained by me:
    Autobasement
    Smashlib

    A small programmer joke:
    Wife: Honey, please go to the market and buy 1 bottle of milk. If they have eggs, bring 6.
    The man came back with 6 bottles of milk.
    Wife: Why did you buy 6 bottles of milk.
    Man: Because they had eggs...

    The 6 Stages of Debugging: 1 )That can't happen. 2) That shouldn't happen. 3) Hmmm, weird. 4) Why does that happen? 5) Oh, I see. 6 )How did that ever work?

    All programs can be optimized, and all programs have bugs; therefore all programs can be optimized to one line that doesn’t work. /Bob Fitch, Blizzard

  10. #10
    Senior Member Winterbay's Avatar
    Join Date
    Feb 2010
    Posts
    5,033

    Default

    Version 1.2 has been posted with Bale's functions added, a new prettier output and a version check.
    My scripts:
    Best sushi for Profit
    Winterbay's Helpful Automatic Monsterbasher (WHAM)

    Scripts maintained by me:
    Autobasement
    Smashlib

    A small programmer joke:
    Wife: Honey, please go to the market and buy 1 bottle of milk. If they have eggs, bring 6.
    The man came back with 6 bottles of milk.
    Wife: Why did you buy 6 bottles of milk.
    Man: Because they had eggs...

    The 6 Stages of Debugging: 1 )That can't happen. 2) That shouldn't happen. 3) Hmmm, weird. 4) Why does that happen? 5) Oh, I see. 6 )How did that ever work?

    All programs can be optimized, and all programs have bugs; therefore all programs can be optimized to one line that doesn’t work. /Bob Fitch, Blizzard

Similar Threads

  1. ZapWizard - Automatically zaps for mall profit
    By darkcodelagsniper in forum Item Handling Scripts
    Replies: 57
    Last Post: 08-21-2018, 09:16 AM
  2. Profit -- get an accurate meat/adv estimate for a given zone
    By zarqon in forum Informational Scripts
    Replies: 27
    Last Post: 07-31-2013, 04:02 AM
  3. Profit from Effects
    By heeheehee in forum Item Handling Scripts
    Replies: 26
    Last Post: 01-17-2013, 04:00 AM
  4. Replies: 0
    Last Post: 09-11-2010, 03:30 PM
  5. Someone trying to profit from my work
    By dj_d in forum Scripting Discussion
    Replies: 31
    Last Post: 12-30-2009, 10:25 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •