def test_move_right(self): initial_state = np.array([[1, 2, 3], [4, 0, 6], [7, 5, 8]]) expected_state = np.array([[1, 2, 3], [4, 6, 0], [7, 5, 8]]) old_state = State(initial_state, 0, 0) new_state = old_state.move("right") self.assertTrue(np.all(new_state.tile_seq == expected_state)) initial_state = np.array([[1, 2, 3], [4, 5, 0], [6, 7, 8]]) state = State(initial_state, 0, 0) with self.assertRaises(IndexError): state.move("right")
def test_move_up(self): initial_state = np.array([[1, 2, 3], [0, 4, 6], [7, 5, 8]]) expected_state = np.array([[0, 2, 3], [1, 4, 6], [7, 5, 8]]) old_state = State(initial_state, 0, 0) new_state = old_state.move("up") self.assertTrue(np.all(new_state.tile_seq == expected_state)) self.assertTrue(np.all(old_state.tile_seq == initial_state)) initial_state = np.array([[0, 2, 3], [1, 4, 6], [7, 5, 8]]) state = State(initial_state, 0, 0) with self.assertRaises(IndexError): state.move("up")