New Content - Implemented Rethinking Candy

Veracity

Developer
Staff member
Thanks.

First I gave ASH all the info about candies.
Then I gave it access to the internal methods that the GUI frame uses to display its candy lists.
Then I gave it access to the internal methods I wrote today to pick a pair of candies.
Finally, I gave you a function to use if/when you decide that you trust those algorithms. :)

You might be amused by the Java code for the two algorithms.

This is the one that picks a pair of candies, favoring the most numerous in inventory:

Code:
	private static Candy[] synthesisPairByCount( final int effectId, final int flags )
	{
		int tier = CandyDatabase.getEffectTier( effectId );

		List<Candy> candy1List = CandyDatabase.itemIdSetToCandyList( CandyDatabase.candyForTier( tier, flags ) );
		Collections.sort( candy1List, INVERSE_COUNT_COMPARATOR );

		for ( Candy candy : candy1List )
		{
			if ( candy.getCount() == 0 )
			{
				// Ran out of available candies
				return NO_PAIR;
			}

			int itemId = candy.getItemId();
			List<Candy> candy2List = CandyDatabase.itemIdSetToCandyList( CandyDatabase.sweetSynthesisPairing( effectId, itemId, flags ) );
			Collections.sort( candy2List, INVERSE_COUNT_COMPARATOR );

			for ( Candy pairing : candy2List )
			{
				int count = pairing.getCount();
				if ( count == 0 )
				{
					// Nothing left in this list. Select a new candy1
					break;
				}
				
				if ( candy.equals( pairing ) && count == 1 )
				{
					// Pairs with itself but only have one.
					continue;
				}

				Candy[] result = new Candy[2];
				result[0] = candy;
				result[1] = pairing;
				return result;
			}
		}

		return NO_PAIR;
	}
This is the one that favors the cheapest total mall price for the two candies:

Code:
	private static Candy[] synthesisPairByCost( final int effectId, final int flags )
	{
		int tier = CandyDatabase.getEffectTier( effectId );

		int bestCost = Integer.MAX_VALUE;
		Candy candy1 = null;
		Candy candy2 = null;

		List<Candy> candy1List = CandyDatabase.itemIdSetToCandyList( CandyDatabase.candyForTier( tier, flags ) );
		Collections.sort( candy1List, MALL_PRICE_COMPARATOR );

		for ( Candy candy : candy1List )
		{
			int cost1 = candy.getCost();
			if ( cost1 > bestCost )
			{
				break;
			}

			int itemId = candy.getItemId();
			List<Candy> candy2List = CandyDatabase.itemIdSetToCandyList( CandyDatabase.sweetSynthesisPairing( effectId, itemId, flags ) );
			Collections.sort( candy2List, MALL_PRICE_COMPARATOR );

			for ( Candy pairing : candy2List )
			{
				int cost2 = pairing.getCost();
				int currentCost = cost1 + cost2;

				if ( currentCost >= bestCost )
				{
					break;
				}

				candy1 = candy;
				candy2 = pairing;
				bestCost = currentCost;
			}
		}

		if ( candy1 == null || candy2 == null )
		{
			return NO_PAIR;
		}

		Candy[] result = new Candy[2];
		result[0] = candy1;
		result[1] = candy2;

		return result;
	}
I say you might be amused because you could just about translate those directly in to ASH, since I exposed the same internal Candy functions to ASH.

Code:
		List<Candy> candy1List = CandyDatabase.itemIdSetToCandyList( CandyDatabase.candyForTier( tier, flags ) );
		Collections.sort( candy1List, INVERSE_COUNT_COMPARATOR );

is essentially

Code:
item [int] list = candy_for_tier( tier, flag );
sort list by -available_amount( value );
and

Code:
			List<Candy> candy2List = CandyDatabase.itemIdSetToCandyList( CandyDatabase.sweetSynthesisPairing( effectId, itemId, flags ) );
			Collections.sort( candy2List, INVERSE_COUNT_COMPARATOR );
is essentially

Code:
item[ int] list = sweet_synthesis_pairing( effect, item, flags );
sort list by -available_amount( value );
 

Bale

Minion
Interesting! Basically, the whole process with all those functions being made available to ash one-by-one was just a matter of exposing the functions as you were writing them so that you could solve the problem of automation in java. Thanks for the peek inside.

Rather neat that you did it the same way I'd program in ash.
 

Veracity

Developer
Staff member
Revision 17647 does this:

Code:
[color=green]> synthesize? greed[/color]

