public static bool Produce() { //Produce if (Player.me.module == Module.Molecules) { Action newAction = new Action(Module.Laboratory); Action.AddAction(newAction); return(false); } if (Player.me.module == Module.Laboratory) { if (Player.me.bestCombination != null) { foreach (var tSample in Player.me.bestCombination.samples) { var sample = Player.me.samples.FirstOrDefault(s => s.id == tSample.id); if (sample != null && sample.isCompleted() && sample.health != -1) { Action newAction = new Action(sample); Action.AddAction(newAction); return(false); } } } else //no best combination, use default action { foreach (var sample in Player.me.samples.OrderByDescending(s => s.totalCost)) { if (sample.isCompleted() && sample.health != -1) { Action newAction = new Action(sample); Action.AddAction(newAction); return(false); } } } } //Go Back Collecting if (Player.me.module == Module.Laboratory) { //if enemy is already at lab if (Player.me.samples.Count > 0 && Player.enemy.module == Module.Laboratory) { var refundGameState = new GameState(Player.me); foreach (var sample in Player.enemy.samples.Where(s => s.isCompleted())) { refundGameState.AddRefundSample(sample); } var refundCombination = SampleOptimization.TrySampleCombinations(refundGameState, Player.me.samples, new List <Sample>()); if (refundCombination.Count > 0) { Action newAction = new Action(Module.Molecules); Action.AddAction(newAction); return(false); } } if (Player.me.samples.Count > 0 && Player.me.samples.Any(s => s.canCompleteSample())) { Action newAction = new Action(Module.Molecules); Action.AddAction(newAction); return(false); } else if (Player.me.samples.Count < 3) { Action newAction = new Action(Module.Samples); Action.AddAction(newAction); return(false); } } return(true); }
public static bool Gather() { //Gather if (Player.me.module == Module.Molecules && Player.me.CountMolecules() < 10) { //Stop enemy sample 1 foreach (var sample in Player.enemy.samples) { if (sample.canResearch()) { foreach (var pair in sample.costs.Where(p => p.Value - Player.enemy.expertises[p.Key] - Player.enemy.storages[p.Key] == p.Key.count)) { var molecule = pair.Key; int count = pair.Value; if (count > 4 && molecule.count > 0) { Action newAction = new Action(molecule); Action.AddAction(newAction); return(false); } } } } var combinations = SampleOptimization.TrySampleCombinations(new GameState(Player.me), Player.me.samples, new List <Sample>()); if (combinations.Count > 0) { //Get the longest combination, then by lowest total molecule count var bestCombination = combinations .OrderByDescending(c => c.samples.Count) .ThenBy(c => c.state.CountMolecules()).First(); //if enemy is already at lab, wait for molecules/try better combination //maybe move this up if (Player.enemy.module == Module.Laboratory) { var refundGameState = new GameState(Player.me); foreach (var sample in Player.enemy.samples.Where(s => s.isCompleted())) { refundGameState.AddRefundSample(sample); } var refundCombination = SampleOptimization.TrySampleCombinations(refundGameState, Player.me.samples, new List <Sample>()) .OrderByDescending(c => c.samples.Count) .ThenBy(c => c.state.CountMolecules()).First(); if (refundCombination.samples.Count > bestCombination.samples.Count) { bestCombination = refundCombination; } } Player.me.bestCombination = bestCombination; //grab the missing molecules of the best combination var missingMolecules = bestCombination.CalculateMolecules(); foreach (var pair in missingMolecules.OrderByDescending(p => p.Key.myCount)) { var molecule = pair.Key; int count = pair.Value; if (count > 0 && molecule.count > 0) { Action newAction = new Action(molecule); Action.AddAction(newAction); return(false); } } //Stop enemy sample 2 foreach (var sample in Player.enemy.samples) { if (sample.canResearch()) { foreach (var pair in sample.costs.OrderBy(p => p.Value)) { var molecule = pair.Key; int count = pair.Value; if (count > 3 && molecule.count > 0) { Action newAction = new Action(molecule); Action.AddAction(newAction); return(false); } } } } } else { Player.me.bestCombination = null; } if (Player.me.module == Module.Molecules) { if (!Player.me.samples.Any(s => s.isCompleted())) //no sample is completed { if (Player.me.samples.Count <= 1) { Action newAction = new Action(Module.Samples); Action.AddAction(newAction); return(false); } else { Action newAction = new Action(Module.Diagnosis); Action.AddAction(newAction); return(false); } } } } return(true); }