google-deepmind / lab

A customisable 3D platform for agent-based AI research

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to update current position using Triggers:update(currentPosition)

jafphd opened this issue · comments

Hi, I found a problem when trying to update the current position of the agent using this:

local PositionTrigger = require 'common.position_trigger'
myTriggers = PositionTrigger.new()
myTriggers:update(currentPosition)

If currentPosition is, for example, equal to {0, 0} (I mean, manually placing any two values and in this way creating an explicit table), then there is not any problem. However, if I try to create a table as {tonumber(cp(1)), tonumber(cp(2))} with cp = tensor.DoubleTensor(game:playerInfo().pos), then I get this error error message:

[deepmind/engine/context.cc:843] Check failed: result.ok()[hasEpisodeFinished] - [deepmind.lab.LuaMazeGeneration.fromWorldPos] - [fromWorldPos] - Must provide x, y

I still do not know how to solve this issue and why both ways to create a table are different. I would appreciate if you can let me know how to solve this problem. Thank you in advance!

I think I solved it after a lot of researching about LUA programming. I am going to describe the solution in case it is useful for someonelse. I found useful this information: https://github.com/deepmind/lab/blob/master/docs/developers/reference/tensor.md

The code must be changed to the following one:

local PositionTrigger = require 'common.position_trigger'
myTriggers = PositionTrigger.new()
p= game:playerInfo().pos
currentPosition = {p[1], p[2]}
myTriggers:update(currentPosition)