Research on leadership in animal groups involving STK

Research on leadership in animal groups involving STK

Postby kiskoul » 23 Mar 2012, 16:55

Hi there
I am a new user to this forum. I've introduced myself in the "Introduce yourself" topic (just as a note: this post is not a joke at all).

[tl;dr] I am seeking the help of a STK developer to create a script so I can run many games on various tracks and extract the position of players as well as their ranking from the simulations.

I am working on a research project on the quantification and study of leadership in animal groups. I have developed an algorithm to measure graded leadership and progression order in groups of foraging animals. A small but important part of the project involves the testing of this algorithm against simulation data. Because we don't have "control" data sets on groups of moving animals in which the rank of the animals is known precisely, I have thought of using simulations from a racing game and compare the dynamical rankings calculated by the software with the output of my algorithm. If you are interested (although I'm not looking to orientate this topic towards a discussion of the methods), here is a more scientific description of the project, whose first results are to be presented at a conference in the summer: http://db.tt/7zZI4ESk (PDF, 188KB; Fig. 1 and the "spatial leadership method" refer to the subject of this topic).

I am asking for some help from the community to help me generate relevant game data to test the algorithm. I don't think this should take more than a couple of hours to the project's developers, and it would be hugely helpful as doing it myself would be a lot longer and as I don't know the project I wouldn't be sure of doing the things properly. In return, you'll have of course my eternal gratitude :), and I anticipate that the use of a video game to investigate a topical scientific issue may attract some media attention when the article will come out, which (I guess) can only be beneficial to the project. Of course, the community and especially the developers involved will be gratefully acknowledged in whatever scientific output (talks and papers) that is to come out of this project.

Here's what I would need:

- a script to launch a game of STK with a configuration file (or just as arguments) containing the name of the track, the number of players, some options (weapons activated/deactivated is something I can think of right off the bat)

Here are the modifications to bring to the game:

- the game should be able to run on its own, without a human player
- the position (x,y,maybe z) of the players, as well as the current rankings, should be stored at regular intervals (e.g. once per second) in a text file or whatever format that's easy to parse.
- if possible, during a simulation the group (e.g., all the players) should stay relatively cohesive, because all players are supposed to be moving collectively. So it doesn't work if the first and last players are more than, say, a third of a track lap apart.

I would also need to know the following:

- how is the progression order calculated in STK? I'm guessing there's a line/spline running along the track and the positions of the players are projected onto it, is that more or less accurate?

I've installed STK 0.7 on Kubuntu 10.04. I have tried the track "Around the Lighthouse", which is simple but still tortuous enough to be an interesting testbed for the algorithm. We could start with that.

Anyone interested? Again, this is a serious research project funded by a well-known university, not a prank I'm playing on you.

I'm very much looking forward to your reaction.

Cheers
kiskoul
kiskoul
 
Posts: 8
Joined: 23 Mar 2012, 16:06

Re: Research on leadership in animal groups involving STK

Postby Auria » 24 Mar 2012, 01:21

Hi,

thanks for your interest. First of all let me say that I really really don't understand how STK is supposed to help you in your research project ^^ Now unfortunately my own free time tends towards zero so I would not be able to help significantly, tough I would be happy to point in the right direction


- a script to launch a game of STK with a configuration file (or just as arguments) containing the name of the track, the number of players, some options (weapons activated/deactivated is something I can think of right off the bat)

Here are the modifications to bring to the game:

- the game should be able to run on its own, without a human player

I believe those 2 options already exist :) running 'supertuxkart --help' on a terminal should give you quite a bit of these flags. I also believe the 'profiling' mode enables STK to run without human intervention AND store the results in a file (Joerg knows about this mode more than I do though so he be more specific than me)

[code]
- if possible, during a simulation the group (e.g., all the players) should stay relatively cohesive, because all players are supposed to be moving collectively. So it doesn't work if the first and last players are more than, say, a third of a track lap apart.


If I understand correctly this is the main part where your algorithm should be implemented? The files to look at would be /src/karts/controller/default_ai_controller. If all you want is to increase cohesion a little, it shouldn't be very difficult to modify the AI to make a kart slow down when the others are too far behind
Image
User avatar
Auria
STK Moderator
 
