Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify envs to be compatible with twrl #8

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
70eb229
Modified specs to follow gym API
Oct 1, 2016
a56188c
Update function names
Oct 2, 2016
1fe33fa
Experiment uses new specs
Oct 2, 2016
522b8a4
Changed function calls to getters
Oct 2, 2016
9e92921
table with all rlenv envs
Oct 19, 2016
1c276f2
Update function calls, added new steps method, updated README
Oct 21, 2016
63cf6db
Added timestep limits, exposed start function added _start function t…
Oct 24, 2016
c20c8b8
Added render
Oct 24, 2016
a9ea21e
Added zoom option
Oct 26, 2016
430a2b4
Added zoom variable to experiment
Oct 26, 2016
358a8c7
fixed variable name
Oct 26, 2016
135bf69
Modified specs to follow gym API
Oct 1, 2016
2afdffe
Update function names
Oct 2, 2016
0e3b561
Experiment uses new specs
Oct 2, 2016
3a39f0c
Changed function calls to getters
Oct 2, 2016
834c837
table with all rlenv envs
Oct 19, 2016
b6f086b
Update function calls, added new steps method, updated README
Oct 21, 2016
2319531
Added timestep limits, exposed start function added _start function t…
Oct 24, 2016
b02b760
Added render
Oct 24, 2016
68f773e
Added zoom option
Oct 26, 2016
0f86433
Added zoom variable to experiment
Oct 26, 2016
904f747
fixed variable name
Oct 26, 2016
922f10d
Merge remote-tracking branch 'origin/twrl' into twrl
Nov 9, 2016
c1f3b16
Modified XOWorld to new api standards
Nov 9, 2016
9114305
1 channel for XOWorld
Nov 9, 2016
796bc58
Added super call
Nov 9, 2016
eb8ea9b
Merge branch 'master' into twrl
Nov 9, 2016
52ad76d
Added base tests
Nov 14, 2016
1096f31
Merge remote-tracking branch 'origin/master' into twrl
Nov 14, 2016
59da7cd
Modified Minecraft functions to support api
Nov 17, 2016
2d23ed7
Exclude minecraft from tests
Nov 17, 2016
55f90eb
Added assertions to tests
Nov 25, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions experiment.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
local image = require 'image'
require 'rlenvs'
local Catch = require('rlenvs.Catch')
-- Detect QT for image display
local qt = pcall(require, 'qt')

-- Initialise and start environment
local env = Catch({level = 2})
local env = Catch({level = 2, render = true})
local getActionSpace = env:getActionSpace()
local observation = env:start()

Expand All @@ -14,7 +11,7 @@ local episodes, totalReward = 0, 0
local nEpisodes = 1000

-- Display
local window = qt and image.display({image=observation, zoom=10})
env:render()

for i = 1, nEpisodes do
while not terminal do
Expand All @@ -24,9 +21,7 @@ for i = 1, nEpisodes do
totalReward = totalReward + reward

-- Display
if qt then
image.display({image=observation, zoom=10, win=window})
end
env:render()
end

episodes = episodes + 1
Expand Down
14 changes: 13 additions & 1 deletion rlenvs/Env.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ function Env:_init(opts)
else
self.maxSteps = 1000
end
if opts.render then
require 'image' self.qt = pcall(require, 'qt')
if not self.qt then print('Was not able to load qt to render, are you using qlua to run the script?') end
end
self.currentStep = 1
end

Expand All @@ -34,7 +38,15 @@ end

function Env:start()
self.currentStep = 1
return self:_start()
local obs = self:_start()
return obs
end

function Env:render()
if self.qt and self.getDisplay then
self.window = self.window == nil and image.display({ image = self:getDisplay(), zoom = 10 }) or self.window
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

zoom should be part of opts and handled by Env - 10 was hard-coded for Catch, but the default of 1 is appropriate for Atari.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall I set the default to 10 for Catch or leave this exposed for the user as well?

image.display({ image = self:getDisplay(), zoom = 10, win = self.window })
end
end

return Env