当前位置: 首页>>代码示例>>Python>>正文


Python Box2D.b2World方法代码示例

本文整理汇总了Python中Box2D.b2World方法的典型用法代码示例。如果您正苦于以下问题:Python Box2D.b2World方法的具体用法?Python Box2D.b2World怎么用?Python Box2D.b2World使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Box2D的用法示例。


在下文中一共展示了Box2D.b2World方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import Box2D [as 别名]
# 或者: from Box2D import b2World [as 别名]
def __init__(self):
        self._seed()
        self.viewer = None

        self.world = Box2D.b2World()
        self.moon = None
        self.lander = None
        self.particles = []

        self.prev_reward = None

        high = np.array([np.inf]*N_OBS_DIM)  # useful range is -1 .. +1, but spikes can be higher
        self.observation_space = spaces.Box(-high, high)

        self.action_space = spaces.Discrete(N_ACT_DIM)

        self.curr_step = None

        self._reset() 
开发者ID:xuwd11,项目名称:cs294-112_hws,代码行数:21,代码来源:lunar_lander.py

示例2: __init__

# 需要导入模块: import Box2D [as 别名]
# 或者: from Box2D import b2World [as 别名]
def __init__(self):
        self.seed()
        self.viewer = None

        self.world = Box2D.b2World()
        self.moon = None
        self.lander = None
        self.particles = []

        self.prev_reward = None

        high = np.array([np.inf]*8)  # useful range is -1 .. +1, but spikes can be higher
        self.observation_space = spaces.Box(-high, high)

        if self.continuous:
            # Action is two floats [main engine, left-right engines].
            # Main engine: -1..0 off, 0..+1 throttle from 50% to 100% power. Engine can't work with less than 50% power.
            # Left-right:  -1.0..-0.5 fire left engine, +0.5..+1.0 fire right engine, -0.5..0.5 off
            self.action_space = spaces.Box(-1, +1, (2,))
        else:
            # Nop, fire left engine, main engine, right engine
            self.action_space = spaces.Discrete(4)

        self.reset() 
开发者ID:ArztSamuel,项目名称:DRL_DeliveryDuel,代码行数:26,代码来源:lunar_lander.py

示例3: __init__

# 需要导入模块: import Box2D [as 别名]
# 或者: from Box2D import b2World [as 别名]
def __init__(self):
        EzPickle.__init__(self)
        self.seed()
        self.viewer = None

        self.world = Box2D.b2World()
        self.moon = None
        self.lander = None
        self.particles = []

        self.prev_reward = None

        # useful range is -1 .. +1, but spikes can be higher
        self.observation_space = spaces.Box(-np.inf, np.inf, shape=(8,), dtype=np.float32)

        if self.continuous:
            # Action is two floats [main engine, left-right engines].
            # Main engine: -1..0 off, 0..+1 throttle from 50% to 100% power. Engine can't work with less than 50% power.
            # Left-right:  -1.0..-0.5 fire left engine, +0.5..+1.0 fire right engine, -0.5..0.5 off
            self.action_space = spaces.Box(-1, +1, (2,), dtype=np.float32)
        else:
            # Nop, fire left engine, main engine, right engine
            self.action_space = spaces.Discrete(4)

        self.reset() 
开发者ID:joanby,项目名称:ia-course,代码行数:27,代码来源:lunar_lander.py

示例4: __init__

# 需要导入模块: import Box2D [as 别名]
# 或者: from Box2D import b2World [as 别名]
def __init__(self, width, height):
        super(PhysicalWorld, self).__init__()

        # Create the world in the physics engine.
        self._contacts = ContactListener()
        self._filter = ContactFilter()
        self._engine = box_2d.b2World(
            gravity=(0, 0),
            contactListener=self._contacts,
            contactFilter=self._filter,
        )
        self._width, self._height = width, height
        self._destroy_queue = []

        self.add(cocos.layer.ColorLayer(0, 0, 0, 255))

        self._batch = cocos.batch.BatchNode()
        self.add(self._batch)

        self.seed()
        self.create_world(self._batch)
        self.reset_world()

        self._terminal = False 
开发者ID:sunblaze-ucb,项目名称:rl-generalization,代码行数:26,代码来源:physical_world.py

