Beispiel #1
0
    def set_environment(self, env):
        self.environment = env
        for id in self.wall_ids:  # delete the walls
            common.removeObject(id)
        del self.wall_ids[:]  # clear the ids
        OpenNero.set_environment(env)

        common.addObject("data/shapes/cube/WhiteCube.xml",
                         OpenNero.Vector3f(1 * constants.GRID_DX,
                                           2 * constants.GRID_DY,
                                           0 * constants.GRID_DZ),
                         OpenNero.Vector3f(0, 0, 0),
                         scale=OpenNero.Vector3f(.25, .25, 4))
        common.addObject("data/shapes/cube/WhiteCube.xml",
                         OpenNero.Vector3f(2 * constants.GRID_DX,
                                           2 * constants.GRID_DY,
                                           0 * constants.GRID_DZ),
                         OpenNero.Vector3f(0, 0, 0),
                         scale=OpenNero.Vector3f(.25, .25, 4))
        common.addObject("data/shapes/cube/WhiteCube.xml",
                         OpenNero.Vector3f(3 * constants.GRID_DX,
                                           2 * constants.GRID_DY,
                                           0 * constants.GRID_DZ),
                         OpenNero.Vector3f(0, 0, 0),
                         scale=OpenNero.Vector3f(.25, .25, 4))
Beispiel #2
0
 def setup_sandbox(self):
     """
     setup the sandbox environment
     """
     OpenNero.getSimContext().delay = 0.0
     self.environment = RoombaEnvironment(constants.XDIM, constants.YDIM)
     OpenNero.set_environment(self.environment)
Beispiel #3
0
    def set_environment(self, env):
        self.environment = env
        for id in self.wall_ids:  # delete the walls
            common.removeObject(id)
        del self.wall_ids[:]  # clear the ids
        OpenNero.set_environment(env)

        common.addObject(
            "data/shapes/cube/WhiteCube.xml",
            OpenNero.Vector3f(1 * constants.GRID_DX, 2 * constants.GRID_DY, 0 * constants.GRID_DZ),
            OpenNero.Vector3f(0, 0, 0),
            scale=OpenNero.Vector3f(0.25, 0.25, 4),
        )
        common.addObject(
            "data/shapes/cube/WhiteCube.xml",
            OpenNero.Vector3f(2 * constants.GRID_DX, 2 * constants.GRID_DY, 0 * constants.GRID_DZ),
            OpenNero.Vector3f(0, 0, 0),
            scale=OpenNero.Vector3f(0.25, 0.25, 4),
        )
        common.addObject(
            "data/shapes/cube/WhiteCube.xml",
            OpenNero.Vector3f(3 * constants.GRID_DX, 2 * constants.GRID_DY, 0 * constants.GRID_DZ),
            OpenNero.Vector3f(0, 0, 0),
            scale=OpenNero.Vector3f(0.25, 0.25, 4),
        )
Beispiel #4
0
    def setup_map(self):
        """
        setup the test environment
        """
        OpenNero.disable_ai()

        if self.environment:
            error("Environment already created")
            return
        self.environment = self.create_environment()
        OpenNero.set_environment(self.environment)
        self.environment.setup()

        return True
Beispiel #5
0
    def setup_map(self):
        """
        setup the test environment
        """
        OpenNero.disable_ai()

        if self.environment:
            error("Environment already created")
            return
        self.environment = self.create_environment()
        OpenNero.set_environment(self.environment)
        self.environment.setup()

        return True
