test obs is image
@@ -21,6 +21,7 @@ import malmoenv
import argparse
from pathlib import Path
import time
+from PIL import Image
if __name__ == '__main__':
@@ -33,6 +34,7 @@ if __name__ == '__main__':
parser.add_argument('--episode', type=int, default=0, help='the start episode - default is 0')
parser.add_argument('--role', type=int, default=0, help='the agent role - defaults to 0')
parser.add_argument('--episodemaxsteps', type=int, default=0, help='max number of steps per episode')
+ parser.add_argument('--saveimagesteps', type=int, default=0, help='save an image every N steps')
parser.add_argument('--resync', type=int, default=0, help='exit and re-sync on every N - default 0 meaning never')
parser.add_argument('--experimentUniqueId', type=str, default='test1',
help="the experiment's unique id. Generated if not specified")
@@ -58,6 +60,12 @@ if __name__ == '__main__':
print("reward: " + str(reward))
print("done: " + str(done))
print("obs: " + str(obs))
+ # print("info" + info)
+ if args.saveimagesteps > 0 and steps % args.saveimagesteps == 0:
+ w, h = env.observation_space.shape
+ img = Image.fromarray(obs.reshape(h, w, 3))
+ img.save('image' + args.role + '_' + str(steps) + '.png')
+
# time.sleep(3)
time.sleep(.05)
