Exemple #1
0
    def test_not_equals_wrong_item(self):
        state1 = SimulatorState(2)
        state1.add_item_to_floor('AM', 2)
        state1.add_item_to_floor('BM', 2)
        state1.add_item_to_floor('AG', 1)
        state1.add_item_to_floor('BG', 1)

        state2 = SimulatorState(2)
        state2.add_item_to_floor('BM', 1)
        state2.add_item_to_floor('AM', 1)
        state2.add_item_to_floor('BG', 2)
        state2.add_item_to_floor('AG', 2)

        self.assertFalse(state1 == state2)
Exemple #2
0
    def test_equivalent_states(self):
        state1 = SimulatorState(2)
        state1.add_item_to_floor('HM', 0)
        state1.add_item_to_floor('HG', 1)
        state1.add_item_to_floor('LiG', 1)
        state1.add_item_to_floor('LiM', 2)

        state2 = SimulatorState(2)
        state2.add_item_to_floor('LiG', 1)
        state2.add_item_to_floor('LiM', 0)
        state2.add_item_to_floor('HG', 1)
        state2.add_item_to_floor('HM', 2)

        self.assertTrue(SimulatorState.equivalent_states(state1, state2))
Exemple #3
0
    def test_different_states(self):
        state1 = SimulatorState(3)
        state1.add_item_to_floor('CM', 2)
        state1.add_item_to_floor('AG', 3)
        state1.add_item_to_floor('BG', 3)
        state1.add_item_to_floor('CG', 3)
        state1.add_item_to_floor('AM', 3)
        state1.add_item_to_floor('BM', 3)

        state2 = SimulatorState(3)
        state2.add_item_to_floor('BM', 2)
        state2.add_item_to_floor('CM', 2)
        state2.add_item_to_floor('AG', 3)
        state2.add_item_to_floor('BG', 3)
        state2.add_item_to_floor('CG', 3)
        state2.add_item_to_floor('AM', 3)

        self.assertFalse(SimulatorState.equivalent_states(state1, state2))
    def test_puzzle_two(self):
        assembler = MicrochipAssembler()
        start = SimulatorState(0)
        start.add_item_to_floor('SrG', 0)
        start.add_item_to_floor('SrM', 0)
        start.add_item_to_floor('PuG', 0)
        start.add_item_to_floor('PuM', 0)
        start.add_item_to_floor('ElG', 0)
        start.add_item_to_floor('ElM', 0)
        start.add_item_to_floor('DlG', 0)
        start.add_item_to_floor('DlM', 0)
        start.add_item_to_floor('TmG', 1)
        start.add_item_to_floor('RuG', 1)
        start.add_item_to_floor('RuM', 1)
        start.add_item_to_floor('CmG', 1)
        start.add_item_to_floor('CmM', 1)
        start.add_item_to_floor('TmM', 2)

        self.assertEqual(61, assembler.solve(start))
 def test_one_move_to_completion(self):
     assembler = MicrochipAssembler()
     start = SimulatorState(2)
     start.add_item_to_floor('HG', 2)
     start.add_item_to_floor('HM', 3)
     self.assertEqual(1, assembler.solve(start))
Exemple #6
0
 def test_cannot_move_item_that_does_not_exist(self):
   with self.assertRaises(RuntimeError):
     rad_sim = RadiationContainmentSimulator(SimulatorState(0))
     rad_sim.elevator_up(['CaM'])
 def test_two_moves_to_completion(self):
     assembler = MicrochipAssembler()
     start = SimulatorState(1)
     start.add_item_to_floor('CoG', 1)
     start.add_item_to_floor('CoM', 3)
     self.assertEqual(2, assembler.solve(start))
Exemple #8
0
 def test_cannot_move_empty_elevator(self):
   with self.assertRaises(ElevatorCapacityError):
     rad_sim = RadiationContainmentSimulator(SimulatorState(0))
     rad_sim.elevator_up([])
Exemple #9
0
 def assert_floors(self, simulator_state:SimulatorState, expected_floor_map):
   for (i, floor) in enumerate(simulator_state.get_floors()):
     self.assertCountEqual(floor, expected_floor_map[i])
Exemple #10
0
 def assert_elevator_location(self, simulator_state:SimulatorState, elevator_floor):
   self.assertEqual(simulator_state.get_elevator_floor(), elevator_floor)
 def __init__(self, initial_state:SimulatorState):
   self.floors = Floors(initial_state.floors)
   self.elevator = Elevator(initial_state.get_elevator_floor())
 def get_simulator_state(self) -> SimulatorState:
   state = SimulatorState(self.elevator.get_floor())
   state.set_floors(self.floors)
   return state