Remix of original by djscope, modified to show sensing technique and make it suitable for display on the Dynamic A.I. Studio. The simplicity of this method is good. Notice how simple the sensing armature is in the original. Bonus coolness points for the skid marks! Use the vector curve editing tool (second from top on vector toolbar) to create new tracks and test the AI on them. The default tracks all share the straightaway at bottom, so you can switch tracks when the car enters the straight and the transition will be seamless. WHAT TWEAKS OR MODS CAN YOU MAKE TO THE A.I. SO THE CAR GOES AROUND THE TRACK FASTER??
The trace function is always on right now so that the path and speed can be monitored for A.I. tuning. At very high speeds, the size of the Move makes the car jump past the finish line so that it misses the Pen Clear and interacts with the blue trace line. As a crude solution, the car presently has a track-colored probe sticking out the front to make the car costume longer. Now and then, the sensors will react to the black color of the finish line. Trimming the finish line away from the sides of the roadway will reduce this, but it would be best for the track to have a proper black&white checker finish line. Still working on it...please post ideas. (NOTE: We'll keep the track-sensing-based algorithm so that any graphic can be put alongside the track with no worries of strange interactions with the sensors. We'd rather deal with predictable things put on the track by us than who-knows-what someone would like to add alongside the track.) DISCOVERIES: 1. If the car goes fast enough to go off the road and put a turn sensor off the screen, the sensor detects plain WHITE. Therefore, use any road color except basic white. An off-white color will do, just not absolute white. 2. Sometimes, when the car goes haywire, it's the A.I. logic. other times, it's the Scratch player. It's usually very hard to tell the difference. 3. Moving the sensors farther in front of the car makes the car hug the inside of a curve or turn, producing a remarkably professional-looking driving line. Allowing the sensor armature to grow until both sensors touch the side of the road has almost the same effect. 4. Being able to grow the sensor armature in the X direction only (forward) would open the door for big improvement. Being able to dynamically shift the armature's center so that it moves forward of the car would also open the same door. The DAI mods in this remix are: 1. Sensors changed from whiskers to circles. 2. Curb sensors aligned square to the axis of the car and each other.. 3. Simplified sensing logic to sense edge of road instead edge of non-road (checks for "not gray" instead of looking for white). This uses fewer blocks and speeds up execution. 4. Parked the blue car to the side so the focus is on the red DAI car. 5. Stripped out unneeded code for improved script execution speed. Reworked variable names, script structure, etc. for clarity. 6. Made generic sprite names for both cars so that they can race each other to test different DAI methods. 7. Added the black spot front and center of the armature to detect when car is heading for the side of the road and steer harder. It's also used for braking on tight curves. 8 Added a trace with the pen for driving line analysis. Width of line is based on speed: wider = faster. 9. Made the sensing armature grow as road becomes straight and open. This allows the car to look farther ahead and speed up on straights and sweeping curves. The armature shrinks in tight curves and hairpins where the car slows down.. 10. Added speed adjustment based on how wild and loose the last lap was. Variables are how much braking and how many curb hits. 11. Tuned feedback variables so that a single variable (MaxSpd) controls the speed and driving aggressiveness. Interestingly, the car steers much better at higher speeds. When driving slow, it looks like a sloppy rookie, but when it finds its top speed, it usually brakes and steers through sharp turns like a pro.