Just realized I may have left out some information that may be important in that last message:
The track is I am running is "Forza" under "Road Tracks".
The position my car was at was just past the start line somewhere at the edge of one of the two buildings, (or between them) at the right hand side of the track.
I am still running into program crashes once in awhile, but for a different reason this time. It seemed that my sensors were picking up bad values sometimes. (I use offset centerline etc. for some calculations.)
My bot currently turns hard right sometimes straight into the wall at the beginning of the race. Since I am using a neural network this is expected for some runs. So I added this bit of code into my drive funciton:
drive(int index, tCarElt* car, tSituation *situation)
std::cout << "Positition = ("
<< car->pub.DynGC.pos.x << ", "
<< car->pub.DynGC.pos.y << ", "
<< car->pub.DynGC.pos.z << ") " <<std::endl;
The output is:
Positition = (667.472, 1163.4, 3.84071)
Positition = (667.472, 1163.4, 3.84074)
Positition = (667.472, 1163.4, 3.84076)
Positition = (667.472, 1163.4, 3.84079)
Positition = (667.472, 1163.4, 3.84081)
Positition = (667.472, 1163.4, 3.84083)
Positition = (667.472, 1163.4, 3.84084)
Positition = (667.472, 1163.4, 3.84086)
Positition = (667.472, 1163.4, 3.84087)
Positition = (667.472, 1163.4, 3.84088)
Positition = (667.472, 1163.4, 3.84089)
Positition = (667.472, 1163.4, 3.8409)
Positition = (-nan, nan, -nan)
/usr/local/bin/torcs: line 53: 7428 Segmentation fault (core dumped) $LIBDIR/torcs-bin -l $LOCAL_CONF -L $LIBDIR -D $DATADIR $*
Once the position is nan or -nan, my program crashes because these values are ultimately used to index an array that I store approximations of a sigmoid in. (I don't imagine most others would do something like this.) My solution will be to check for nan of course, but I thought I'd mention it here in case it is a bug with TORCS. Perhaps some bad geometry at the edge of the track? Perhaps it's just my code again, but I definitely do not attempt to update position directly in my code, only the gas, brake and steering commands.
At the very least, someone might check the geometry at the above position and see if there is anything funky there just in case. (I have no idea how to check it myself.) This should be a rare case since my bot did 1270 runs before this happened. Subsequent loads of my 1271st network will cause it to crash at the same point every time. (I have a separate program generating the networks, so I have been able to load that network in via XML as a first run multiple times)
Feel free to let me know if I'm completely of my rocker here!