AI Taught My Son a Life Lesson: A Real Story

In the ever-evolving world of technology, Artificial Intelligence (AI) has become an integral part of our lives. Its impact goes beyond technological advancements; AI can be a powerful educational tool. My personal experience with AI, where it played a key role in teaching my son a life lesson, exemplifies this.

For an educational project, I developed a few algorithms to play simple games, one of which involved navigating a 5×5 maze. This challenge is often used to introduce learners to reinforcement learning — a branch of AI that optimizes a behavior through a trial-and-error process. I programmed two algorithms for this purpose: The first was a basic algorithm that chooses moves randomly (a random agent), serving as the base case for comparison. The second was a Q-learning agent, a reinforcement learning algorithm that progressively approaches an optimal solution as it gains more experience. Both agents track the number of steps they take, providing a quantifiable measure of their effectiveness.

Upon introducing these games to my son, he was immediately engaged. He amusingly named the random agent the “silly agent” due to its aimless movements.

The `0` represents the agent, the `X` indicates a wall, and the` _` denotes a free spot that the agent can move to. In this animated image, the agent moves randomly and does not learn from its mistakes. Consequently, it takes numerous steps to reach the goal, marked by `[]`

The Q-learning also began with random moves but adapted over time, eventually finding the shortest path. I had intentionally disabled visualization for the Q-learning agent during its learning phase. To my son, it seemed as though this agent paused to think before moving along the optimal path.

The Q-learning agent represented by `0` solves a 5x5 maze by moving along the shortest path to the goal which is marked by `[]`

This presented an invaluable teaching moment. I explained to my son the significance of thinking and planning before taking action. The “silly agent,” acting without a strategy and feedback took many more steps and time to reach the goal. Conversely, the learning agent, seemingly pausing at the beginning to strategize, reached the goal much faster. This contrast between haste and thoughtful planning provided a potent lesson in patience, strategy, and learning from mistakes. Now, I often reference the difference between the two agents to encourage my son to think before acting and learn from his experiences. This experience has not only taught him a valuable lesson but also highlighted how AI can be a unique and effective tool in education and personal growth.

Link to code: https://github.com/amjadmajid/deep-reinforcement-learning-games-from-scratch