alpaca/alpacka/agents/stochastic_mcts_test.py
def make_one_level_binary_tree(
    left_value, right_value, left_reward=0, right_reward=0
):
    """Makes a TabularEnv and rate_new_leaves_fn for a 1-level binary tree."""
    # 0, action 0 -> 1 (left)
    # 0, action 1 -> 2 (right)
    (root_state, left_state, right_state) = (0, 1, 2)
    env = testing.TabularEnv(
        init_state=root_state,
        n_actions=2,
        transitions={
            # state: {action: (state', reward, done)}
            root_state: {
                0: (left_state, left_reward, False),
                1: (right_state, right_reward, False),
            },
            # Dummy terminal states, made so we can expand left and right.
            left_state: {0: (3, 0, True), 1: (4, 0, True)},
            right_state: {0: (5, 0, True), 1: (6, 0, True)},
        }
    )
    rate_new_leaves_fn = functools.partial(
        rate_new_leaves_tabular,
        state_values={
            root_state: 0,
            left_state: left_value,
            right_state: right_value,
            # Dummy terminal states.
            3: 0, 4: 0, 5: 0, 6: 0,
        },
    )
    return (env, rate_new_leaves_fn)
Makes a TabularEnv and rate_new_leaves_fn for a 1-level binary tree.
Makes a TabularEnv and rate_new_leaves_fn for a 1-level binary tree.
Makes a TabularEnv and rate_new_leaves_fn for a 1 - level binary tree .
def make_one_level_binary_tree(
    left_value, right_value, left_reward=0, right_reward=0
):
    (root_state, left_state, right_state) = (0, 1, 2)
    env = testing.TabularEnv(
        init_state=root_state,
        n_actions=2,
        transitions={
            root_state: {
                0: (left_state, left_reward, False),
                1: (right_state, right_reward, False),
            },
            left_state: {0: (3, 0, True), 1: (4, 0, True)},
            right_state: {0: (5, 0, True), 1: (6, 0, True)},
        }
    )
    rate_new_leaves_fn = functools.partial(
        rate_new_leaves_tabular,
        state_values={
            root_state: 0,
            left_state: left_value,
            right_state: right_value,
            3: 0, 4: 0, 5: 0, 6: 0,
        },
    )
    return (env, rate_new_leaves_fn)
def make_one_level_binary_tree ( left_value , right_value , left_reward = 0 , right_reward = 0 ) : ( root_state , left_state , right_state ) = ( 0 , 1 , 2 ) env = testing . TabularEnv ( init_state = root_state , n_actions = 2 , transitions = { root_state : { 0 : ( left_state , left_reward , False ) , 1 : ( right_state , right_reward , False ) , } , left_state : { 0 : ( 3 , 0 , True ) , 1 : ( 4 , 0 , True ) } , right_state : { 0 : ( 5 , 0 , True ) , 1 : ( 6 , 0 , True ) } , } ) rate_new_leaves_fn = functools . partial ( rate_new_leaves_tabular , state_values = { root_state : 0 , left_state : left_value , right_state : right_value , 3 : 0 , 4 : 0 , 5 : 0 , 6 : 0 , } , ) return ( env , rate_new_leaves_fn )
Makes a TabularEnv and rate_new_leaves_fn for a 1-level binary tree.
Makes a TabularEnv and rate_new_leaves_fn for a 1 - level binary tree .
"""Makes a TabularEnv and rate_new_leaves_fn for a 1-level binary tree.""" # 0, action 0 -> 1 (left) # 0, action 1 -> 2 (right) # state: {action: (state', reward, done)} # Dummy terminal states, made so we can expand left and right. # Dummy terminal states.
left_value
right_value
left_reward
right_reward