My previous patch was committed \o/
My editor still had the file raceresults.cpp open and I found some ways to make it more simple & robust:
ReUpdateStandings() is used to read the existing results, update them with the most recent race's standings and write the updated results back. So basically you look for a driver, if he/she has previous results then add the points from the last race; if he/she does not have and previous results, create a record of it and put it between the results.
The original code went through the list of the recent race's results and sorted the array based on points with a bubble sort after each update. Now that it is luxury, sorting can be done after the updates have finished. That means we sort 1 time, not eg 20 times.
Then I thought - hey we are in the 21st century, let's not sort with a hand-written bubble sort when we have complete libraries for that. So I took a big breath and changed the array to a STL vector, then used STL sort() to handle sorting and find() to search for drivers. Result is: much simpler code. Oh and while I was there I changed the char* things to C++ strings, too.
I've sent the patch to Jean-Philippe, we'll see if he likes it or not. The patch can be applied to both trunk or sdl-port as the file is the same in both.
Friday, June 5, 2009
Tuesday, May 26, 2009
Patch - results not saved
I've sent a patch to Jean-Philippe, it fixes TORCS-NG's faulty behaviour not saving the results file if the directory structure to hold it was not created yet. I made the patch against the sdl-port branch, AFAIK the trunk is expected to be released soon.
The cause is plain simple, saving the XML file (GfParmWriteFile) uses fopen() and fopen isn't expected to create the directories. However I think the directory path should have been created when first running the program...
Well the patch fixes the fault explicitly creating the directories in the path if they do not exist. I've tested it under Linux but can't test it under Windows.
Scanning the TODO file a similar error is still there, not saving screenshots when the directories are not created yet. I'll look at it, this may be the same problem.
The cause is plain simple, saving the XML file (GfParmWriteFile) uses fopen() and fopen isn't expected to create the directories. However I think the directory path should have been created when first running the program...
Well the patch fixes the fault explicitly creating the directories in the path if they do not exist. I've tested it under Linux but can't test it under Windows.
Scanning the TODO file a similar error is still there, not saving screenshots when the directories are not created yet. I'll look at it, this may be the same problem.
Set for this year
Phew, I've been able to set up TORCS and my robot today.
I was really worried I would not get there in time.
I've created a development user environment, for testing the robot. Then I've created a separate user only for running the races. The latter one will get clean a TORCS install right before each race, so nothing can be left over and harm the results. At least I hope so :D
The only remaining issue is - my laptop's ATI Mobility Radeon X200 and Ubuntu 9.04 do not like eachother. I guess you know the story - Ubuntu moved to the new X server, ATI dropped support for 'legacy' cards, so their fglrx does not like the X200 now. That leaves me with the free radeon driver, that is ... khm ... not so strong when we speak about 3D. Framerates can drop to 1-2/s :( I guess I'll have to wait a bit and hope someone comes up with a solution for decent 3D. Or should I downgrade to 8.10 where all was fine yet?
I was really worried I would not get there in time.
I've created a development user environment, for testing the robot. Then I've created a separate user only for running the races. The latter one will get clean a TORCS install right before each race, so nothing can be left over and harm the results. At least I hope so :D
The only remaining issue is - my laptop's ATI Mobility Radeon X200 and Ubuntu 9.04 do not like eachother. I guess you know the story - Ubuntu moved to the new X server, ATI dropped support for 'legacy' cards, so their fglrx does not like the X200 now. That leaves me with the free radeon driver, that is ... khm ... not so strong when we speak about 3D. Framerates can drop to 1-2/s :( I guess I'll have to wait a bit and hope someone comes up with a solution for decent 3D. Or should I downgrade to 8.10 where all was fine yet?
Wednesday, May 20, 2009
2009 season preview
The TORCS Endurance World Championship 2009 season start is almost here.
I don't particularly like the tracks selected for this year - I like Forza, E-track 4 and Street 1, but really hate Dirt-3, E-Track-1 or Aalborg. I miss Brondehach, Wheel-2, E-track-6 or Corkscrew. But well, maybe my robots have a different opinion :D
I have some issues with my laptop so cannot run TORCS and test the robots at the moment. I expect them to be on the skill level of last December, while many code enhancements were committed, mainly in the raceline section. But none of these changes has been tested against the 1.3.1 release so I only expect the robots to drive as good as they have did near the close of last year's championships.
First race is due on 4th of June, so - from coder's viewpoint - almost an eternity to get everything going.
I don't particularly like the tracks selected for this year - I like Forza, E-track 4 and Street 1, but really hate Dirt-3, E-Track-1 or Aalborg. I miss Brondehach, Wheel-2, E-track-6 or Corkscrew. But well, maybe my robots have a different opinion :D
I have some issues with my laptop so cannot run TORCS and test the robots at the moment. I expect them to be on the skill level of last December, while many code enhancements were committed, mainly in the raceline section. But none of these changes has been tested against the 1.3.1 release so I only expect the robots to drive as good as they have did near the close of last year's championships.
First race is due on 4th of June, so - from coder's viewpoint - almost an eternity to get everything going.
Labels:
championship,
robot,
software,
TORCS
Friday, November 28, 2008
TORCS Championships 2008 - Corkscrew
The TORCS robots moved across the US, from Michigan to sunny California this time. Testing their skills at the dreaded Corkscrew complex, on a newrunner track (erm created by... me?). It was a fun race, one that I enjoyed the most so far I guess, and not because it was on 'my' track.
Ah right, forgot to write about Michigan... oval racing, going round and round lotsa times. My robots did quite well, being speedy, but their technique in the corners would need some more work. Ah and at one point they tend to miss a pit visit so can run out of fuel. That was solved with a temporary hack for Corkscrew, telling them to start thinking about pitting when they still have fuel enough for 3 laps :)
So came qualifiers and the kilo bots finished #13-14 while the dotty ones #17-18 (by design). In fact the Dots were some hundredths faster on test runs than the Kilos but I preferred the Kilos to gain points, so made the qualy setting of Dots a little bit slower. That is a programmer, playing God :D
Start went fine and the first hairpin was solved without any big amounts of damage, but Turn 3, a sweeping right-hander prooved fatal for some top teams. USR lost R.Giskard who though he should pit each and every lap after the accident, a JDI was thrown back and Bea Benz had to fight her way back to the top 10, too.

