コード例 #1
0
    def build(self):
        testenv = Environment2D()

        # Add a shape to the 2D space.
        testenv.add_shapes(
            Line(np.asarray([-1, 0]), np.asarray([1, 0]),
                 np.asarray([1, 0, 0, 1])))
        # Set the agent's position to right of the circle.
        testenv.set_position(np.asarray([0.0, 2.0]))
        # Set rotation quanta in degrees.
        testenv.set_rot_amount(30)
        # Set the Forward and Right directions for the agent.
        testenv.set_directions(np.asarray([0.0, -1.0]), np.asarray([1.0, 0.0]))
        # Set the movement amount to 0.1 units per action.
        testenv.set_move_amount(0.4)

        return testenv
コード例 #2
0
    W = obs.shape[2];

    # Convert the rest
    # TxNxC
    obs = obs.transpose([1, 0, 2, 3]).reshape([obs.shape[1], obs.shape[0] * obs.shape[2], obs.shape[3]])

    # TxNxA
    acs = np.tile(acs.transpose([1, 0, 2]).reshape([acs.shape[1], acs.shape[0], 1, acs.shape[2]]), [1, 1, W, 1]) \
        .reshape([acs.shape[1], acs.shape[0] * W, acs.shape[2]])

    # TxNxS
    states = np.tile(states.transpose([1, 0, 2]).reshape([states.shape[1], states.shape[0], 1, states.shape[2]]), [1, 1, W, 1]) \
        .reshape([states.shape[1], states.shape[0] * W, states.shape[2]])
    return uvs, obs, acs, states

testenv = Environment2D()

# Add a shape to the 2D space.
testenv.add_shapes( Line( np.asarray([-1,0]), np.asarray([1,0]), np.asarray([1,0,0,1])) )
# Set the agent's position to right of the circle.
testenv.set_position( np.asarray([0.0,2.0]) )
# Set rotation quanta in degrees.
testenv.set_rot_amount( 30 )
# Set the Forward and Right directions for the agent.
testenv.set_directions( np.asarray([0.0,-1.0]), np.asarray([1.0,0.0]) )
# Set the movement amount to 0.1 units per action.
testenv.set_move_amount( 0.4 )

#outputss = sample_lines( testenv )
outputss = sample_paths( testenv )