Minetest as an experimental tool for neuroscience
Minetest as an experimental tool for neuroscience
Hi everyone
I want to use Minetest for analyse memory. It looks like a perfect environment and it's quite easy design the maps. But I need some way to export precise information about the behaviour of the Player.
My principal goal is save in a file the player's coordinates with the system timestamp (aprox 60 per second, but I can work with less). Do you know if that is possible?
Could someone give me some tip?
I want to use Minetest for analyse memory. It looks like a perfect environment and it's quite easy design the maps. But I need some way to export precise information about the behaviour of the Player.
My principal goal is save in a file the player's coordinates with the system timestamp (aprox 60 per second, but I can work with less). Do you know if that is possible?
Could someone give me some tip?
Last edited by eeMagic on Fri May 27, 2016 23:13, edited 1 time in total.
Re: Minetest as an experimental tool for neuroscience
Well, there is a function called register_globalstep. This function is called every few milliseconds from the engine
You can get the current player and his position, the system time with os.clock() and open a file to store the values
And by the way: welcome and this is an interesting project
You can get the current player and his position, the system time with os.clock() and open a file to store the values
And by the way: welcome and this is an interesting project
Re: Minetest as an experimental tool for neuroscience
Thanks!
Now I know it's possible I can keep working. I didn't check how to code it, but probably I will need a way to close the file (I can open it in init.lua). Do you remember some function called when the game is close?
Now I know it's possible I can keep working. I didn't check how to code it, but probably I will need a way to close the file (I can open it in init.lua). Do you remember some function called when the game is close?
Re: Minetest as an experimental tool for neuroscience
I would close the file after writing to prevent file corruption an case of a crash. But if you really keep it open you can use this
http://dev.minetest.net/minetest.register_on_shutdown
http://dev.minetest.net/minetest.register_on_shutdown
- rubenwardy
- Moderator
- Posts: 6978
- Joined: Tue Jun 12, 2012 18:11
- GitHub: rubenwardy
- IRC: rubenwardy
- In-game: rubenwardy
- Location: Bristol, United Kingdom
- Contact:
Re: Minetest as an experimental tool for neuroscience
The server doesn't update fast enough to be able to record at 60fps, by default it updates at 10fps.
To log at 60fps you'll need to set the server fps to 60 (dedicated_time_Step or something in minetest.conf) or edit the client source code. You'll probably end up needing to do the latter as I doubt that the server could work that fast, and that the client would even send their position that fast.
To log at 60fps you'll need to set the server fps to 60 (dedicated_time_Step or something in minetest.conf) or edit the client source code. You'll probably end up needing to do the latter as I doubt that the server could work that fast, and that the client would even send their position that fast.
Re: Minetest as an experimental tool for neuroscience
@burli: thanks. You are right, at least I will save in different files each stage.
@rubenwardy: thanks for the info. That isn't so bad, It could work fine with 10fps and a little of interpolation (without the fast privilege the movement is quite slow). In any case, I will check how to reduce the time_step.
@rubenwardy: thanks for the info. That isn't so bad, It could work fine with 10fps and a little of interpolation (without the fast privilege the movement is quite slow). In any case, I will check how to reduce the time_step.
Re: Minetest as an experimental tool for neuroscience
I tinker a bit with register_globalstep.
1. dedicated_time_step has no effect (I guess it's the wrong parameter for this)
2. in idle register_globalstep is around 30 calls per second (cps)
3. if I move cps can go up??!!
4. if I have lots of mods installed cps can go below 10 or even to 0 (no calls for one or more seconds)
1. dedicated_time_step has no effect (I guess it's the wrong parameter for this)
2. in idle register_globalstep is around 30 calls per second (cps)
3. if I move cps can go up??!!
4. if I have lots of mods installed cps can go below 10 or even to 0 (no calls for one or more seconds)
Re: Minetest as an experimental tool for neuroscience
Depending on exactly how you want to interpret your data, it might be more efficient to log key-presses and mouse movements. Interesting sounding project, I hope you'll tell us more about it.
{-| Visiting Minetest worlds and making up stories: www.codeforyendor.xyz -}
Re: Minetest as an experimental tool for neuroscience
@ptvirgo: That could be useful. But I need the coordinates because the environment should have walls... and they will break the relationship between key-press and position.
Re: Minetest as an experimental tool for neuroscience
I don't think that you really need 60 positions per second. The human reaction time is around 0.2 seconds. It you record 20 positions per second it's enough I think
Re: Minetest as an experimental tool for neuroscience
@eeMagic: Yeah, I wasn't thinking about that; no good being efficient if you cant' actually use the results..!
So are you finding what you need? How's the project coming?
So are you finding what you need? How's the project coming?
{-| Visiting Minetest worlds and making up stories: www.codeforyendor.xyz -}
Re: Minetest as an experimental tool for neuroscience
@ptvirgo: I have a lot to learn (specially about lua), but I think that minetest has all the features I need. The project is going quite slowly, first I have to show that the idea is really possible (and that requires a lot of code and time) .
Re: Minetest as an experimental tool for neuroscience
eemagic:
The code below will do what you need, click on the link to see the full source:
https://gist.github.com/sofar/e5da2a6ce ... 9b367bd7ac
Put this in worlds/<worldname>/worldmods/track/init.lua and start your world, and this will output CSV formatted time+position files for each player.
Output files are overwritten if the player reconnects.
The code below will do what you need, click on the link to see the full source:
https://gist.github.com/sofar/e5da2a6ce ... 9b367bd7ac
Put this in worlds/<worldname>/worldmods/track/init.lua and start your world, and this will output CSV formatted time+position files for each player.
Output files are overwritten if the player reconnects.
Re: Minetest as an experimental tool for neuroscience
@sofar: Thank you very much!! It works perfectly! Now I can start with the crazy stuff.
Sorry for the stupid question but... what is the difference between a worldmod and a mod?
Sorry for the stupid question but... what is the difference between a worldmod and a mod?
- rubenwardy
- Moderator
- Posts: 6978
- Joined: Tue Jun 12, 2012 18:11
- GitHub: rubenwardy
- IRC: rubenwardy
- In-game: rubenwardy
- Location: Bristol, United Kingdom
- Contact:
Re: Minetest as an experimental tool for neuroscience
There are three places a mod can be.
In a subgame like minetest game (games/minetest_game/mods/) - the mod is automatically enabled and specific to that subgame, so any world using that subgame will have that mod.
The main mods dir (mods/)- disabled by default, and world can enable amd use it.
The worldmods mod dir (worlds/worldname/worldmods/) - always enabled, mods are specific to that world.
In a subgame like minetest game (games/minetest_game/mods/) - the mod is automatically enabled and specific to that subgame, so any world using that subgame will have that mod.
The main mods dir (mods/)- disabled by default, and world can enable amd use it.
The worldmods mod dir (worlds/worldname/worldmods/) - always enabled, mods are specific to that world.
Re: Minetest as an experimental tool for neuroscience
Didn't know thatrubenwardy wrote: The worldmods mod dir (worlds/worldname/worldmods/) - always enabled, mods are specific to that world.
Re: Minetest as an experimental tool for neuroscience
Hi again,
I keep working in this project. My biggest problem now is how to add/remove a few blocks before load, I'm using
minetest.after() but I don't want to show the previous arrange of blocks.
I keep working in this project. My biggest problem now is how to add/remove a few blocks before load, I'm using
minetest.after() but I don't want to show the previous arrange of blocks.
Re: Minetest as an experimental tool for neuroscience
Is it possible use a fixed camera? or at least change the max distance of set_eye_offset() in third person?
- srifqi
- Member
- Posts: 570
- Joined: Sat Jun 28, 2014 04:31
- GitHub: srifqi
- IRC: srifqi
- In-game: srifqi
- Location: Indonesia
Re: Minetest as an experimental tool for neuroscience
I'm not sure about fixed camera. Also, if you mean "max distance" is viewing range, you can set it by pressing Numpad - or Numpad + or add this line into minetest.conf:eeMagic wrote:Is it possible use a fixed camera? or at least change the max distance of set_eye_offset() in third person?
Code: Select all
viewing_range = (insert your viewing range here, in block)
Saya dari Indonesia! · Terjemahkan Minetest! · my mods · My nickname in IPA: /es.rif.qi/
Re: Minetest as an experimental tool for neuroscience
I mean the relative position of the camera. In set_eye_offset(offset_first, offset_third), I found that after y=15, offset_third doesn't change any more.
- srifqi
- Member
- Posts: 570
- Joined: Sat Jun 28, 2014 04:31
- GitHub: srifqi
- IRC: srifqi
- In-game: srifqi
- Location: Indonesia
Re: Minetest as an experimental tool for neuroscience
Yes, it does. As stated in docs/lua_api.txt:eeMagic wrote:I mean the relative position of the camera. In set_eye_offset(offset_first, offset_third), I found that after y=15, offset_third doesn't change any more.
Code: Select all
* `set_eye_offset({x=0,y=0,z=0},{x=0,y=0,z=0})`: defines offset value for camera per player
* in first person view
* in third person view (max. values `{x=-10/10,y=-10,15,z=-5/5}`)
Saya dari Indonesia! · Terjemahkan Minetest! · my mods · My nickname in IPA: /es.rif.qi/
Re: Minetest as an experimental tool for neuroscience
Is there a way to change that maximum values?
- srifqi
- Member
- Posts: 570
- Joined: Sat Jun 28, 2014 04:31
- GitHub: srifqi
- IRC: srifqi
- In-game: srifqi
- Location: Indonesia
Re: Minetest as an experimental tool for neuroscience
You can, but you need to change engine codes. It's already hard-coded in the engine code (src/script/lua_api/l_object.cpp) to "Prevent abuse of offset values (keep player always visible)":eeMagic wrote:Is there a way to change that maximum values?
Code: Select all
// Prevent abuse of offset values (keep player always visible)
offset_third.X = rangelim(offset_third.X,-10,10);
offset_third.Z = rangelim(offset_third.Z,-5,5);
/* TODO: if possible: improve the camera colision detetion to allow Y <= -1.5) */
offset_third.Y = rangelim(offset_third.Y,-10,15); //1.5*BS
Saya dari Indonesia! · Terjemahkan Minetest! · my mods · My nickname in IPA: /es.rif.qi/
Re: Minetest as an experimental tool for neuroscience
thanks :)
I have a big problem now. I have to use an external C library to communicate with hardware. I made a dll wrapper in C for lua and it works (I tested it using luaforwindows) . But minetest crash when I try to use: require(wrappername) in the init.lua of a mod.
I'm using Minetest portable 32 bits, Visual Studio for compiling and I tested the code with luaforwindows.
am I totally confused?
is it there another way to use dlls in minetest?
I have a big problem now. I have to use an external C library to communicate with hardware. I made a dll wrapper in C for lua and it works (I tested it using luaforwindows) . But minetest crash when I try to use: require(wrappername) in the init.lua of a mod.
I'm using Minetest portable 32 bits, Visual Studio for compiling and I tested the code with luaforwindows.
am I totally confused?
is it there another way to use dlls in minetest?
Re: Minetest as an experimental tool for neuroscience
I suppose I should tell the end of this
I couldn't compile minetest in part because I wasn't able to find an easy way to add all the codes and libraries we need to send signals to the hardware. But I worked around this issue...
Using Windows, Python and pyHook, I synchronised the game and the external hardware when I press 'return' after input a command in minetest that start the navigation experiment.
I'm quite sure that it has a lot of timing error, but it works fine enough for a lot of tests.
Probably we will move to Blender, the level/game design is more complex but It hasn't the limitations of Minetest. It was fun, I learned a lot, and I will try to use Minetest to test/design others experiments. Thanks to those who helped me with all this
I couldn't compile minetest in part because I wasn't able to find an easy way to add all the codes and libraries we need to send signals to the hardware. But I worked around this issue...
Using Windows, Python and pyHook, I synchronised the game and the external hardware when I press 'return' after input a command in minetest that start the navigation experiment.
I'm quite sure that it has a lot of timing error, but it works fine enough for a lot of tests.
Probably we will move to Blender, the level/game design is more complex but It hasn't the limitations of Minetest. It was fun, I learned a lot, and I will try to use Minetest to test/design others experiments. Thanks to those who helped me with all this
Who is online
Users browsing this forum: No registered users and 7 guests