This isn't scripted. A reinforcement-learning agent starts out knowing nothing, wanders the maze at random, and slowly teaches itself the fastest route — the exact algorithm (tabular Q-learning) behind a lot of "AI that figures things out." Watch it get better, run after run.
A real learning algorithm running in ~150 lines of plain JavaScript — no libraries, nothing sent to a server. This is the kind of "AI that adapts" our team builds into real products for small businesses. Curious what it could figure out for you? Tell us what you're picturing.