Kilo 2 and Fuzzy Foe got in top 10 somehow while the other halves of my teams had to jog a bit in the second half of the field. The track prooved to be quite entertaining, there was always something happening somewhere, there were not many boring empty minutes.

Like here: Kilo 1 (blue+yellow) overlaps the orange R.Giskard, Dotty laps them both, while they were all lapped by the wdbee team (on the far left):

Team Inferno's aggressive driving style caused them to spend quite some time in the pits, obviously loosing too many places, also with the (not so occasional) spins:




The Corkscrew turn complex produced some hot moments:


As I've said before, the race was full of action, takeovers, overlapping, taking a lap back, it was hard sometimes to decide who fights who, the pit was crowded, entering cars caused some trouble, too:



All in all it was an exciting race - too bad the scenery is dull, it definitely needs some Blender work.
Ah right, forgot to write about Michigan... oval racing, going round and round lotsa times. My robots did quite well, being speedy, but their technique in the corners would need some more work. Ah and at one point they tend to miss a pit visit so can run out of fuel. That was solved with a temporary hack for Corkscrew, telling them to start thinking about pitting when they still have fuel enough for 3 laps :)
So came qualifiers and the kilo bots finished #13-14 while the dotty ones #17-18 (by design). In fact the Dots were some hundredths faster on test runs than the Kilos but I preferred the Kilos to gain points, so made the qualy setting of Dots a little bit slower. That is a programmer, playing God :D
Start went fine and the first hairpin was solved without any big amounts of damage, but Turn 3, a sweeping right-hander prooved fatal for some top teams. USR lost R.Giskard who though he should pit each and every lap after the accident, a JDI was thrown back and Bea Benz had to fight her way back to the top 10, too.

