public bool[] CheckSolution(DynamiteWall dw) { bool[] result = new bool[instructions.Length]; for (int i = 0; i < instructions.Length; i++) { result[i] = instructions[i].Check(dw); } return(result); }
public static DynamiteScenario ChooseScenario(GameDifficulty difficulty, DynamiteWall wall, int[] currentHoleStates) { //LastScenario last; //bool lastScenarioAvailable = readLastScenario(out last); List <DynamiteScenario> possibleScenarios = getPossibleScenarios(difficulty); /* * if (lastScenarioAvailable && difficulty == last.difficulty) { * for (int i = 0; i < possibleScenarios.Count; i++) * if (possibleScenarios[i].Number == last.number) { * Log.Verbose("Last scenario found ({0} for difficulty {1}), skipping number {2}", last.name, last.difficulty, last.number); * possibleScenarios.RemoveAt(i); * break; * } * }*/ DynamiteScenario[] shuffled = possibleScenarios.ToArray(); shuffled.Shuffle(); for (int i = 0; i < shuffled.Length; i++) { bool[] instructionsSolved = wall.CheckSolution(shuffled[i], currentHoleStates); if (instructionsSolved.Count(false) > 0) { return(shuffled[i]); } } Log.Warn("Current hole states fulfil every possible scenario for difficulty " + difficulty); return(shuffled[0]); /* * Scenario result = possibleScenarios[Extensions.r.Next(possibleScenarios.Count)]; * writeLastScenario(result); * return result; */ }
internal bool Check(DynamiteWall dw) { return(checker(dw)); }
public DynamiteGame() { wall = new DynamiteWall(); Log.Info("Dynamite game set up."); }