//---------------------------------------------------------------------------- // // RARS Robot racing code DougE1.CPP from Doug Eleveld // // Developed for RARS 0.72 with DJGPP/Allegro // //---------------------------------------------------------------------------- // // !!! DougE1.cpp must be associated with data file DougE1.dat !!! // !!! otherwise nothing will work !!! // // Anybody can do whatever they want with this code, but if you use ideas // I'd like you to send me an email. This source code is public. // // The car 'recognizes' the road that it on by looking at the length, radius // etc of the segments and looks up in a big table of optimized values that // is in the datafile. The optimizer is another program and I won't include // it here as there is just simply too much code. If it gets put on a track // for which it is not optimized, the 'best fit' of the optimized values is // chosen. This usually means that it will crash alot on tracks for which it // is not optimized, and probably won't make it even once around. It is // optimized for all the tracks the RARS 0.72 except, of course, for // RANDOM.TRK. Optimization uses a genetic algorithm with an initial path // and speed that are set by hand. I have not done anything to increase // performance on un-optimized tracks, although I may do leave-one-out // cross validation to find the best weights for 'recognizing' each segment. // I am willing to share the code with pretty much anyone who asks. // // The car's path is dependant on the road, and not on global coordinates. // This means that is is fairly stable, although it performs poorly // (especially passing) when there are many short (compared to car length) // sections of road like in MONACO.TRK or high speed straights that end in // sharp curves like in AUSTRIA.TRK. It loves long sweeping curves like // SPA.TRK. It performs well on MONZA-76.TRK for most of the track, but // gets disturbed by the short chicane-thing and that destroys it's time. // I have been thinking about an 'override' to global coordinates for these // difficult sections, but I not sure if I can do that... // // What I have also implemented that I have not earlier seen here is that // different approach speeds are used for different cars and anti-bulldozing // code. The approach speed of a car depends on how long DougE1 has been // trying to pass them. This is intended to avoid getting stuck behind // someone that I cannot pass, which especially happens on short ovals. // The passing code is only mediocre, even though it is quite complex. It // is particularly poor at passing groups of cars, therefore it doesn't // usually do to well on the short ovals. Sometimes it passes great, but // when it does crash it usually crashes in a spectacular fashion. // // You may notice some wierd or non-optimal things in the physics here. This // is because I know very little about the physics of car racing (I'm an // electrical engineer), but I do know a fair bit about optimization. And // that is what DougE1 is pretty much completely based on, optimized paths // for each track. // // I got the inspriration for my pattern based matching stuff from looking // at the Wappucar source, although I implemented it in a completely // different way. There is also a tiny little bit of code from Apex8 in the // collision avoidance code. Other than that I think it's a pretty original // robot. // // I'd love to discuss the code with anyone, and would actually like to team // up with someone who knows how to white a better collision avoidance than // I have. I'd might want to make one using global coordinates, based on the // TURTLE9 source. Or maybe make a car only for ovals with seperate fast // path and passing path.