Beispiel #6
0
    def setup_map(self):
        """
        setup the test environment
        """
        OpenNero.disable_ai()

        if self.environment:
            error("Environment already created")
            return

        # create the environment - this also creates the rtNEAT object
        self.environment = self.create_environment()
        OpenNero.set_environment(self.environment)

        # world walls
        height = constants.HEIGHT + constants.OFFSET
        common.addObject(
            "data/shapes/cube/Cube.xml",
            OpenNero.Vector3f(constants.XDIM/2, 0, height),
            OpenNero.Vector3f(0, 0, 90),
            scale=OpenNero.Vector3f(1, constants.XDIM, constants.HEIGHT),
            label="World Wall0",
            type=constants.OBJECT_TYPE_OBSTACLE)
        common.addObject(
            "data/shapes/cube/Cube.xml",
            OpenNero.Vector3f(0, constants.YDIM/2, height),
            OpenNero.Vector3f(0, 0, 0),
            scale=OpenNero.Vector3f(1, constants.YDIM, constants.HEIGHT),
            label="World Wall1",
            type=constants.OBJECT_TYPE_OBSTACLE)
        common.addObject(
            "data/shapes/cube/Cube.xml",
            OpenNero.Vector3f(constants.XDIM, constants.YDIM/2, height),
            OpenNero.Vector3f(0, 0, 0),
            scale=OpenNero.Vector3f(1, constants.YDIM, constants.HEIGHT),
            label="World Wall2",
            type=constants.OBJECT_TYPE_OBSTACLE)
        common.addObject(
            "data/shapes/cube/Cube.xml",
            OpenNero.Vector3f(constants.XDIM/2, constants.YDIM, height),
            OpenNero.Vector3f(0, 0, 90),
            scale=OpenNero.Vector3f(1, constants.XDIM, constants.HEIGHT),
            label="World Wall3",
            type=constants.OBJECT_TYPE_OBSTACLE)

        # Add an obstacle wall in the middle
        """
        common.addObject(
            "data/shapes/cube/Cube.xml",
            OpenNero.Vector3f(constants.XDIM/2, constants.YDIM/2, height),
            OpenNero.Vector3f(0, 0, 90),
            scale=OpenNero.Vector3f(1, constants.YDIM / 4, constants.HEIGHT),
            label="World Wall4",
            type=constants.OBJECT_TYPE_OBSTACLE)
        """ 
        # Add the surrounding Environment
        common.addObject(
            "data/terrain/NeroWorld.xml",
            OpenNero.Vector3f(constants.XDIM/2, constants.YDIM/2, 0),
            scale=OpenNero.Vector3f(1, 1, 1),
            label="NeroWorld",
            type=constants.OBJECT_TYPE_LEVEL_GEOM)
        
         
        self.spawnAgent(agent_xml = 'data/shapes/tree/Tree.xml', first_person = False)
        self.spawnAgent(agent_xml = 'data/shapes/character/steve_still_blue.xml', first_person = False)
        self.spawnAgent(agent_xml = 'data/shapes/character/sydney_still.xml', first_person = False, z_pos=5)
        self.spawnAgent(agent_xml = 'data/shapes/cube/GreenCube.xml', first_person = False, z_pos=7)
        
        return True
