Skip to content

Commit

Permalink
feat: add scripts/example.py
Browse files Browse the repository at this point in the history
Signed-off-by: Thiago P. Bueno <thiago.pbueno@gmail.com>
  • Loading branch information
thiagopbueno committed Sep 14, 2020
1 parent d91644a commit a1b0829
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions scripts/example.py
@@ -0,0 +1,20 @@
import rddlgym

from tfrddlsim.policy import RandomPolicy
from tfrddlsim.simulation.policy_simulator import PolicySimulator
from tfrddlsim.viz import GenericVisualizer

# parse and compile RDDL
compiler = rddlgym.make('Reservoir-8', mode=rddlgym.SCG)
compiler.init()

# run simulations
horizon = 40
batch_size = 128
policy = RandomPolicy(compiler, batch_size)
simulator = PolicySimulator(compiler, policy, batch_size)
trajectories = simulator.run(horizon)

# visualize trajectories
viz = GenericVisualizer(compiler, verbose=True)
viz.render(trajectories)

0 comments on commit a1b0829

Please sign in to comment.