Minetest as an experimental tool for neuroscience

eeMagic
Member
 
Posts: 11
Joined: Wed May 25, 2016 15:59
GitHub: ferchaure

Minetest as an experimental tool for neuroscience

by eeMagic » Wed May 25, 2016 17:18

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?
Last edited by eeMagic on Fri May 27, 2016 23:13, edited 1 time in total.
 

User avatar
burli
Member
 
Posts: 1313
Joined: Fri Apr 10, 2015 13:18

Re: Minetest as an experimental tool for neuroscience

by burli » Wed May 25, 2016 17:28

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
 

eeMagic
Member
 
Posts: 11
Joined: Wed May 25, 2016 15:59
GitHub: ferchaure

Re: Minetest as an experimental tool for neuroscience

by eeMagic » Thu May 26, 2016 10:34

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?
 

User avatar
burli
Member
 
Posts: 1313
Joined: Fri Apr 10, 2015 13:18

Re: Minetest as an experimental tool for neuroscience

by burli » Thu May 26, 2016 10:43

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
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Re: Minetest as an experimental tool for neuroscience

by rubenwardy » Thu May 26, 2016 12:15

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.
 

eeMagic
Member
 
Posts: 11
Joined: Wed May 25, 2016 15:59
GitHub: ferchaure

Re: Minetest as an experimental tool for neuroscience

by eeMagic » Thu May 26, 2016 15:15

@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.
 

User avatar
burli
Member
 
Posts: 1313
Joined: Fri Apr 10, 2015 13:18

Re: Minetest as an experimental tool for neuroscience

by burli » Thu May 26, 2016 15:42

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)
 

ptvirgo
Member
 
Posts: 18
Joined: Thu May 26, 2016 22:18
GitHub: ptvirgo

Re: Minetest as an experimental tool for neuroscience

by ptvirgo » Thu May 26, 2016 22:25

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.
 

eeMagic
Member
 
Posts: 11
Joined: Wed May 25, 2016 15:59
GitHub: ferchaure

Re: Minetest as an experimental tool for neuroscience

by eeMagic » Fri May 27, 2016 13:43

@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.
 

User avatar
burli
Member
 
Posts: 1313
Joined: Fri Apr 10, 2015 13:18

Re: Minetest as an experimental tool for neuroscience

by burli » Fri May 27, 2016 14:19

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
 

ptvirgo
Member
 
Posts: 18
Joined: Thu May 26, 2016 22:18
GitHub: ptvirgo

Re: Minetest as an experimental tool for neuroscience

by ptvirgo » Fri May 27, 2016 21:17

@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?
 

eeMagic
Member
 
Posts: 11
Joined: Wed May 25, 2016 15:59
GitHub: ferchaure

Re: Minetest as an experimental tool for neuroscience

by eeMagic » Fri May 27, 2016 23:20

@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) .
 

sofar
Member
 
Posts: 781
Joined: Fri Jan 16, 2015 07:31
GitHub: sofar
IRC: sofar
In-game: sofar

Re: Minetest as an experimental tool for neuroscience

by sofar » Sat May 28, 2016 01:12

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.
 

eeMagic
Member
 
Posts: 11
Joined: Wed May 25, 2016 15:59
GitHub: ferchaure

Re: Minetest as an experimental tool for neuroscience

by eeMagic » Sat May 28, 2016 11:37

@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?
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Re: Minetest as an experimental tool for neuroscience

by rubenwardy » Sat May 28, 2016 11:42

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.
 

User avatar
burli
Member
 
Posts: 1313
Joined: Fri Apr 10, 2015 13:18

Re: Minetest as an experimental tool for neuroscience

by burli » Sat May 28, 2016 13:21

rubenwardy wrote:The worldmods mod dir (worlds/worldname/worldmods/) - always enabled, mods are specific to that world.

Didn't know that
 

eeMagic
Member
 
Posts: 11
Joined: Wed May 25, 2016 15:59
GitHub: ferchaure

Re: Minetest as an experimental tool for neuroscience

by eeMagic » Tue Jun 21, 2016 11:46

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.
 

eeMagic
Member
 
Posts: 11
Joined: Wed May 25, 2016 15:59
GitHub: ferchaure

Re: Minetest as an experimental tool for neuroscience

by eeMagic » Tue Jun 28, 2016 17:38

Is it possible use a fixed camera? or at least change the max distance of set_eye_offset() in third person?
 

User avatar
srifqi
Member
 
Posts: 508
Joined: Sat Jun 28, 2014 04:31
GitHub: srifqi
IRC: srifqi
In-game: srifqi

Re: Minetest as an experimental tool for neuroscience

by srifqi » Wed Jun 29, 2016 09:13

eeMagic wrote:Is it possible use a fixed camera? or at least change the max distance of set_eye_offset() in third person?

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:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
viewing_range = (insert your viewing range here, in block)
I'm from Indonesia! Saya dari Indonesia!
Terjemahkan Minetest!
Mods by me. Modifikasi oleh saya.

Pronounce my nick as in: es-rifqi (IPA: /es rifˈki/)
 

eeMagic
Member
 
Posts: 11
Joined: Wed May 25, 2016 15:59
GitHub: ferchaure

Re: Minetest as an experimental tool for neuroscience

by eeMagic » Wed Jun 29, 2016 10:15

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.
 

User avatar
srifqi
Member
 
Posts: 508
Joined: Sat Jun 28, 2014 04:31
GitHub: srifqi
IRC: srifqi
In-game: srifqi

Re: Minetest as an experimental tool for neuroscience

by srifqi » Thu Jun 30, 2016 15:17

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.

Yes, it does. As stated in docs/lua_api.txt:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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}`)
I'm from Indonesia! Saya dari Indonesia!
Terjemahkan Minetest!
Mods by me. Modifikasi oleh saya.

Pronounce my nick as in: es-rifqi (IPA: /es rifˈki/)
 

eeMagic
Member
 
Posts: 11
Joined: Wed May 25, 2016 15:59
GitHub: ferchaure

Re: Minetest as an experimental tool for neuroscience

by eeMagic » Sat Jul 16, 2016 15:35

Is there a way to change that maximum values?
 

User avatar
srifqi
Member
 
Posts: 508
Joined: Sat Jun 28, 2014 04:31
GitHub: srifqi
IRC: srifqi
In-game: srifqi

Re: Minetest as an experimental tool for neuroscience

by srifqi » Sun Jul 17, 2016 16:20

eeMagic wrote:Is there a way to change that maximum values?

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)":
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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

Remove those lines above in source code and compile.
I'm from Indonesia! Saya dari Indonesia!
Terjemahkan Minetest!
Mods by me. Modifikasi oleh saya.

Pronounce my nick as in: es-rifqi (IPA: /es rifˈki/)
 

eeMagic
Member
 
Posts: 11
Joined: Wed May 25, 2016 15:59
GitHub: ferchaure

Re: Minetest as an experimental tool for neuroscience

by eeMagic » Sun Jul 24, 2016 16:15

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?
 


Return to Minetest-Related

Who is online

Users browsing this forum: No registered users and 31 guests

cron