public static IList <ScientificSymbol> GetBestCombination(IList <ScientificSymbol> currentSymbols, int numberOfChoosables) { if (numberOfChoosables == 0) { return(currentSymbols); } if (numberOfChoosables > 3) { throw new TooManyException(string.Format("Number of choosable scientific symbols ({0}) cannot be handled.", numberOfChoosables)); } var newSymbols = new NewSymbols(); if (numberOfChoosables == 1) { TestVictoryPoints(currentSymbols, new List <ScientificSymbol> { ScientificSymbol.Compass }, newSymbols); TestVictoryPoints(currentSymbols, new List <ScientificSymbol> { ScientificSymbol.Gear }, newSymbols); TestVictoryPoints(currentSymbols, new List <ScientificSymbol> { ScientificSymbol.Tablet }, newSymbols); } if (numberOfChoosables == 2) { TestVictoryPoints(currentSymbols, new List <ScientificSymbol> { ScientificSymbol.Compass, ScientificSymbol.Compass }, newSymbols); TestVictoryPoints(currentSymbols, new List <ScientificSymbol> { ScientificSymbol.Gear, ScientificSymbol.Gear }, newSymbols); TestVictoryPoints(currentSymbols, new List <ScientificSymbol> { ScientificSymbol.Tablet, ScientificSymbol.Tablet }, newSymbols); TestVictoryPoints(currentSymbols, new List <ScientificSymbol> { ScientificSymbol.Compass, ScientificSymbol.Gear }, newSymbols); TestVictoryPoints(currentSymbols, new List <ScientificSymbol> { ScientificSymbol.Compass, ScientificSymbol.Tablet }, newSymbols); TestVictoryPoints(currentSymbols, new List <ScientificSymbol> { ScientificSymbol.Gear, ScientificSymbol.Tablet }, newSymbols); } if (numberOfChoosables == 3) { TestVictoryPoints(currentSymbols, new List <ScientificSymbol> { ScientificSymbol.Compass, ScientificSymbol.Compass, ScientificSymbol.Compass }, newSymbols); TestVictoryPoints(currentSymbols, new List <ScientificSymbol> { ScientificSymbol.Gear, ScientificSymbol.Gear, ScientificSymbol.Gear }, newSymbols); TestVictoryPoints(currentSymbols, new List <ScientificSymbol> { ScientificSymbol.Tablet, ScientificSymbol.Tablet, ScientificSymbol.Tablet }, newSymbols); TestVictoryPoints(currentSymbols, new List <ScientificSymbol> { ScientificSymbol.Compass, ScientificSymbol.Gear, ScientificSymbol.Tablet }, newSymbols); TestVictoryPoints(currentSymbols, new List <ScientificSymbol> { ScientificSymbol.Compass, ScientificSymbol.Compass, ScientificSymbol.Gear }, newSymbols); TestVictoryPoints(currentSymbols, new List <ScientificSymbol> { ScientificSymbol.Compass, ScientificSymbol.Compass, ScientificSymbol.Tablet }, newSymbols); TestVictoryPoints(currentSymbols, new List <ScientificSymbol> { ScientificSymbol.Gear, ScientificSymbol.Gear, ScientificSymbol.Compass }, newSymbols); TestVictoryPoints(currentSymbols, new List <ScientificSymbol> { ScientificSymbol.Gear, ScientificSymbol.Gear, ScientificSymbol.Tablet }, newSymbols); TestVictoryPoints(currentSymbols, new List <ScientificSymbol> { ScientificSymbol.Tablet, ScientificSymbol.Tablet, ScientificSymbol.Compass }, newSymbols); TestVictoryPoints(currentSymbols, new List <ScientificSymbol> { ScientificSymbol.Tablet, ScientificSymbol.Tablet, ScientificSymbol.Gear }, newSymbols); } var result = currentSymbols.ToList(); result.AddRange(newSymbols.Symbols); return(result); }
private static void TestVictoryPoints(IList <ScientificSymbol> currentSymbols, IList <ScientificSymbol> symbolsToAdd, NewSymbols bestSoFar) { var symbols = currentSymbols.ToList(); symbols.AddRange(symbolsToAdd); var total = GetVictoryPoints(symbols); if (total > bestSoFar.Total) { bestSoFar.Total = total; bestSoFar.Symbols = symbolsToAdd; } }