本文整理汇总了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()
示例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()
示例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()
示例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
示例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)
示例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)
示例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)
示例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)
示例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)
示例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()
示例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)
示例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)