Simulation of a self-driving car

Warning: I apologize for making it quite computationally demanding, so if you'll run the project on a less powerful laptop, or on a tablet (notebook) or a phone, it is going to be maddeningly slow, so better run it on a (powerful) desktop computer.

Here is a link

It uses:

  • a maze and a car image, designed by fridolinux in his autorennen 2.0 project,
  • nested to it are several stick-like sprites ('lasers' ) sensing how far from the car are the walls in various directions, which is achieved by percentually adjusting their individual sizes,
  • higher order functions, such as KEEP, MAP, and COMBINE are used to get lists of front lasers and back ones, their lengths, and the longest front laser's direction is then used to steer the car (or, when it is shorter than some value, the longest among the back laser's direction is used instead).

When the mouse-pointer is touching the car, the lasers are shown more visibly (i. e. with a lesser ghost effect).

Ideas to spice up the project:

I have been thinking about adding a small-range rotations to the individual lasers in order to find the best possible direction at each step, but that would make the simulation really slow, I guess.

If that was not the case, I would like to add maybe passengers or other cars that the self-driving car would have to avoid.

Cool, this is really good. I cant even think of making a project like this.

Two (and a half) years ago, I was not able to use the MAP block! ('scratchmouse' was/is my username at the - old Scratch - forum for Snap! users.)

Everything can be learned.

True, we all learn new things every day.

This is absolutely brilliant! But it's not published??? I can't find it on the community site.

It's true, it seems hardly any time ago that you were asking beginner questions and now you're a superstar. Congratulations!

Wow, nice AI. Keep your amazing projects up!

I :heart: it

When I have tried running it on the community site (in "my projects", visible only to me), well, it was too slow. It seems that the embedding makes projects quite slower. Since it is already slow, I prefer it is not run in any embedded form, that is why I decided to not publish it.

Hopefully I am keeping my ability to ask beginners (and stupid) questions - it keeps one's mind open - as my little superpower.

Besides, I still don't understand bunch of things, so be prepared to be asked very stupid questions in the coming 2021; ha ha ha

What I wish in the new year is to ask Jens & Jadga if could I collaborate with them making a tutorial on how to re-create the "Self-driving Car Simulation" project with me in a puppet role, semi-randomly (impro comedy, few years ago I took some real "impro comedy" courses...) stupid (beginners) questions (kind of the 1970s old tv "Muppets Show"), some met by educational answers/tips where to find answers (by Jens/Jadga, or/and by you, Brian, if you are interested), while the more absurd ones being just dismissed with an annoyed (bored) Jens'/Jadga's/your face doing facepalm for comical effect, dissolving the learning curve stress in the process. Just an ordinary, humble, New Year wish by a superstar of stupidity, ha ha, but why not.

Thanks, but you probably meant "nice Artificial Stupidity", not AI, project ('cos that is what it has been intended to be).

That sounds great! But meanwhile we can't put it in Featured Projects if you don't publish it. You could put in the project notes that people should click "view code" and run it in the editor instead of directly on the site.

What about publishing a "pointer" project containing no code, except a write block, saying what you said above (invite viewers to open an url of the actual project)?

That looks really cool. I think its amazing that simple rules like the cars 'ai' are able to find a (albeit unoptimized) solution.

Sure. Take a screenshot from the real thing for the stage background, though.

I agree it was/is a pleasant surprise.

I have finally published it, but it claims now there is some JS inside,

although I don't use any JS in the project.

Does the colors library use JS (I can't tell, I did look into it, but don't see it)?

Ummm sort of... In the new (7.0) version, the libraries work again, but you have to reload the dev version of the library. This is going to be a big pain in the neck for everyone, we know; we wish there were a way we could avoid it. So...

  1. Go to
  2. Open your project
  3. Load the library again
  4. If it works, save the project, maybe with a different name.

Once 7.0 is officially released, the new project will work in regular Snap!.