示例5: __init__

# 需要导入模块: import Box2D [as 别名]
# 或者: from Box2D import b2World [as 别名]
def __init__(self, verbose=1):
        EzPickle.__init__(self)
        self.seed()
        self.contactListener_keepref = FrictionDetector(self)
        self.world = Box2D.b2World((0,0), contactListener=self.contactListener_keepref)
        self.viewer = None
        self.invisible_state_window = None
        self.invisible_video_window = None
        self.road = None
        self.car = None
        self.reward = 0.0
        self.prev_reward = 0.0
        self.verbose = verbose
        self.fd_tile = fixtureDef(
                shape = polygonShape(vertices=
                    [(0, 0),(1, 0),(1, -1),(0, -1)]))

        self.action_space = spaces.Box( np.array([-1,0,0]), np.array([+1,+1,+1]), dtype=np.float32)  # steer, gas, brake
        self.observation_space = spaces.Box(low=0, high=255, shape=(STATE_H, STATE_W, 3), dtype=np.uint8) 
开发者ID:hust512,项目名称:DQN-DDPG_Stock_Trading,代码行数:21,代码来源:car_racing.py

示例6: __init__

# 需要导入模块: import Box2D [as 别名]
# 或者: from Box2D import b2World [as 别名]
def __init__(self):
        self.seed()
        self.contactListener_keepref = FrictionDetector(self)
        self.world = Box2D.b2World((0,0), contactListener=self.contactListener_keepref)
        self.viewer = None
        self.invisible_state_window = None
        self.invisible_video_window = None
        self.road = None
        self.car = None
        self.reward = 0.0
        self.prev_reward = 0.0

        self.action_space = spaces.Box( np.array([-1,0,0]), np.array([+1,+1,+1]))  # steer, gas, brake
        self.observation_space = spaces.Box(low=0, high=255, shape=(STATE_H, STATE_W, 3), dtype=np.uint8) 
开发者ID:ArztSamuel,项目名称:DRL_DeliveryDuel,代码行数:16,代码来源:car_racing.py

示例7: __init__

# 需要导入模块: import Box2D [as 别名]
# 或者: from Box2D import b2World [as 别名]
def __init__(self):
        self.seed()
        self.viewer = None

        self.world = Box2D.b2World()
        self.terrain = None
        self.hull = None

        self.prev_shaping = None
        self.reset()

        high = np.array([np.inf]*24)
        self.action_space = spaces.Box(np.array([-1,-1,-1,-1]), np.array([+1,+1,+1,+1]))
        self.observation_space = spaces.Box(-high, high) 
开发者ID:ArztSamuel,项目名称:DRL_DeliveryDuel,代码行数:16,代码来源:bipedal_walker.py

示例8: __init__

# 需要导入模块: import Box2D [as 别名]
# 或者: from Box2D import b2World [as 别名]
def __init__(self):
        EzPickle.__init__(self)
        self.seed()
        self.contactListener_keepref = FrictionDetector(self)
        self.world = Box2D.b2World((0,0), contactListener=self.contactListener_keepref)
        self.viewer = None
        self.invisible_state_window = None
        self.invisible_video_window = None
        self.road = None
        self.car = None
        self.reward = 0.0
        self.prev_reward = 0.0

        self.action_space = spaces.Box( np.array([-1,0,0]), np.array([+1,+1,+1]), dtype=np.float32)  # steer, gas, brake
        self.observation_space = spaces.Box(low=0, high=255, shape=(STATE_H, STATE_W, 3), dtype=np.uint8) 
开发者ID:joanby,项目名称:ia-course,代码行数:17,代码来源:car_racing.py

示例9: __init__

# 需要导入模块: import Box2D [as 别名]
# 或者: from Box2D import b2World [as 别名]
def __init__(self):
        EzPickle.__init__(self)
        self.seed()
        self.viewer = None

        self.world = Box2D.b2World()
        self.terrain = None
        self.hull = None

        self.prev_shaping = None

        self.fd_polygon = fixtureDef(
                        shape = polygonShape(vertices=
                        [(0, 0),
                         (1, 0),
                         (1, -1),
                         (0, -1)]),
                        friction = FRICTION)

        self.fd_edge = fixtureDef(
                    shape = edgeShape(vertices=
                    [(0, 0),
                     (1, 1)]),
                    friction = FRICTION,
                    categoryBits=0x0001,
                )

        self.reset()

        high = np.array([np.inf]*24)
        self.action_space = spaces.Box(np.array([-1,-1,-1,-1]), np.array([+1,+1,+1,+1]))
        self.observation_space = spaces.Box(-high, high) 