Kilo 2 and Fuzzy Foe got in top 10 somehow while the other halves of my teams had to jog a bit in the second half of the field. The track prooved to be quite entertaining, there was always something happening somewhere, there were not many boring empty minutes.

Like here: Kilo 1 (blue+yellow) overlaps the orange R.Giskard, Dotty laps them both, while they were all lapped by the wdbee team (on the far left):

Team Inferno's aggressive driving style caused them to spend quite some time in the pits, obviously loosing too many places, also with the (not so occasional) spins:




The Corkscrew turn complex produced some hot moments:


As I've said before, the race was full of action, takeovers, overlapping, taking a lap back, it was hard sometimes to decide who fights who, the pit was crowded, entering cars caused some trouble, too:



All in all it was an exciting race - too bad the scenery is dull, it definitely needs some Blender work.
Wednesday, October 15, 2008
TORCS Championships 2008 - Alpine-2
Winter. Snow. Slippery roads. 20 mad pilots.
That was the Alpine-2 race of the TRB championships. As the track is quite slow (and narrow), I've expected the race to be well over 3 hours and indeed I was right.
Kilo robots finished at #17-18 while Dots were #15-16 after the qualifications. They made a good start, fighting with the JDIs, when those 2 decided to wreck eachother so we could take them over and go after the Kiwis.

But then disaster came (as usual) and all 4 of my robots collided with eachother when Dotty tried to fight the Kiwis' Arina:
So - time to get working hard and find our way back. This is the scheme I seem to follow this year it seems :D
Kilo 2 seemed to be in best position, with less damage than the others. Dotty made a pass over Arina however - too bad it had to pit the same lap to refuel.

I was testing a refuel strategy code with my robots, making fast pit and frequent pit stops, refuelling every 10-15 laps to make more speed. I am still undecided whether it worked or not.
Berniw robots were slow and - unusually - very hard to overlap, this resulted in quite interesting moments and some damage to the leading robots, too.


Well about 30-40 laps into the race it seemed Kilo 2 can catch a Kiwi (Ohiana), and all others would follow the JDI Porsches. Not a good result but... well...
A big pile-up determined Kilo 1's race, due to heavy damage, also ending one Berniw robot's race:
Fuzzy Foe made an interesting pit stop, not caring about Dotty being there already, so he had to quit the race shamefully:

Then we lost dummy's 2nd driver the same way:
At the middle of the race Ohiana made a spin and had a hard time to recover and that proved lethal for his position, Kilo 2 had a target and from then on slowly beat poor Kiwi, with short refuels and fast, un-disturbed laps (yes, that part is true luck):
A JDI spinned at the entrance of the tunnel and was completely destroyed by the arriving USR bot:
As a result of these events, the positions were like this: #11 Kilo2, #12 Ohiana, #13 JDI2, #14 Kilo1, #15 Dotty, and in fact it didn't change until the finish. During the closing phases Kilo 2 was quite faster than Arina, the other Kiwi, too bad there was 2 laps' distance between them...

All in all I've enjoyed the race, Kilo 2 moved from start position #18 to finish at place 11. We lost Fuzzy due to a silly error (I must investigate that). Kilo 1's race was simply unlucky, with 2 big crashes and a lot of time spent in the pits.
As for what happened at the top... I don't really know, I was concentrating on the middle section. Sorry Andrew, Wolf-Dieter and Eric, it is too boring to see you win all the races :D :P
That was the Alpine-2 race of the TRB championships. As the track is quite slow (and narrow), I've expected the race to be well over 3 hours and indeed I was right.
Kilo robots finished at #17-18 while Dots were #15-16 after the qualifications. They made a good start, fighting with the JDIs, when those 2 decided to wreck eachother so we could take them over and go after the Kiwis.

But then disaster came (as usual) and all 4 of my robots collided with eachother when Dotty tried to fight the Kiwis' Arina:
So - time to get working hard and find our way back. This is the scheme I seem to follow this year it seems :DKilo 2 seemed to be in best position, with less damage than the others. Dotty made a pass over Arina however - too bad it had to pit the same lap to refuel.

