Closed DamienLopez1 closed 2 years ago
You have 2 engine instances in the same script, referencing a single playground instance, which causes the issue.
Remove the 2nd engine = Engine(time_limit=10000, playground= my_playground, debug=True)
and move the engine.run
before the engine.terminate
and it'll run.
Thanks that worked! Any reason that the window is extremely tiny? the code does not seem to follow the size parameter even when full_surface=True
engine = Engine(time_limit=10000, playground=my_playground, debug=True,full_surface=True)
The window should be the size of the playground in pixels, i.e. size=(400, 400)
-> 400x400 pixels. If I change that to size=(800, 800)
then it does change the window size accordingly on my end.
my_playground = GridRooms(size=(400, 400), room_layout=(3,3), random_doorstep_position=True, doorstep_size = 60,wall_type = "light")
# we use the option screen=True to use a keyboard controlled agent later on.
engine = Engine(time_limit=10000, playground=my_playground, debug=True,full_surface=True)
#topdown_img = engine.generate_playground_image()
room_left = my_playground.grid_rooms[0][1]
doorstep = room_left.doorstep_right
door = doorstep.generate_door()
my_playground.add_element(door)
switch = OpenCloseSwitch(door=door)
position_switch = room_left.get_random_position_on_wall(wall_location='right', element=switch)
my_playground.add_element(switch, position_switch)
enemy_reward_zone = RewardZone(reward=1,limit =10,config_key = None,physical_shape = "square", texture = [123, 234, 0],size = [100,100],radius = 100)
my_playground.add_element(enemy_reward_zone, ((200, 200), 0))
candy = Candy()
my_playground.add_element(candy, ((70,70),0))
pentagon_object = Physical(config_key='circle', graspable=True, mass=1)
my_playground.add_element(pentagon_object, ((170, 30), 0.5))
my_agent = BaseAgent(controller=Keyboard(), radius=10, interactive = True)
my_playground.add_agent(my_agent)
engine.run(print_rewards = True)
#plt_image(topdown_img)
engine.terminate()
It seems to be stuck at this tiny size
Right, that's because the camera follows the agent and you don't see the whole playground in the game window. This is to avoid rendering large playgrounds and running out of memory.
You can get the whole PG image with: engine.generate_playground_image()
Thanks. Appreciate the help and feedback.
I have imported simple playgrounds into my environment and I am trying to run a simple scenario using a keyboard controlled agent.
The code for the scenario is shown below:
When running the above from command line I get the following error:
Using similar code while just cloning the simple playgrounds repository works fine.