I know this is a huge wall of text but please read it! - This project demonstrates an extremely simple self-learning AI. There are two cliffs with a valley in between, and the goal of the blue square is to jump between the two cliffs. When it reaches the the edge of each cliff, it can perform three actions: Continue (c). If the square picks this option, it will fall off the cliff and respawn on the left cliff. Jump (j). If the square picks this option, it will jump to the other cliff. Random (r). If the square picks this option, it will have a 50% chance to land on the other cliff and a 50% chance to fall off and respawn on the left cliff. The c, j, and r variables are the amount of times it has picked that option. Over time, the square will learn to perform the actions that keep it alive most often. The 'Weight' variables of each of the three options are the key to the entire project. This value can go between 0 and 1. The higher the value, the more it prefers that option. The 'Total' variable is the amount of times it has reached the end of a cliff. The 'totalSuccess' variable is the amount of time it has jumped to the other end. The success values respective to each of the options are the amount of times the square has succeeded after choosing that option. Adjust the speed with the speed slider. Pause and play the simulation with the pause/play button.
Inspired by 'Learning AI' by Kanoa: https://scratch.mit.edu/projects/767917/ I just added a random value to make it more interesting Not surprisingly, the square eventually learns to perform the Jump option most often and the Random option less often. It almost never chooses the Continue option. As more time passes, it uses the jump option more frequently. I've noticed it can start choosing the Random option a lot, but over time it learns to use the Jump option.