I was testing a refuel strategy code with my robots, making fast pit and frequent pit stops, refuelling every 10-15 laps to make more speed. I am still undecided whether it worked or not.
Berniw robots were slow and - unusually - very hard to overlap, this resulted in quite interesting moments and some damage to the leading robots, too.


Well about 30-40 laps into the race it seemed Kilo 2 can catch a Kiwi (Ohiana), and all others would follow the JDI Porsches. Not a good result but... well...
A big pile-up determined Kilo 1's race, due to heavy damage, also ending one Berniw robot's race:
Fuzzy Foe made an interesting pit stop, not caring about Dotty being there already, so he had to quit the race shamefully:
Then we lost dummy's 2nd driver the same way:
At the middle of the race Ohiana made a spin and had a hard time to recover and that proved lethal for his position, Kilo 2 had a target and from then on slowly beat poor Kiwi, with short refuels and fast, un-disturbed laps (yes, that part is true luck):
A JDI spinned at the entrance of the tunnel and was completely destroyed by the arriving USR bot:
As a result of these events, the positions were like this: #11 Kilo2, #12 Ohiana, #13 JDI2, #14 Kilo1, #15 Dotty, and in fact it didn't change until the finish. During the closing phases Kilo 2 was quite faster than Arina, the other Kiwi, too bad there was 2 laps' distance between them...
All in all I've enjoyed the race, Kilo 2 moved from start position #18 to finish at place 11. We lost Fuzzy due to a silly error (I must investigate that). Kilo 1's race was simply unlucky, with 2 big crashes and a lot of time spent in the pits.
As for what happened at the top... I don't really know, I was concentrating on the middle section. Sorry Andrew, Wolf-Dieter and Eric, it is too boring to see you win all the races :D :P
Wednesday, July 23, 2008
TORCS Championships 2008 - Brondehach
The TRB Championships saw another interesting race this weekend.
The track is known for its tricky, off-camber turns and short straights. I've decided to split the team and used a high-downforce setup for car #1 and a high-speed one for car #2. Looking back at results, the first choice proved to be more effective.
The qualification yielded "nothing new" - my cars were in the middle, USR/wdbee/Simplix teams at top. USR showed off a lightning-fast 1:07.02, so a quick maths gave me a race result of finishing 5 laps behind...
Green lights! And they're off for 128 laps... Kilo 1 drives nice at position 10 while Kilo 2 was blocked at the start by a JDI Porsche parking across the start lane... It took about half a lap time to get clear of that :( Anyway for the first 30-40 laps the Kilos were in the middle of the field, driving quite smooth and nice. I noticed however my robots were more elegant than others when letting one overlap them, and it caused quite some time loss. Then something went simply wrong - every overlapping put my robots back a long way, they even lost positions that way. Overlapping cars (especially the USR team) caused damage, opponents smashed into them, then they drove a bit glued together in 4th gear not overlapping/waiting to be overlapped (something wrong with team tactics decision code). Then around lap 90 Kilo 1 drove straight into the pit wall and spent 3 minutes there recovering :( That pretty much ruined all the race for him, until then it would have been capable of finishing #10, afterwards I was happy to see them finish 13th-14th.
Well as it is a fun game, I don't want to use words like 'catastrophe' but - it was one :( Nevertheless if I look at the race from an outside view, it was a nice, crowded race with a lot happening all around.
The track is known for its tricky, off-camber turns and short straights. I've decided to split the team and used a high-downforce setup for car #1 and a high-speed one for car #2. Looking back at results, the first choice proved to be more effective.
The qualification yielded "nothing new" - my cars were in the middle, USR/wdbee/Simplix teams at top. USR showed off a lightning-fast 1:07.02, so a quick maths gave me a race result of finishing 5 laps behind...
Green lights! And they're off for 128 laps... Kilo 1 drives nice at position 10 while Kilo 2 was blocked at the start by a JDI Porsche parking across the start lane... It took about half a lap time to get clear of that :( Anyway for the first 30-40 laps the Kilos were in the middle of the field, driving quite smooth and nice. I noticed however my robots were more elegant than others when letting one overlap them, and it caused quite some time loss. Then something went simply wrong - every overlapping put my robots back a long way, they even lost positions that way. Overlapping cars (especially the USR team) caused damage, opponents smashed into them, then they drove a bit glued together in 4th gear not overlapping/waiting to be overlapped (something wrong with team tactics decision code). Then around lap 90 Kilo 1 drove straight into the pit wall and spent 3 minutes there recovering :( That pretty much ruined all the race for him, until then it would have been capable of finishing #10, afterwards I was happy to see them finish 13th-14th.
Well as it is a fun game, I don't want to use words like 'catastrophe' but - it was one :( Nevertheless if I look at the race from an outside view, it was a nice, crowded race with a lot happening all around.
Labels:
championship,
race,
software,
TORCS
Tuesday, July 8, 2008
TORCS Championships 2008 - Adelaide
It was the second race on this year's schedule of the TORCS Championships, held on a track very very similar to the late Adelaide street circuit.
There were 18 robots starting, installation went without any trouble. The qualifiers went OK again, my robots came mid-field, at position 9 and 12, separated only by some 6 hundreths. Then the race...
As it could be expected, the first corners were frantic and there was a huge crash involving 6-7 cars, only the first half of the cars survived it. So that and the following pit visits mixed up the order quite a bit, causing early overlappings and big fun to watch. My robots were set up using a low-downforce, highspeed setup, which made them suffer very much in the 90-degree corners, but they gained back quite a bit of time each lap on the straigth sections. In fact, they were quite hard to overtake, being speedy (3rd-4th in top speed competition). If one missed his chance in the corners, my robots were out of reach for him on the other parts of the track.
"As usual", the USR, wdbee and Simplix robots were fighting for top positions, closely followed by the Dummy team. Team Kiwi was fast again, but one of its robots did not stop to pit with no fuel left, so that meant the end for him, while his own teammate smashed into the small queue that formed behind his mate just slowing down.
My robots had a nice clash with the Inferno team and gained a shared 11th and a 13th position in the end. It could have been better even, if my better robot, Kilo 2 hadn't spin about 10 laps to go, as it was closing in on Inferno-C quite fast and could have overtaken him - but well, this is racing :)
Team JDI had improved quite a bit, better watch out for those blue-green Porsches next time. Too bad Berniw didn't have time to imrpove the robot code obviously, so his robots weren't competetive this time.
So it was an eventful race, and clearly showed the areas where I should improve the robot behaviour: smarter overtaking, faster recovery, working together as a team.
There were 18 robots starting, installation went without any trouble. The qualifiers went OK again, my robots came mid-field, at position 9 and 12, separated only by some 6 hundreths. Then the race...
As it could be expected, the first corners were frantic and there was a huge crash involving 6-7 cars, only the first half of the cars survived it. So that and the following pit visits mixed up the order quite a bit, causing early overlappings and big fun to watch. My robots were set up using a low-downforce, highspeed setup, which made them suffer very much in the 90-degree corners, but they gained back quite a bit of time each lap on the straigth sections. In fact, they were quite hard to overtake, being speedy (3rd-4th in top speed competition). If one missed his chance in the corners, my robots were out of reach for him on the other parts of the track."As usual", the USR, wdbee and Simplix robots were fighting for top positions, closely followed by the Dummy team. Team Kiwi was fast again, but one of its robots did not stop to pit with no fuel left, so that meant the end for him, while his own teammate smashed into the small queue that formed behind his mate just slowing down.
My robots had a nice clash with the Inferno team and gained a shared 11th and a 13th position in the end. It could have been better even, if my better robot, Kilo 2 hadn't spin about 10 laps to go, as it was closing in on Inferno-C quite fast and could have overtaken him - but well, this is racing :)
Team JDI had improved quite a bit, better watch out for those blue-green Porsches next time. Too bad Berniw didn't have time to imrpove the robot code obviously, so his robots weren't competetive this time.So it was an eventful race, and clearly showed the areas where I should improve the robot behaviour: smarter overtaking, faster recovery, working together as a team.
Labels:
championship,
race,
robot,
software,
TORCS
Subscribe to:
Posts (Atom)