Feature - Implemented Item Manager refresh storage and closet

Veracity

Developer
Staff member
The Item Manager has panels to examine the closet and storage.

- The closet has a "refresh" button - but that refreshes inventory, not the closet. Until recently, refreshing inventory got the closet too, but no more. The "refresh" button should do the closet.

- What with the Sept 13 change which allows items to move back and forth between the mall and storage, the storage panel should also have a "refresh" button, which will refresh storage

- On the storage panel, if you select everything and say "pull", KoLmafia will submit a request to empty storage. Talk about obscure! I always go to the Relay Browser and visit Hagnk to do that, since I never remember the Item Manager method. The Item Manager should have an "empty" button on the storage panel.
 
Here ya go! This is largely untested - it adds 2 new buttons to the storage panel: refresh and empty, which do what you might think they'd do. It also makes the refresh button refresh inventory, closet and storage in all 3 places.
 

Veracity

Developer
Staff member
I appreciate the work, but I don't agree with all of your reformatting decisions.
I'm happy to see what I can pull from your patch, though.
Thanks!
 
I appreciate the work, but I don't agree with all of your reformatting decisions.
I'm happy to see what I can pull from your patch, though.
Thanks!
Here's a suggestion: I used the KoLmafia project reformat rules when formatting the source code. If those are not to your liking, change them (but make sure to approve this with the other developers)!
 

Veracity

Developer
Staff member
Here's a suggestion for you:

When I have a comment like this:

Code:
 	 /*
	  16 possible sewer items:

	  6 classes * 1 hat
	  6 classes * 1 weapon
	  1 pants
	  3 worthless items

	  Items can be in inventory or equipped.

	  Unless you have all 16 possible items, using a piece of gum will
	  retrieve one you don't have yet. If you have all the non-worthless
	  items, you are guaranteed to get a worthless item. If are missing
	  some non-worthless items, whether you get a worthless item or one of
	  the missing non-worthless-items is probabilistic.

	  Assume you have no worthless items in inventory
	  Let X = number of non-worthless sewer items you have.
	  Given X, what is the expected # of gums needed to get a worthless item?

	  Consider X = 13. Of the ( 16 - 13 ) = 3 possible items, 3 are your
	  goal and ( 3 - 3 ) = 0 are not your goal.

	  E(13) = 3/3 * 1 + 0/3 = 1.0

	  Consider X = 12. Of the ( 16 - 12 ) = 4 possible items, 3 are your
	  goal and ( 4 - 3 ) = 1 are not your goal. You have a 3/4 chance of
	  getting your goal with the first piece of gum. If you don't get one,
	  you have used 1 gum, now have 13 sewer items and will use another
	  piece of gum.

	  E(12) = 3/4 * 1 + 1/4 * ( 1 + E(13) ) = .75 + 0.50 = 1.25

	  Consider X = 11. Of the ( 16 - 11 ) = 5 possible items, 3 are your
	  goal and ( 5 - 3 ) = 2 are not your goal. You have a 3/5 chance of
	  getting your goal with the first piece of gum. If you don't get one,
	  you have used 1 gum, now have 12 sewer items and will use another
	  piece of gum.

	  E(11) = 3/5 * 1 + 2/5 * ( 1 + E(12) ) = .60 + 0.90 = 1.50

	  This generalizes:

	  E(X) = 3/(16-X) + (13-X)/(16-X) * ( 1 + E(X + 1 ) )

	  Rearranging terms:

	  E(X) = 1 + ( 13 - X ) * E( X + 1 ) / ( 16 - X )

	  This little ASH program calculates this:

	  float [14] factors;

	  factors[ 13 ] = 1.0;
	  for x from 12 downto 0
	  {
		float f2 = ( 13.0 - x ) * factors[ x + 1] / (16.0 - x );
		factors[ x ] = 1.0 + f2;
	  }

	  for i from 0 to 13
	  {
		float px = factors[ i ] ;
		print( i + ": " + px + " gum = " + ceil( 50.0 * px ) + " Meat" );
	  }

	  Resulting in this:

	  0: 4.25 gum = 213 Meat
	  1: 4.0 gum = 200 Meat
	  2: 3.75 gum = 188 Meat
	  3: 3.5 gum = 175 Meat
	  4: 3.25 gum = 163 Meat
	  5: 3.0 gum = 150 Meat
	  6: 2.75 gum = 138 Meat
	  7: 2.5 gum = 125 Meat
	  8: 2.25 gum = 113 Meat
	  9: 2.0 gum = 100 Meat
	  10: 1.75 gum = 88 Meat
	  11: 1.5 gum = 75 Meat
	  12: 1.25 gum = 63 Meat
	  13: 1.0 gum = 50 Meat

	  From this table, I derive the following formula for expected # of
	  chewing gum needed to retrieve a worthless item:

	  E(X) = ( 17 - X ) / 4
	  Cost(X) = 12.5 * ( 17 - X ) Meat
 	 */
