Page 3 of 3 FirstFirst 1 2 3
Results 21 to 27 of 27

Thread: SmashLib: Expected results from smashing

  1. #21
    Senior Member Theraze's Avatar
    Join Date
    Mar 2010
    Posts
    8,743

    Default

    Attached is a tweaked version of the post 13 SmashLib, that fixes the warnings/errors from return/break in the switches.
    Attached Files

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

    Default

    What did you do to get those? As far as I can see every function in that script has a return value at the end of it (some of them are there in order to fix the thing that the update of mafia fixed, but that's beside the point as they should never be reached anyway), unless I added that to my local copy without updating the thread which I don't think I did.

    Edit: Ok, so missing one update made me miss the .jar that added this feature

    However it appears to not work properly, or could someone explain to me why the code warns on this:
    Code:
    foreach thing in result
    {
    	switch(thing)
    	{
    		case $item[twinkly nuggets]:
    		case $item[twinkly wad]: returnmap["twinkly"] = 1.0; break;
    		case $item[cold nuggets]:
    		case $item[cold wad]: returnmap["cold"] = 1.0; break;
    		case $item[hot nuggets]:
    		case $item[hot wad]: returnmap["hot"] = 1.0; break;
    		case $item[sleaze nuggets]:
    		case $item[sleaze wad]: returnmap["sleaze"] = 1.0; break;
    		case $item[stench nuggets]:
    		case $item[stench wad]: returnmap["stench"] = 1.0; break;
    		case $item[spooky nuggets]:
    		case $item[spooky wad]: returnmap["spooky"] = 1.0; break;
    		case $item[useless powder]: returnmap["useless"] = 1.0; return returnmap; break;
    		case $item[epic wad]: returnmap["epic"] = 1.0; return returnmap; break;			
    		case $item[sea salt crystal]: returnmap["sea salt"] = 1.0; return returnmap; break;
    		case $item[ultimate wad]: returnmap["ultimate"] = 1.0; return returnmap; break;
    		case $item[sugar shard]: returnmap["sugar"] = 1.0; return returnmap; break;
    		case $item[chunk of depleted Grimacite]: returnmap["depleted Grimacite"] = 1.0; return returnmap; break;
    		case $item[wad of Crovacite]: returnmap["Crovacite"] = 1.0; return returnmap; break;
    		case $item[BRICKO brick]: returnmap["BRICKO"] = 1.0; return returnmap; break;
    	}
    }
    The warnings start at "case $item[useless powder]", but I'm pretty certain that part of the code isn't unreachable. At least when calling the script with "antique spear" or "sponge pants" I get the expected result back...
    Also, it does not warn on the bogus return values I added to places that definitely never will get reached.
    Last edited by Winterbay; 03-05-2012 at 07:56 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

  3. #23
    Developer jasonharper's Avatar
    Join Date
    Sep 2008
    Location
    Oklahoma
    Posts
    1,122

    Default

    A "break" immediately after a "return" is unreachable.
    In game: Seventh (#363053), originally a Seal clubber. I am the Ap'ostle of Ak'gyxoth! (Or is that Ap'ostrophe?)

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

    Default

    Ahh oh,thanks. I missed that due to the variable name being returnmap...
    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

  5. #25
    Senior Member Theraze's Avatar
    Join Date
    Mar 2010
    Posts
    8,743

    Default

    Yeah, sorry... tried to explain where the problems were... it's where it was returning and breaking after the returns in the switches. I had one similar (continue/break) in EatDrink.

  6. #26
    Senior Member
    Join Date
    Mar 2012
    Posts
    247

    Default

    So I know this thread is old, but there is a bug in get_smash_yield():

    Code:
    float [item] get_smash_yield(item it)
    {
    	float [item] resultf;
    	float sum = 0;
    	int[item] resulti;
    		
    	if (!is_smashable(it))
    		return resultf;
    		
    	string tier = get_smash_tier(it);
    	float [string] element_type = get_smash_element(it);
    	resulti = get_related(it,"pulverize");
    	
    	foreach thing in resulti
    	{
    		sum = sum + resulti[thing];
    	}
    	foreach thing in resulti
    	{
    		resultf[thing] = resulti[thing] / sum; // BUG HERE
    	}
    	return resultf;
    }
    The bug is noted above. To find the expected yield of each thing, the line marked above should actually be


    resultf[thing] = resulti[thing] / 1000000.0; // This is correct

    This properly accounts for multiple returns. In addition, the computation of the variable "sum" is unnecessary.

    For example, the item "Armgun" yields 4 nuggets 50% of the time, and 1 wad 50% of the time.

    Working out the math, that means that the average yields should be:
    E(#Twinkly nuggets) = 0.5*4=2
    E(#Twinkly wads) = 0.5*1=0.5

    This is properly reflected by the get_related ash function:

    Code:
    > ash get_related($item[armgun],"pulverize");
    
    Returned: aggregate int [item]
    twinkly nuggets => 2000000
    twinkly wad => 500000
    I'm not sure where else this bug occurs, because I only use a few functions.
    Last edited by rlbond86; 05-01-2012 at 04:16 PM.

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

    Default

    This version fixes errors due to element now being disallowed in foreach-loops (as it should really) and the above mentioned bug that was probably introduced when I went from loading the map to using get_related.
    Attached Files
    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. Replies: 0
    Last Post: 09-07-2015, 09:00 PM
  2. 16271: You can walk away from smashing barrels
    By RSS Bot in forum Latest SVN Changes
    Replies: 0
    Last Post: 09-03-2015, 03:26 AM
  3. New Content - Implemented Recognize smashing A Stone Shrine
    By Bale in forum Bug Reports
    Replies: 2
    Last Post: 03-06-2015, 10:23 AM
  4. Replies: 0
    Last Post: 01-13-2014, 04:10 PM
  5. New Content Smashing Pumpkins
    By Veracity in forum Bug Reports
    Replies: 3
    Last Post: 08-20-2012, 11:52 PM

Posting Permissions

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