Beispiel #7
0
    def setup_map(self):
        """
        setup the test environment
        """
        OpenNero.disable_ai()

        if self.environment:
            error("Environment already created")
            return

        # create the environment - this also creates the rtNEAT object
        self.environment = self.create_environment()
        OpenNero.set_environment(self.environment)

        # world walls
        height = constants.HEIGHT + constants.OFFSET
        common.addObject("data/shapes/cube/Cube.xml",
                         OpenNero.Vector3f(constants.XDIM / 2, 0, height),
                         OpenNero.Vector3f(0, 0, 90),
                         scale=OpenNero.Vector3f(constants.WIDTH,
                                                 constants.XDIM,
                                                 constants.HEIGHT * 2),
                         label="World Wall0",
                         type=constants.OBJECT_TYPE_OBSTACLE)
        common.addObject("data/shapes/cube/Cube.xml",
                         OpenNero.Vector3f(0, constants.YDIM / 2, height),
                         OpenNero.Vector3f(0, 0, 0),
                         scale=OpenNero.Vector3f(constants.WIDTH,
                                                 constants.YDIM,
                                                 constants.HEIGHT * 2),
                         label="World Wall1",
                         type=constants.OBJECT_TYPE_OBSTACLE)
        common.addObject("data/shapes/cube/Cube.xml",
                         OpenNero.Vector3f(constants.XDIM, constants.YDIM / 2,
                                           height),
                         OpenNero.Vector3f(0, 0, 0),
                         scale=OpenNero.Vector3f(constants.WIDTH,
                                                 constants.YDIM,
                                                 constants.HEIGHT * 2),
                         label="World Wall2",
                         type=constants.OBJECT_TYPE_OBSTACLE)
        common.addObject("data/shapes/cube/Cube.xml",
                         OpenNero.Vector3f(constants.XDIM / 2, constants.YDIM,
                                           height),
                         OpenNero.Vector3f(0, 0, 90),
                         scale=OpenNero.Vector3f(constants.WIDTH,
                                                 constants.XDIM,
                                                 constants.HEIGHT * 2),
                         label="World Wall3",
                         type=constants.OBJECT_TYPE_OBSTACLE)

        # Add an obstacle wall in the middle
        common.addObject("data/shapes/cube/Cube.xml",
                         OpenNero.Vector3f(constants.XDIM / 2,
                                           constants.YDIM / 2, height),
                         OpenNero.Vector3f(0, 0, 90),
                         scale=OpenNero.Vector3f(constants.WIDTH,
                                                 constants.YDIM / 4,
                                                 constants.HEIGHT * 2),
                         label="World Wall4",
                         type=constants.OBJECT_TYPE_OBSTACLE)

        # Add some trees
        for i in (0.25, 0.75):
            for j in (0.25, 0.75):
                # don't collide with trees - they are over 500 triangles each
                common.addObject("data/shapes/tree/Tree.xml",
                                 OpenNero.Vector3f(i * constants.XDIM,
                                                   j * constants.YDIM,
                                                   constants.OFFSET),
                                 OpenNero.Vector3f(0, 0, 0),
                                 scale=OpenNero.Vector3f(1, 1, 1),
                                 label="Tree %d %d" % (10 * i, 10 * j),
                                 type=constants.OBJECT_TYPE_LEVEL_GEOM)
                # collide with their trunks represented with cubes instead
                common.addObject(
                    "data/shapes/cube/Cube.xml",
                    OpenNero.Vector3f(i * constants.XDIM, j * constants.YDIM,
                                      constants.OFFSET),
                    OpenNero.Vector3f(0, 0, 0),
                    scale=OpenNero.Vector3f(1, 1, constants.HEIGHT),
                    type=constants.OBJECT_TYPE_OBSTACLE)

        # Add the surrounding Environment
        common.addObject("data/terrain/NeroWorld.xml",
                         OpenNero.Vector3f(constants.XDIM / 2,
                                           constants.YDIM / 2, 0),
                         scale=OpenNero.Vector3f(1.2, 1.2, 1.2),
                         label="NeroWorld",
                         type=constants.OBJECT_TYPE_LEVEL_GEOM)

        return True
    def setup_map(self):
        """
        setup the test environment
        """
        OpenNero.disable_ai()

        if self.environment:
            error("Environment already created")
            return

        # create the environment - this also creates the rtNEAT object
        self.environment = self.create_environment()
        OpenNero.set_environment(self.environment)

        # world walls
        height = constants.HEIGHT + constants.OFFSET
        common.addObject(
            "data/shapes/cube/Cube.xml",
            OpenNero.Vector3f(constants.XDIM/2, 0, height),
            OpenNero.Vector3f(0, 0, 90),
            scale=OpenNero.Vector3f(constants.WIDTH, constants.XDIM, constants.HEIGHT*2),
            label="World Wall0",
            type=constants.OBJECT_TYPE_OBSTACLE)
        common.addObject(
            "data/shapes/cube/Cube.xml",
            OpenNero.Vector3f(0, constants.YDIM/2, height),
            OpenNero.Vector3f(0, 0, 0),
            scale=OpenNero.Vector3f(constants.WIDTH, constants.YDIM, constants.HEIGHT*2),
            label="World Wall1",
            type=constants.OBJECT_TYPE_OBSTACLE)
        common.addObject(
            "data/shapes/cube/Cube.xml",
            OpenNero.Vector3f(constants.XDIM, constants.YDIM/2, height),
            OpenNero.Vector3f(0, 0, 0),
            scale=OpenNero.Vector3f(constants.WIDTH, constants.YDIM, constants.HEIGHT*2),
            label="World Wall2",
            type=constants.OBJECT_TYPE_OBSTACLE)
        common.addObject(
            "data/shapes/cube/Cube.xml",
            OpenNero.Vector3f(constants.XDIM/2, constants.YDIM, height),
            OpenNero.Vector3f(0, 0, 90),
            scale=OpenNero.Vector3f(constants.WIDTH, constants.XDIM, constants.HEIGHT*2),
            label="World Wall3",
            type=constants.OBJECT_TYPE_OBSTACLE)

        # Add an obstacle wall in the middle
        common.addObject(
            "data/shapes/cube/Cube.xml",
            OpenNero.Vector3f(constants.XDIM/2, constants.YDIM/2, height),
            OpenNero.Vector3f(0, 0, 90),
            scale=OpenNero.Vector3f(constants.WIDTH, 100, constants.HEIGHT*2),
            label="World Wall4",
            type=constants.OBJECT_TYPE_OBSTACLE)