开发者ID:joanby,项目名称:ia-course,代码行数:34,代码来源:bipedal_walker.py

示例10: setup

# 需要导入模块: import Box2D [as 别名]
# 或者: from Box2D import b2World [as 别名]
def setup(self):
        self.seed()
        self.viewer = None

        self.world = Box2D.b2World()
        self.terrain = None

        init_x = TERRAIN_STEP * TERRAIN_STARTPAD / 2
        init_y = TERRAIN_HEIGHT + 2 * LEG_H
        self.start_x = [
            init_x + WALKER_SEPERATION * i * TERRAIN_STEP for i in range(self.n_walkers)
        ]
        self.walkers = [
            BipedalWalker(self.world, init_x=sx, init_y=init_y, one_hot=self.one_hot)
            for sx in self.start_x
        ]

        self.package_scale = self.n_walkers / 1.75
        self.package_length = PACKAGE_LENGTH / SCALE * self.package_scale

        self.total_agents = self.n_walkers

        self.prev_shaping = np.zeros(self.n_walkers)
        self.prev_package_shaping = 0.0

        self.terrain_length = int(TERRAIN_LENGTH * self.n_walkers * 1 / 8.)

        self.reset() 
开发者ID:ermongroup,项目名称:multiagent-gail,代码行数:30,代码来源:multi_walker.py

示例11: __init__

# 需要导入模块: import Box2D [as 别名]
# 或者: from Box2D import b2World [as 别名]
def __init__(self, env_config):
        self.spec = None
        self.set_env_config(env_config)
        self.env_params = None
        self.env_seed = None
        self._seed()
        self.viewer = None

        self.world = Box2D.b2World()
        self.terrain = None
        self.hull = None

        self.prev_shaping = None
        self.fd_polygon = fixtureDef(
            shape=polygonShape(vertices=[(0, 0),
                                         (1, 0),
                                         (1, -1),
                                         (0, -1)]),
            friction=FRICTION)

        self.fd_edge = fixtureDef(
            shape=edgeShape(vertices=[(0, 0),
                                      (1, 1)]),
            friction=FRICTION,
            categoryBits=0x0001,
        )

        self._reset()

        high = np.array([np.inf] * 24)
        self.action_space = spaces.Box(
            np.array([-1, -1, -1, -1]), np.array([+1, +1, +1, +1]))
        self.observation_space = spaces.Box(-high, high) 
开发者ID:uber-research,项目名称:poet,代码行数:35,代码来源:bipedal_walker_custom.py

示例12: __init__

# 需要导入模块: import Box2D [as 别名]
# 或者: from Box2D import b2World [as 别名]
def __init__(self):
        EzPickle.__init__(self)
        self.seed()
        self.viewer = None

        self.world = Box2D.b2World()
        self.terrain = None
        self.hull = None

        self.prev_shaping = None

        self.fd_polygon = fixtureDef(
                        shape = polygonShape(vertices=
                        [(0, 0),
                         (1, 0),
                         (1, -1),
                         (0, -1)]),
                        friction = FRICTION)

        self.fd_edge = fixtureDef(
                    shape = edgeShape(vertices=
                    [(0, 0),
                     (1, 1)]),
                    friction = FRICTION,
                    categoryBits=0x0001,
                )

        self.reset()

        high = np.array([np.inf] * 24)
        self.action_space = spaces.Box(np.array([-1, -1, -1, -1]), np.array([1, 1, 1, 1]), dtype=np.float32)
        self.observation_space = spaces.Box(-high, high, dtype=np.float32) 
开发者ID:hust512,项目名称:DQN-DDPG_Stock_Trading,代码行数:34,代码来源:bipedal_walker.py


注:本文中的Box2D.b2World方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。