-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathexperiment.lua
More file actions
31 lines (25 loc) · 749 Bytes
/
Copy pathexperiment.lua
File metadata and controls
31 lines (25 loc) · 749 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
local Catch = require 'rlenvs.Catch'
-- Initialise and start environment
local env = Catch({level = 2, render = true, zoom = 10})
local actionSpace = env:getActionSpace()
local observation = env:start()
local reward, terminal = 0, false
local episodes, totalReward = 0, 0
local nEpisodes = 1000
-- Display
env:render()
for i = 1, nEpisodes do
while not terminal do
-- Pick random action and execute it
local action = torch.random(0, actionSpace['n'] - 1)
reward, observation, terminal = env:step(action)
totalReward = totalReward + reward
-- Display
env:render()
end
episodes = episodes + 1
observation = env:start()
terminal = false
end
print('Episodes: ' .. episodes)
print('Total Reward: ' .. totalReward)