I am very new to Lua, so pardon for the retarded question.
Following this tutorial I am trying to import DeepMind dqn
into an iTorch notebook.
I have cloned this repo that contains a folder called dqn
where the source code lives.
I have added the path to the dqn
folder
package.path = package.path .. ";/path/to/dqn/?.lua"
When I try to do
require 'dqn'
I obtain an (expected) error, since there is no file called dqn.lua
in the folder. The source code of such module is, in fact, contained in the file NeuralQLearner.lua
.
I have seen the documentation that hints at the problem between file and package name.
So my question is: how can I import this module correctly? How can I let Lua know that dqn
it should actually look for NeuralQLearner.lua
(without hardcoding into the path I guess)?
The trick is in:
if not dqn then
require 'initenv'
end
put in every file. The initenv
file will then define what dqn
is supposed to mean. Once the path to initenv
is package.path
, this seems a nice trick to overcome the limitation.