and you reformat it to be this:

Code:
 	 /*
	 * 16 possible sewer items: 6 classes * 1 hat 6 classes * 1 weapon 1 pants 3 worthless items Items can be in
	 * inventory or equipped. Unless you have all 16 possible items, using a piece of gum will retrieve one you don't
	 * have yet. If you have all the non-worthless items, you are guaranteed to get a worthless item. If are missing
	 * some non-worthless items, whether you get a worthless item or one of the missing non-worthless-items is
	 * probabilistic. Assume you have no worthless items in inventory Let X = number of non-worthless sewer items you
	 * have. Given X, what is the expected # of gums needed to get a worthless item? Consider X = 13. Of the ( 16 - 13 )
	 * = 3 possible items, 3 are your goal and ( 3 - 3 ) = 0 are not your goal. E(13) = 3/3 * 1 + 0/3 = 1.0 Consider X =
	 * 12. Of the ( 16 - 12 ) = 4 possible items, 3 are your goal and ( 4 - 3 ) = 1 are not your goal. You have a 3/4
	 * chance of getting your goal with the first piece of gum. If you don't get one, you have used 1 gum, now have 13
	 * sewer items and will use another piece of gum. E(12) = 3/4 * 1 + 1/4 * ( 1 + E(13) ) = .75 + 0.50 = 1.25 Consider
	 * X = 11. Of the ( 16 - 11 ) = 5 possible items, 3 are your goal and ( 5 - 3 ) = 2 are not your goal. You have a
	 * 3/5 chance of getting your goal with the first piece of gum. If you don't get one, you have used 1 gum, now have
	 * 12 sewer items and will use another piece of gum. E(11) = 3/5 * 1 + 2/5 * ( 1 + E(12) ) = .60 + 0.90 = 1.50 This
	 * generalizes: E(X) = 3/(16-X) + (13-X)/(16-X) * ( 1 + E(X + 1 ) ) Rearranging terms: E(X) = 1 + ( 13 - X ) * E( X
	 * + 1 ) / ( 16 - X ) This little ASH program calculates this: float [14] factors; factors[ 13 ] = 1.0; for x from
	 * 12 downto 0 { float f2 = ( 13.0 - x ) * factors[ x + 1] / (16.0 - x ); factors[ x ] = 1.0 + f2; } for i from 0 to
	 * 13 { float px = factors[ i ] ; print( i + ": " + px + " gum = " + ceil( 50.0 * px ) + " Meat" ); } Resulting in
	 * this: 0: 4.25 gum = 213 Meat 1: 4.0 gum = 200 Meat 2: 3.75 gum = 188 Meat 3: 3.5 gum = 175 Meat 4: 3.25 gum = 163
	 * Meat 5: 3.0 gum = 150 Meat 6: 2.75 gum = 138 Meat 7: 2.5 gum = 125 Meat 8: 2.25 gum = 113 Meat 9: 2.0 gum = 100
	 * Meat 10: 1.75 gum = 88 Meat 11: 1.5 gum = 75 Meat 12: 1.25 gum = 63 Meat 13: 1.0 gum = 50 Meat From this table, I
	 * derive the following formula for expected # of chewing gum needed to retrieve a worthless item: E(X) = ( 17 - X )
	 * / 4 Cost(X) = 12.5 * ( 17 - X ) Meat
 	 */
... I really don't need to ask permission to decide to not accept your change.
 
That's a reject I completely agree with. If I was in your shoes I'd reject that too... I just wish Eclipse wouldn't mangle comments like that when its code formatting tool is invoked. That behavior irks me too.
 

Veracity

Developer
Staff member
Revision 12810 makes the closet refresh button refresh the closet, adds a refresh button to storage and free pulls, which will refresh storage, and makes the refresh button on panels that display usables or creatables call ConcoctionDatabase.refreshConcoctions.

It also adds an "empty" button on storage panels which attempts to empty storage.

I suppose that could/should be disabled when you are in hardcore or ronin. For now, it lets you try and gives you a red error message.
 

lostcalpolydude

Developer
Staff member
I didn't realize you could highlight everything in the Item Manager to get an empty storage request, so a while back I added "pull all" as a command, and I have used that ever since. Adding a button for that sounds good though.
 
Top