public void CrashLeft()
 {
     var puzzle = new Puzzle(File.ReadAllText("../../Puzzles/Cargo101.json"));
     var solution = new Solution();
     solution.F1.AddInstruction(InstructionType.Left);
     var simulator = new Simulator(puzzle, solution);
     Assert.AreEqual(SimulationResult.CrashedIntoLeftWall, simulator.Run());
 }
 public void DetectInfiniteLoop()
 {
     var puzzle = new Puzzle(File.ReadAllText("../../Puzzles/Cargo101.json"));
     var solution = new Solution();
     solution.F1.AddInstruction(InstructionType.Down);
     solution.F1.AddInstruction(InstructionType.F1);
     var simulator = new Simulator(puzzle, solution);
     Assert.AreEqual(SimulationResult.InfiniteLoop, simulator.Run());
 }
 public void CallFunction()
 {
     var puzzle = new Puzzle(File.ReadAllText("../../Puzzles/Cargo101.json"));
     var solution = new Solution();
     solution.F1.AddInstruction(InstructionType.F2);
     solution.F1.AddInstruction(InstructionType.Right);
     solution.F1.AddInstruction(InstructionType.F2);
     solution.F2.AddInstruction(InstructionType.Down);
     var simulator = new Simulator(puzzle, solution);
     Assert.AreEqual(SimulationResult.Solved, simulator.Run());
 }
 public void CrashIntoBoxes()
 {
     var puzzle = new Puzzle(File.ReadAllText("../../Puzzles/WalkingPiles.json"));
     var solution = new Solution();
     solution.F1.AddInstruction(InstructionType.Down);
     solution.F1.AddInstruction(InstructionType.Right);
     solution.F1.AddInstruction(InstructionType.Down);
     solution.F1.AddInstruction(InstructionType.Left);
     solution.F1.AddInstruction(InstructionType.F1);
     var simulator = new Simulator(puzzle, solution);
     Assert.AreEqual(SimulationResult.CrashedIntoBoxes, simulator.Run());
 }
        public Solution GetNextSolution()
        {
            Increment();

            var solution = new Solution();

            foreach (var index in indices)
            {
                var instr = toolbox[index];
                solution.F1.AddInstruction(instr.Type, instr.Condition);
            }

            return solution;
        }
 public void EmptySolution()
 {
     var puzzle = new Puzzle(File.ReadAllText("../../Puzzles/Cargo101.json"));
     var solution = new Solution();
     var simulator = new Simulator(puzzle, solution);
     Assert.AreEqual(SimulationResult.Finished, simulator.Run());
 }
 //readonly HashSet<Snapshot> snapshots = new HashSet<Snapshot>();
 public Simulator(Puzzle puzzle, Solution solution)
 {
     this.puzzle = puzzle;
     this.solution = solution;
     this.currentStage = puzzle.InitialStage;
 }