Posts: 2976
Joined: 07 Dec 2009, 03:52

Re: Research on leadership in animal groups involving STK

Postby hiker » 24 Mar 2012, 11:40

kiskoul {l Wrote}:- a script to launch a game of STK with a configuration file (or just as arguments) containing the name of the track, the number of players, some options (weapons activated/deactivated is something I can think of right off the bat)

That's already possible, e.g. a simple script I used to do some automatic profiling:
{l Code}: {l Select All Code}
#!/bin/bash
set -x
#for track in data/tracks/*/track.xml; do
for track in data/tracks/canyon/track.xml;  do
    a=${track%%/track.xml};
    trackname=${a##data/tracks/};
   # Skip arenas and test tracks
    if [ $trackname == "cave"       ]; then continue; fi
    if [ $trackname == "emc2"       ]; then continue; fi
    if [ $trackname == "beachtrack" ]; then continue; fi
    if [ $trackname == "test"       ]; then continue; fi
    if [ $trackname == "stadium"    ]; then continue; fi
    for kartname in mozilla; do
        for numkarts in 4 ; do
            ./src/supertuxkart --track $trackname -k $numkarts --kart $kartname --mode 3 --profile=120 -N >>stdout.$trackname.$kartname$numkarts
            gprof  src/supertuxkart gmon.out >profile.$trackname.$kartname$numkarts
            mv gmon.out gmon.out.$trackname.$kartname$numkarts
        done
    done
done

That should give you an idea about the parameters, except: mode 3 is hardest difficulty, profile=120 means play for 120 seconds (that should work for 0.7, though I am not entirely sure, I have removed those parameters to --profile-laps= or --profile-time=). I admit I haven't used that script for a while, but all the things you want (afaik) can be specified.
Here are the modifications to bring to the game:

- the game should be able to run on its own, without a human player

Already possible, see above.
- the position (x,y,maybe z) of the players, as well as the current rankings, should be stored at regular intervals (e.g. once per second) in a text file or whatever format that's easy to parse.

STK supports so called history files, which stores the time, position, rotation, and controller input at each frame in a simple text file. Just add a call to 'history->Save()' to enterRaceOverState of ProfileWorld. Adding the current kart position to the history save file should be trivial.

- if possible, during a simulation the group (e.g., all the players) should stay relatively cohesive, because all players are supposed to be moving collectively. So it doesn't work if the first and last players are more than, say, a third of a track lap apart.

See auria's answer.

I would also need to know the following:

- how is the progression order calculated in STK? I'm guessing there's a line/spline running along the track and the positions of the players are projected onto it, is that more or less accurate?

Correct. Each kart has a 'distance along track', which is the kart position projected on a curve, which is basically a piecewise linear function.
...

Anyone interested? Again, this is a serious research project funded by a well-known university, not a prank I'm playing on you.

I'm very much looking forward to your reaction.

Sorry, I don't have time for that, but am happy to provide pointers for you to implement things. It should be reasonable straight forward.

Cheers,
Joerg
hiker
 
Posts: 1435
Joined: 07 Dec 2009, 12:15
Location: Melbourne, Australia

Re: Research on leadership in animal groups involving STK

Postby kiskoul » 25 Mar 2012, 14:47

That's brilliant! Even simpler than I thought it would be. Thanks for your answers. I'm going to work on it and I'll come back here to report on my results/problems encountered.
Cheers
kiskoul
 
Posts: 8
Joined: 23 Mar 2012, 16:06

Re: Research on leadership in animal groups involving STK

Postby kiskoul » 26 Mar 2012, 16:15

Alright, I've made some progress. I was on 0.7 and it wasn't very fast and Joerg's profiling options didn't work, so I figured out I would build 0.7.3 on Lucid. I checked out and built Irrlicht 1.8.0-alpha from the SVN. Maybe due to this being an alpha release different from 1.7.3, there are some graphical issues: as far as I can see, all tracks but olivermath (I tried at least 6-7) cause the GPU to hang (kernel panic) when using the OpenGL renderer. Starting in software rendering mode seems to make it work on all tracks, even though the display is then unreadable. Maybe using Irrlicht 1.7.3 would solve all this. But at least the no-graphics option works flawlessly, so for me that should do it. Additionally, whenever the program stops (for example when asking for a track or kart list) it returns a segmentation fault.

I've added a History->Save() to ProfileWorld and removed unnecessary exports so that now it only outputs X, Y, and Z. I think I'll manage to export the rank of players by using getLocalPlayerGPRank (but does it work only with local players, or also AI-controlled karts?). The main problem now is that the setNumLocalPlayers(0) of ProfileWorld does not seem to have any effect: the headers of history.dat always contain "numplayers: 1" and when I use graphics I see that the kart on which the camera is focused is a human-controlled one, which does not move if no buttons are pressed. Any idea as to the origin of this behaviour?

Cheers
kiskoul
 
Posts: 8
Joined: 23 Mar 2012, 16:06

Re: Research on leadership in animal groups involving STK

Postby Auria » 27 Mar 2012, 16:39

Regarding kernel panics, this is definitely not normal. I suggest checking that you use the best drivers available for your system and GPU, they are usually the culprits - and unfortunately there is essentially nothing we can do about driver issues, sorry
You could try going in options and disabling render features, this may help your GPU/driver
Image
User avatar
Auria
STK Moderator
 
Posts: 2976
Joined: 07 Dec 2009, 03:52

Re: Research on leadership in animal groups involving STK

Postby kiskoul » 27 Mar 2012, 16:51

Thanks -- but that's only a minor issue, since I am going to run the simulations in the no-graphics mode. What is more important is for the profiling mode (with no human players) to work, since otherwise when I specify profile-laps=1 the simulation never completes as the human player is also expected to participate in the race. Any idea as to where this problem comes from? You could try to run the game in profiling mode and see if for you also the setNumLocalPlayers(0) of ProfileWorld has no effect.
kiskoul
 
Posts: 8
Joined: 23 Mar 2012, 16:06

Re: Research on leadership in animal groups involving STK

Postby hiker » 28 Mar 2012, 05:44

kiskoul {l Wrote}:Alright, I've made some progress. I was on 0.7 and it wasn't very fast and Joerg's profiling options didn't work, so I figured out I would build 0.7.3 on Lucid. I checked out and built Irrlicht 1.8.0-alpha from the SVN. Maybe due to this being an alpha release different from 1.7.3, there are some graphical issues: as far as I can see, all tracks but olivermath (I tried at least 6-7) cause the GPU to hang (kernel panic) when using the OpenGL renderer. Starting in software rendering mode seems to make it work on all tracks, even though the display is then unreadable. Maybe using Irrlicht 1.7.3 would solve all this. But at least the no-graphics option works flawlessly, so for me that should do it. Additionally, whenever the program stops (for example when asking for a track or kart list) it returns a segmentation fault.

This sounds indeed (as auria said) like a problem with your graphics driver. I assume that irrlicht 1.8.0-alpha is exactly the version STK needs (a newer version wouldn't compile).

I've added a History->Save() to ProfileWorld and removed unnecessary exports so that now it only outputs X, Y, and Z. I think I'll manage to export the rank of players by using getLocalPlayerGPRank (but does it work only with local players, or also AI-controlled karts?).

No, that's the rank within the GP, not the rank within a race. To get the position in the current race, call kart->getPosition().

The main problem now is that the setNumLocalPlayers(0) of ProfileWorld does not seem to have any effect: the headers of history.dat always contain "numplayers: 1" and when I use graphics I see that the kart on which the camera is focused is a human-controlled one, which does not move if no buttons are pressed. Any idea as to the origin of this behaviour?

I haven't added the call to save, but basically profile mode works with 0.7.3 for me. I use:
{l Code}: {l Select All Code}
./supertuxkart --track lighthouse -k 4 --kart nolok --mode 3 --profile-time=10 --no-graphics

for a 10 second race, or
{l Code}: {l Select All Code}
./supertuxkart --track lighthouse -k 4 --kart nolok --mode 3 --profile-laps=1 --no-graphics

for one lap. And this with or without the -no-graphics option. It is possible that history would contain numplayers: 1 (since there is one camera), but that shouldn't matter, the number of karts is correct.

Can you first try this with a plain 0.7.3 build, i.e. without any modifications?

Thanks!
Joerg
hiker
 
Posts: 1435
Joined: 07 Dec 2009, 12:15
Location: Melbourne, Australia

Re: Research on leadership in animal groups involving STK

Postby kiskoul » 28 Mar 2012, 09:09

Hi Joerg, thanks for your reply and your help. Here's where I'm standing:
- 0.7.3 "vanilla" builds fine but won't run in no-graphics mode (segmentation fault).
- 0.7.3 binary actually runs fine on all tracks, no GPU crash... Something must definitely have gone wrong when I built the game. Maybe it's due to me struggling a little to build Irrlicht 1.8.0-alpha and eventually having to build the game by forcing the DVERSION_VAR as follows:
{l Code}: {l Select All Code}
cmake ..  -DIRRLICHT_INCLUDE_DIR=/home/nperony/Tools/irrlicht/trunk/include -DVERSION_VAR=1.8 -DUSE_FRIBIDI=0

The only issue is that the profiling mode of the binary does not save the history by default, and I can't press F10 on all runs. I suspect going through my library issues may take much longer for me than it would be for you to build the game with the following options:
- history save upon EnterRaceOverState
- all tracks unlocked.
Do you think you could do that? Please pretty please :).
kiskoul
 
Posts: 8
Joined: 23 Mar 2012, 16:06

Re: Research on leadership in animal groups involving STK

Postby kiskoul » 28 Mar 2012, 09:14

Sorry, I forgot that the Save method should also be customised to include the position of all the karts. If that's a bit much to do, I'll try to compile the source on another machine with a more recent version of Ubuntu and that should work better. Cheers
kiskoul
 
Posts: 8
Joined: 23 Mar 2012, 16:06

Re: Research on leadership in animal groups involving STK

Postby hiker » 28 Mar 2012, 10:59

...
kiskoul {l Wrote}:- 0.7.3 binary actually runs fine on all tracks, no GPU crash... Something must definitely have gone wrong when I built the game. Maybe it's due to me struggling a little to build Irrlicht 1.8.0-alpha and eventually having to build the game by forcing the DVERSION_VAR as follows:
{l Code}: {l Select All Code}
cmake ..  -DIRRLICHT_INCLUDE_DIR=/home/nperony/Tools/irrlicht/trunk/include -DVERSION_VAR=1.8 -DUSE_FRIBIDI=0


Try following the instructions at http://supertuxkart.sourceforge.net/Build_STK_on_Linux , and use:
{l Code}: {l Select All Code}
... -DIRRLICHT_DIR=/home/nperony/Tools/irrlicht/trunk

You only specified the include directory for irrlicht, so you will likely link in the wrong library.

The only issue is that the profiling mode of the binary does not save the history by default, and I can't press F10 on all runs. I suspect going through my library issues may take much longer for me than it would be for you to build the game with the following options:
- history save upon EnterRaceOverState
- all tracks unlocked.
Do you think you could do that? Please pretty please :).

Sorry, I don't easily have access to a linux system atm. Xeno usually builds the linux binaries, but I haven't heard from him for a while. Anyone else here who might be able to help out?

Unlocking the tracks is just a matter of editing ~/.config/supertuxkart/challenges.xml - replace false with true.

Cheers,
Joerg
hiker
 
Posts: 1435
Joined: 07 Dec 2009, 12:15
Location: Melbourne, Australia

Re: Research on leadership in animal groups involving STK

Postby kiskoul » 28 Mar 2012, 11:19

Actually most of my problems probably come from my running Ubuntu 10.04 with outdated versions of CMake and Irrlicht, etc., which I had to build/install using backports. It's a bit of a mess. I should be able to build the whole game on Oneiric with more recent libraries and link them statically so as to have a running binary without all these problems. This is anyway going to be much easier. Thanks!
kiskoul
 
Posts: 8
Joined: 23 Mar 2012, 16:06

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

cron