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:

This is the one that favors the cheapest total mall price for the two candies: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; }

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: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; }

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

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

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

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