From 667acb88959631a81cb52567c5cea6f66efa8abe Mon Sep 17 00:00:00 2001 From: sp Date: Mon, 10 Jul 2023 14:12:18 +0200 Subject: [PATCH] added install script and simple runner --- install.sh | 14 ++++++++++++++ run_simple.py | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 install.sh create mode 100644 run_simple.py diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..de5166d --- /dev/null +++ b/install.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +# aptitude dependencies +sudo apt install python3.8-venv python3-tk +python3 -m pip install --user virtualenv +python3 -m venv env + +source env/bin/activate +which python3 + + +cd gym_minigrid/ +python3 -m pip install -e . +cd .. diff --git a/run_simple.py b/run_simple.py new file mode 100644 index 0000000..1d65e42 --- /dev/null +++ b/run_simple.py @@ -0,0 +1,37 @@ +import gym +from gym_minigrid.wrappers import RGBImgObsWrapper, ImgObsWrapper, MiniWrapper +from subprocess import call +from os import listdir, system +from os.path import isfile, join, getctime +import argparse +from gym_minigrid.policyRepairEnv import State + +def main(): + LOG("> Start Application ...") + + ################################################################# + # Parse command line arguments + parser = argparse.ArgumentParser() + parser.add_argument('--env', type=str, required=True, help='Environment (for now only "Testing-v0" possible)') + args = parser.parse_args() + + ################################################################ + # Create & Setup environment + env = gym.make(args.env, render_mode="human") + env = RGBImgObsWrapper(env) # Get pixel observations + env = ImgObsWrapper(env) # Get rid of the 'mission' field + env = MiniWrapper(env) # Project specific changes + + observation = env.reset() + print(env.printGrid(init=True)) + + LOG("> Starting MiniGrid2PRISM ...") + with open("grid", "w") as infile: + infile.write(env.printGrid(init=True)) + system("./Minigrid2PRISM/build/main -i grid -o testing.prism -v 'agent'") + LOG("> Finished Application!") + +# ........................................................................... # + +if __name__ == '__main__': + main()