The TORCS Racing Board
Username: Password: Remember Me?
Lost Password Register
Author: joe | Created: 2017-03-06 18:42:05
Subject: new team, need guidance/code
Hello all,

I have played with torcs and followed trb forums and mailing list for a few years and I figured it is time to start racing. I finally learned a bit of scripting so I figured it was time to put that to use and make a robot. My concern is that I will be a hindrance to quality racing if I attempt to startfom scratch. It seems in other threads like teams share the prior years code for those looking to modify it. Is there a place to download the robots or do you just email them directly?

MORE EDITS: I feel I should clarify that I plan on modifying the code, not just running it straight.

Also how much time is left to work on robots before a road ready version is needed?
EDIT: I just saw the email about the season sign up
Thanks in advance,
Joe
Last Edited: 2017-03-06 19:18:01 by joe
    Author: dummy | Created: 2017-03-06 19:32:29
    Subject: Re: new team, need guidance/code
    Welcome Joe to the TRB championships. This season is looking promising with new teams joining in.

    You can download every robot of past seasons on the Events link. And maybe read the "New Team" thread from jspenn for some important info about the new TORCS version.
    Last Edited: 2017-03-06 19:32:29 by dummy
    Author: jspenn | Created: 2017-03-08 13:32:47
    Subject: Re: new team, need guidance/code
    I guess this is a good time to say that I have absolutely no idea how the .dat files work.

    EDIT: as in .../usr_2016/car2_trb1/wheel_2.dat
    Last Edited: 2017-03-08 13:34:07 by jspenn
      Author: firechief | Created: 2017-03-08 13:41:29
      Subject: Re: new team, need guidance/code
      Afraid I can't help you with that - if you want to persevere with hymie you'll have to figure it out :)
      Last Edited: 2017-03-08 13:41:29 by firechief
        Author: joe | Created: 2017-03-08 15:19:01
        Subject: Re: new team, need guidance/code
        Along the lines of figuring things out: does anyone have a favorite cpp learning resource?
        Last Edited: 2017-03-08 15:19:01 by joe
          Author: firechief | Created: 2017-03-08 15:28:21
          Subject: Re: new team, need guidance/code
          I learned many years ago through reading this book, which is still on my shelf ... http://iacs-courses.seas.harvard.edu/courses/cs207/resources/TIC2Vone.pdf

          I did already have a thorough working knowledge of C though. Of course, these days you have google to help as well ;)
          Last Edited: 2017-03-08 15:28:21 by firechief
          Author: dummy | Created: 2017-03-08 16:44:36
          Subject: Re: new team, need guidance/code
          IMHO http://www.stroustrup.com/ is a good starting point.

          But AFAIK we can't use the C++11 stuff yet in the TORCS Robots :(
          Last Edited: 2017-03-08 16:44:36 by dummy
        Author: joe | Created: 2017-03-08 15:19:36
        Subject: Re: new team, need guidance/code
        Along the lines of figuring things out: does anyone have a favorite cpp learning resource?
        Last Edited: 2017-03-08 15:19:36 by joe
    Author: firechief | Created: 2017-03-09 05:04:55
    Subject: Re: new team, need guidance/code
    Hi Joe, you can download the robots from last year here: http://www.berniw.org/trb/events/event_view.php?vieweventid=23

    Keep in mind that these downloads contain only the code, not the configuration (setup & other data files) that were used to make them run quickly in 2016's comp. Some robots are by nature obsolete and quite slow (berniw_2004, jdi_2009), so you can't expect to win much if you base your robot off these.

    The other robots are all quite good, though they will all require you to put some work in to understand how to configure them for optimal performance on a track. Some (USR/Hymie) are highly complex and will seriously hurt your brain if you try to use them - I've just merrily added a wide array of options to them over the years, half of which are now redundant.

    DanDroid and wdbee both have self-learning features (I can't vouch for how good they are or tell you how they work) which I think their authors used to help create setups. USR/Hymie and Axiom/Sieger are entirely manual, no learning code has been written for them.

    None of the robots contain any code for managing the new tyre wear feature introduced in TORCS 1.3.8, so that's something you'll need to write yourself otherwise your robot will not be competitive and may struggle to finish many races.

    You can see the schedule for the races here: http://www.berniw.org/trb/events/race_schedule_view.php?viewscheduleid=24 with the cutoff date for the first one being 30th May, although if your robot is ready before then its a good idea to enter one of the Test races as that will help you find out whether its compiling & installing correctly on other people's computers.

    Hope that helps!
    Last Edited: 2017-03-09 05:07:18 by firechief
      Author: joe | Created: 2017-03-16 18:03:42
      Subject: Re: new team, need guidance/code
      Do you happen to have a copy of locus floating about? I was reading through old posts on here and back then you said that it was a good bot for beginners. If that still holds true I would like to check it out. Last years bots are a bit over my head, and I feel like I would be plagiarizing if I used them as I cant really contribute anything new. Thanks!
      Last Edited: 2017-03-16 18:03:42 by joe
        Author: dummy | Created: 2017-03-16 19:55:41
        Subject: Re: new team, need guidance/code
        I don't know, if it's still a good starting point, but I found it:

        https://sites.google.com/site/torcscreations/drivers

        EDIT: Oops, the link to the file doesn't work, sorry.
        Last Edited: 2017-03-16 19:58:18 by dummy
        Author: firechief | Created: 2017-03-17 00:21:47
        Subject: Re: new team, need guidance/code
        Locus is a pretty simple robot though not without its flaws, and unfortunately I no longer have the source code for it. Quite a few people have based their robots on locus though, and you can download their work & use that as a starting point.

        2008 was the year Locus was introduced and that year's TRB saw several robots using it, the best of which (by a considerable margin) was Eric Espie's Inferno who finished a creditable 4th out of 12 entrants. I'd suggest looking at his version which can be downloaded from http://www.berniw.org/trb/events/event_spectator_download.php?eventid=11&teamid=6
        Last Edited: 2017-03-17 00:21:47 by firechief
          Author: joe | Created: 2017-03-18 00:16:43
          Subject: Re: new team, need guidance/code
          Great, thanks for the tip. I think simpler is better for now. other people's code is hard to understand when you are new to the language. Trying to parse through the clothoid.cpp is maybe a lost cause on friday afternoon...
          Last Edited: 2017-03-18 00:16:43 by joe
            Author: firechief | Created: 2017-03-18 05:35:28
            Subject: Re: new team, need guidance/code
            Heh, I know what you mean. The successful robots all use clothoids to calculate the raceline - even berniw_2004 does. Locus was basically a merger between BT, which provided the basic framework for the robot, and K1999 which provided a clothoid implementation written by Remi Coulom who has since gone on to write chess & Go engines. My current USR/Hymie started with Locus as a base.

            With the clothoid side of things, its not essential to understand how it works - you can do quite well simply treating it as a magical black box. However there are various ways to tweak its parameters to improve performance. USR/Hymie do this with K1999's code, and Axiom, DanDroid & wdbee do the same with their own implementations. You'll need to experiment to discover ways to do this yourself.

            Also a challenge with Locus is what happens when the car leaves the precomputed raceline, in order to overtake an opponent for example. Locus only has the one raceline, it uses BT's code for driving offline, and the transition between the two isn't always great. The fastest robots all use precomputed racelines for avoidance as well as the ideal line for driving alone, and clever ways to move from one raceline to the next.

            Another challenge is making the overtaking code smarter so the car doesn't waste time & speed trying to overtake when there's no real hope of success, but also doesn't drive too conservatively & fail to get past when the opportunity's there. This too is something you can tinker with to improve.

            And lastly of course there's the tyre management side of things to code, and penalties to handle (the BT example I posted should work for a locus bot btw) and generally getting the car to lap as fast as possible on each track, hoping that you've managed to match or beat your opponents - and this year we have no benchmark as we've changed to pro, we literally have no idea what laptimes to expect from anyone :)
            Last Edited: 2017-03-18 05:35:28 by firechief
              Author: jspenn | Created: 2017-03-18 09:49:36
              Subject: Re: new team, need guidance/code
              Hey Andrew, congrats on 1000 posts! You're, by my calculations, the most prolific poster on the entire board.

              Only 24 more until you get to a nice round number ;)
              Last Edited: 2017-03-18 09:51:02 by jspenn
                Author: firechief | Created: 2017-03-18 10:18:01
                Subject: Re: new team, need guidance/code
                I need to get a life...
                Last Edited: 2017-03-18 10:18:01 by firechief
                  Author: dummy | Created: 2017-03-18 11:19:45
                  Subject: Re: new team, need guidance/code
                  What? This forum is not the life? Then I need one too :)
                  Last Edited: 2017-03-18 11:19:45 by dummy
                  Author: jspenn | Created: 2017-03-18 16:05:10
                  Subject: Re: new team, need guidance/code
                  What's a life?
                  Last Edited: 2017-03-18 16:05:10 by jspenn
              Author: joe | Created: 2017-03-18 19:07:12
              Subject: Re: new team, need guidance/code
              Wow, thanks for all the tips. Time to scheme.
              Last Edited: 2017-03-18 19:07:12 by joe
                Author: firechief | Created: 2017-03-19 02:21:37
                Subject: Re: new team, need guidance/code
                We're a friendly & helpful bunch here - even though we're competing, we're happy to help each other out as the goal is to create superb robots that result in exciting races :)
                Last Edited: 2017-03-19 02:21:37 by firechief
      Author: jspenn | Created: 2017-03-20 09:34:25
      Subject: Re: new team, need guidance/code
      Hey andrew, i have just run a few test races on 1.3.8, and i can conclude two things:
      1) everythings fine
      2) contrary to last season's standings, Axiom > DanDroid
      MOUSE POWAH 4 DA WIN

      (sorry danny)
      Last Edited: 2017-03-20 09:34:25 by jspenn
        Author: firechief | Created: 2017-03-20 10:55:55
        Subject: Re: new team, need guidance/code
        Heh, glad you got everything working - and my guess is you're running them against each other using their default settings, in which case Axiom will indeed be faster. Its not necessarily that way once Danny's optimized his track-specific setup though, but yes Axiom's next goal is to try & finish ahead of the Droids in the championship.
        Last Edited: 2017-03-20 10:55:55 by firechief
        Author: dummy | Created: 2017-03-20 16:54:32
        Subject: Re: new team, need guidance/code
        Nice too hear you're up and running. One problem solved, but still a lot of work ahead.

        I totally agree. Mouse Powah rules :)

        Danny
        Last Edited: 2017-03-20 16:54:32 by dummy
          Author: jspenn | Created: 2017-03-20 18:22:39
          Subject: Re: new team, need guidance/code
          Status update, absolutely everything is fine, robots should be ready by the beginning of the championship. I wasn't originally going to use mouse powah, but then again...
          Last Edited: 2017-03-20 18:22:39 by jspenn
    Author: jspenn | Created: 2017-03-09 17:45:05
    Subject: Re: new team, need guidance/code
    Also, I may have missed this from an earlier thread, but how do you implement tyre wear in the code?
    Last Edited: 2017-03-09 17:45:05 by jspenn
      Author: joe | Created: 2017-03-09 21:04:56
      Subject: Re: new team, need guidance/code
      Pretty sure that is what we all have to figure out :)
      Last Edited: 2017-03-09 21:04:56 by joe
    Author: firechief | Created: 2017-03-11 08:41:25
    Subject: Re: new team, need guidance/code
    Another note regarding Pro mode - as stated in the rules, robots will need to abide by drive-through and stop & go penalties. Both of these are for pit-lane infringements. Drive-throughs are for speeding in the pits, and stop & go's are for entering or exiting the pits from the wrong location which is quite possible on tracks that don't have pit walls.

    The very first race in this year's TRB is on alpine-1, where there's no pit wall. If (for example) a car is bumped while trying to overtake down the straight and ends up veering into the pit area, it will be given first a drive-through and then a stop & go which it will need to serve separately.

    From my manual experimentation (deliberately driving through a pit lane at high speed to provoke a stop & go penalty), a car is eliminated after 5 laps if the penalty isn't served. If the race ends before the 5 laps is up, the car suffers a 10 second penalty for a drive-through, and a 16 second penalty for a stop & go.

    The point is that robots will need to be able to perform stop & go's (should be easy enough) and drive-throughs which will require new code to be written, as no current robots will have that feature implemented. Nothing would be worse than leading a race, have a penalty imposed, and be eliminated.

    Firstly your robot will need to know of the existence of penalties. The following snippet provides an example...

    tCarPenalty *penalty = GF_TAILQ_FIRST(&(car->_penaltyList));
    if (penalty) {
    if (penalty->penalty == RM_PENALTY_DRIVETHROUGH) {
    // yep, a drive-through, you need to handle it
    } else if (penalty->penalty == RM_PENALTY_STOPANDGO) {
    // you guessed it, a stop&go penalty
    }
    }

    In the above, "car" is a tCarElt *

    If its a drive-through, your car should not stop but just cruise through the pitlane - no robots have this logic implemented yet though. Alternatively you could stop the car, but in the PitCmd callback you'll need to set car->pitcmd.stopType = RM_PIT_STOPANDGO. I don't know if this will clear a drive-through penalty, when driving manually the Stop & Go button is greyed out when I pit, and the drive-through is still there after exiting the pitlane. If your robot repairs damage, adds fuel or changes tyres, or even does none of these but still returns an RM_PIT_REPAIR, then the penalty will not have been served.

    Hopefully the above information helps. These kind of pit infringements should be rare, so hopefully we won't see them happen very often, and on some tracks stop & go's are physically impossible. But on other tracks (dirt-3 especially) they become quite likely, and it'd be a shame to see cars eliminated because they're oblivious to penalties.


    Last Edited: 2017-03-14 04:15:48 by firechief
      Author: dummy | Created: 2017-03-11 13:25:40
      Subject: Re: new team, need guidance/code
      Thanks Andrew. This helps a lot to get started with implementing those new rules.
      Last Edited: 2017-03-11 13:25:40 by dummy