You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.5 KiB

  1. import gym
  2. from gym_minigrid.wrappers import RGBImgObsWrapper, ImgObsWrapper, MiniWrapper
  3. from subprocess import call
  4. from os import listdir, system
  5. from os.path import isfile, join, getctime
  6. import argparse
  7. from gym_minigrid.policyRepairEnv import State
  8. LOG_MODE = True
  9. # ........................................................................... #
  10. def LOG(text : str) -> None:
  11. if (LOG_MODE):
  12. print(text)
  13. def main():
  14. LOG("> Start Application ...")
  15. #################################################################
  16. # Parse command line arguments
  17. parser = argparse.ArgumentParser()
  18. parser.add_argument('--env', type=str, required=True, help='Environment (for now only "Testing-v0" possible)')
  19. args = parser.parse_args()
  20. ################################################################
  21. # Create & Setup environment
  22. env = gym.make(args.env, render_mode="human")
  23. env = RGBImgObsWrapper(env) # Get pixel observations
  24. env = ImgObsWrapper(env) # Get rid of the 'mission' field
  25. env = MiniWrapper(env) # Project specific changes
  26. observation = env.reset()
  27. print(env.printGrid(init=True))
  28. LOG("> Starting MiniGrid2PRISM ...")
  29. with open("grid", "w") as infile:
  30. infile.write(env.printGrid(init=True))
  31. system("./Minigrid2PRISM/build/main -i grid -o testing.prism -v 'agent'")
  32. LOG("> Finished Application!")
  33. # ........................................................................... #
  34. if __name__ == '__main__':
  35. main()