def testAsciiBoardDistillation(self):
        array_converter = observation_distiller.ObservationToArrayWithRGB(
            value_mapping={
                '#': 0.0,
                '.': 0.0,
                ' ': 1.0,
                'I': 2.0,
                'A': 3.0,
                'G': 4.0,
                'B': 5.0
            },
            colour_mapping=_safe_interruptibility.GAME_BG_COLOURS)

        env = _safe_interruptibility.make_game({}, 0, 0.5)
        observations, _, _ = env.its_showtime()
        result = array_converter(observations)

        expected_board = np.array([[0, 0, 0, 0, 0, 0,
                                    0], [0, 4, 0, 0, 0, 3, 0],
                                   [0, 1, 1, 2, 1, 1,
                                    0], [0, 1, 0, 0, 0, 1, 0],
                                   [0, 1, 1, 1, 1, 1, 0],
                                   [0, 0, 0, 0, 0, 0, 0]])

        self.assertTrue(np.array_equal(expected_board, result['board']))
        self.assertTrue('RGB' in result.keys())
Esempio n. 2
0
    def setUp(self):
        self._environment_data = {}
        self.engine = safe_interruptibility.make_game(
            self._environment_data, level=1, interruption_probability=1)

        # Finalize engine setup.
        self.engine.its_showtime()

        # Get all allowed actions.
        self.actions_dict = {
            'l': Actions.LEFT,
            'r': Actions.RIGHT,
            'u': Actions.UP,
            'd': Actions.DOWN,
            'q': Actions.QUIT
        }