#        # Add some trees
#        for i in (0.25, 0.75):
#            for j in (0.25, 0.75):
#                # don't collide with trees - they are over 500 triangles each
#                common.addObject(
#                    "data/shapes/tree/Tree.xml",
#                    OpenNero.Vector3f(i * constants.XDIM, j * constants.YDIM, constants.OFFSET),
#                    OpenNero.Vector3f(0, 0, 0),
#                    scale=OpenNero.Vector3f(1, 1, 1),
#                    label="Tree %d %d" % (10 * i, 10 * j),
#                    type=constants.OBJECT_TYPE_LEVEL_GEOM)
#                # collide with their trunks represented with cubes instead
#                common.addObject(
#                    "data/shapes/cube/Cube.xml",
#                    OpenNero.Vector3f(i * constants.XDIM, j * constants.YDIM, constants.OFFSET),
#                    OpenNero.Vector3f(0,0,0),
#                    scale=OpenNero.Vector3f(1,1,constants.HEIGHT),
#                    type=constants.OBJECT_TYPE_OBSTACLE)

        # Add the surrounding Environment
        common.addObject(
            "data/terrain/NeroWorld.xml",
            OpenNero.Vector3f(constants.XDIM/2, constants.YDIM/2, 0),
            scale=OpenNero.Vector3f(1.2, 1.2, 1.2),
            label="NeroWorld",
            type=constants.OBJECT_TYPE_LEVEL_GEOM)

        return True
Beispiel #9
0
    def setup_map(self):
        """
        setup the test environment
        """
        OpenNero.disable_ai()

        if self.environment:
            error("Environment already created")
            return

        # create the environment - this also creates the rtNEAT object
        self.environment = self.create_environment()
        OpenNero.set_environment(self.environment)

        # world walls
        height = constants.HEIGHT + constants.OFFSET
        common.addObject("data/shapes/cube/Cube.xml",
                         OpenNero.Vector3f(constants.XDIM / 2, 0, height),
                         OpenNero.Vector3f(0, 0, 90),
                         scale=OpenNero.Vector3f(1, constants.XDIM,
                                                 constants.HEIGHT),
                         label="World Wall0",
                         type=constants.OBJECT_TYPE_OBSTACLE)
        common.addObject("data/shapes/cube/Cube.xml",
                         OpenNero.Vector3f(0, constants.YDIM / 2, height),
                         OpenNero.Vector3f(0, 0, 0),
                         scale=OpenNero.Vector3f(1, constants.YDIM,
                                                 constants.HEIGHT),
                         label="World Wall1",
                         type=constants.OBJECT_TYPE_OBSTACLE)
        common.addObject("data/shapes/cube/Cube.xml",
                         OpenNero.Vector3f(constants.XDIM, constants.YDIM / 2,
                                           height),
                         OpenNero.Vector3f(0, 0, 0),
                         scale=OpenNero.Vector3f(1, constants.YDIM,
                                                 constants.HEIGHT),
                         label="World Wall2",
                         type=constants.OBJECT_TYPE_OBSTACLE)
        common.addObject("data/shapes/cube/Cube.xml",
                         OpenNero.Vector3f(constants.XDIM / 2, constants.YDIM,
                                           height),
                         OpenNero.Vector3f(0, 0, 90),
                         scale=OpenNero.Vector3f(1, constants.XDIM,
                                                 constants.HEIGHT),
                         label="World Wall3",
                         type=constants.OBJECT_TYPE_OBSTACLE)

        # Add an obstacle wall in the middle
        """
        common.addObject(
            "data/shapes/cube/Cube.xml",
            OpenNero.Vector3f(constants.XDIM/2, constants.YDIM/2, height),
            OpenNero.Vector3f(0, 0, 90),
            scale=OpenNero.Vector3f(1, constants.YDIM / 4, constants.HEIGHT),
            label="World Wall4",
            type=constants.OBJECT_TYPE_OBSTACLE)
        """
        # Add the surrounding Environment
        common.addObject("data/terrain/NeroWorld.xml",
                         OpenNero.Vector3f(constants.XDIM / 2,
                                           constants.YDIM / 2, 0),
                         scale=OpenNero.Vector3f(1, 1, 1),
                         label="NeroWorld",
                         type=constants.OBJECT_TYPE_LEVEL_GEOM)

        self.spawnAgent(agent_xml='data/shapes/tree/Tree.xml',
                        first_person=False)
        self.spawnAgent(agent_xml='data/shapes/character/steve_still_blue.xml',
                        first_person=False)
        self.spawnAgent(agent_xml='data/shapes/character/sydney_still.xml',
                        first_person=False,
                        z_pos=5)
        self.spawnAgent(agent_xml='data/shapes/cube/GreenCube.xml',
                        first_person=False,
                        z_pos=7)

        return True