INNER CODE UNIT · Python

on_calculate

rlcode/reinforcement-learning · 1-grid-world/2-value_iteration.py:64

    def on_calculate():
        value_iteration.value_iteration()
        display.show_values(value_iteration.value_table)

    def on_print_policy():
        # Build a policy arrow table from the greedy actions implied by V.
        policy = [[[0.0] * 4 for _ in range(env.width)] for _ in range(env.height)]
        for state in env.get_all_states():
            x, y = state
            actions = value_iteration.get_action(state)
            if not actions:
                continue
            prob = 1.0 / len(actions)
            for a in actions:
                policy[x][y][a] = prob
        display.show_arrows(policy)

    def on_move():

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…