liveBook · Manning

Trial and error

As explained in Grokking AI Algorithms, Second Edition

Trial and error is a problem-solving technique that tests alternative attempts and uses their outcomes to identify a successful solution.

Trial and error is a problem-solving technique: try one approach, learn from its outcome, and try something different until you succeed. The process may require many attempts and is often guided by rewards or penalties. section 10.2

The technique works well when possible actions can be tested and their results observed. It connects naturally to reinforcement learning, where feedback encourages useful behavior and discourages harmful behavior. section 10.2 section 2.3

Finding a path through a maze

Imagine a 10-by-10 maze with barriers and a goal. Try paths by moving north, south, east, or west, then record whether each attempt reaches the goal and how many actions it takes. One attempt fails after four actions; four others succeed in 17, 23, 17, and 15 actions. The 15-action path is best among the attempts, although it was found by chance. A much larger maze makes manual trial and error exhausting, which motivates using search algorithms. section 2.3

The feedback loop can shape behavior in several ways:

  • Reward a desirable action, such as giving a dog a treat after it sits. section 10.2
  • Penalize an undesirable action, such as scolding a dog after it tears up a carpet. section 10.2
  • Improve future choices as experience reveals which actions lead to food, shorter digging time, or other desired outcomes. section 10.2

How Grokking AI Algorithms, Second Edition covers it

How deep it goes
Defines the technique through behavioral examples and a maze comparison, but stops short of implementing a search algorithm.
Examples
Uses chicks identifying food, chimpanzees choosing sticks, dog training, and competing paths through a maze.
What you can do after
Evaluate alternative actions by observing rewards, penalties, success, failure, and effort.
How it connects
Connects trial and error with reinforcement learning, behavioral psychology, rewards, penalties, and search algorithms.

Also explained in

Compare how 2 books explain trial and error →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking AI Algorithms, Second Edition. The section links point to the parts of the book it draws on.