Item 'Milk Studs' is a complex candy. You have 246 available to you without using the mall, where it costs 100 Meat.
Item 'sterno-flavored Hob-O' is a complex candy. You have 12 available to you without using the mall, where it costs 235 Meat.
Synthesizing those two candies will give you 30 turns of Synthesis: Greed (Meat +300%)

[color=green]> synthesize? Milk Studs, sterno-flavored Hob-O[/color]

Item 'Milk Studs' is a complex candy. You have 246 available to you without using the mall, where it costs 100 Meat.
Item 'sterno-flavored Hob-O' is a complex candy. You have 12 available to you without using the mall, where it costs 235 Meat.
Synthesizing those two candies will give you 30 turns of Synthesis: Greed (Meat +300%)
The only visible difference is that it tells you the result of having the effect.

Well, and the fact that rather than matching over ALL effect names, it matches only on the 15 effects that are a result of synthesizing candy. You could previously say "synthesize Synthesis: Greed" (and you still can), but leaving out the Synthesis: part of the name forces fuzzy matching and it will unambiguously find the desired the effect, rather than possibly resulting in an ambiguous result, considering the other 2000 or so effect names.

Which is to say, the second half of the effect names are, effectively, keywords you can use.

If we wanted real keywords - "meat", "items", "muscle", "muscle exp", etc. - that would be additional coding.

I'm not feeling particularly motivated.
 

Ezandora

Member
Datafile correction: sugar-coated pine cone is complex, not simple. It had a candy credit value of 10, which implied simple, but verification has it as complex.

Most of the other candies have been manually verified with no discrepancies.
 
Awesome work on all of this, just one tiny thingy: any chance the buffs can be added to the modifier maximizer? Without that, I'm sure I'll forgot to grab them at some future point, and then I'll be all sad.
 

Veracity

Developer
Staff member
Revision 17660 adds the "synthesize" commands to statuseffects.txt, so the maximizer knows how to generate the effects. The maximizer needs to be taught more about that command to decide whether it is really available: you need to have spleen available and CandyDatabase.synthesisPair( effectId ) needs to return something other than CandyDatabase.NO_PAIR.
 

Veracity

Developer
Staff member
And revision 17661 teaches the maximizer about the synthesize command. That was easier than I expected.
 

Veracity

Developer
Staff member
Two changes for the benefit of people using "available" candies:

Revision 17674 will filter out candies in the Candy A panel if you don't have anything to pair with it in Candy B.
Revision 17675 will disable effect buttons if you don't have ANY suitable pair of candies to synthesize to get it.

Those are both of heeheehee's suggestions and this completes Phase 5.

Which is to say, I'm declaring this New Content to be Implemented.
 

Veracity

Developer
Staff member
(Which is say, bugs should go into new Bug threads and suggestions should go into new Feature threads.)
 

AlbinoRhino

Active member
I'm not sure if this is a bug so don't want to make a new thread just yet. If I go to Preferences > Look & Feel > Main Interface and place "Sweet Synthesis" into the "Startup in Tabs" list, I don't seem to get a tab for it when I restart. I get tabs for things both before and after it in the list, but not that particular one. Is that tool supposed to work as a tab ?
 

Veracity

Developer
Staff member
I've never tried it as a tab. It seems a bit wide to me, but if you're cool with that, why not?
Perhaps there are special constraints needed for frames as tabs. I'll take a look.
 

Veracity

Developer
Staff member
OK, there was a typo and also something I had to do to make the frame be tab-capable.
Revision 17696 should do it for you.

If you already have it listed in your options on a tab, you might have to delete it and re-add it, since I had the wrong frame name (the typo), which might be in your setting.
 

AlbinoRhino

Active member
It seems a bit wide to me, but if you're cool with that, why not?

Looks pretty "sweet" (heh, heh) to me. As you can see, I am back to using the toolbar and also placing almost everything in a tab ! lol Thanks again for all you do !


9BBDtd1.jpg
 

AlbinoRhino

Active member
Love the encyclopedia. Wish it had even more data. Like the location data. Ooh, and proxy info. So much nicer than searching through txt files.
 

gulaschkanone

New member
Minor nitpicks: It seems like Mafia still increments your spleen when you visit the "Sweet Synthesis" choice in the relay browser by chat command (/cast synthes), then leave that choice. It seems to not happen if you enter the choice by clicking the button on your skill page. Also, '[21:21] Ezandora: really? I'm not seeing that. though "you have to pick two candies!" will increment local spleen', although i can't test that right now.
 
Top