AppsGuidesAI DictionarySmall FixesOn RecordAboutFollow the lab

Heuristic

Also called rule of thumb

A heuristic is a rule of thumb: a quick, smart shortcut that usually finds a good answer without checking every possibility.

The basicsCurious

In plain words

Some problems have so many possible answers that checking them all would take a computer longer than a lifetime. Finding the shortest trip through 50 cities is one. So instead of trying everything, a program uses a rule of thumb that points it in the right direction.

That rule of thumb is a heuristic. On a map, a good one is: prefer roads that bring you closer to where you're going as the crow flies. It is not always right, since a road may curve away before it gets there, but it lets the program ignore most of the map and still find a sensible route quickly.

The word comes from the Greek for "to discover". In AI, heuristics guide searches in games, route planners and puzzle solvers. The trade is always the same: much more speed, for a small risk of missing the very best answer. People use heuristics too, every day, which is why psychologists study them as well.

Everyday example

Finding a shop in a new market

You're looking for a sweet shop in an unfamiliar bazaar. You don't walk every lane. You head toward the smell of frying jalebis and follow the crowd carrying boxes. Most of the time you get there fast. Now and then the smell leads you to the wrong stall. That shortcut, good but not perfect, is a heuristic.

Where the example breaks: Your nose works without thinking. A computer heuristic is a formula someone designed for one kind of problem, and a heuristic that works well for maps may be useless for chess.

Go deeper

How it actually works

In computing, a heuristic trades a guarantee for speed: it may give up finding the perfect answer, or any answer at all, in exchange for a good answer fast.

  1. The problem: too many options

    Many search problems grow explosively. Every extra city, move or choice multiplies the possibilities, so checking all of them is hopeless for real sizes, even for the fastest computers.

  2. Score the options with a guess

    A heuristic function gives each option a quick estimate of how promising it is, such as straight-line distance to the goal. The search then explores the most promising options first and leaves the rest for later, or never.

  3. A*: a heuristic with a guarantee

    The A* search method, published in 1968, adds the cost travelled so far to the heuristic's estimate of the cost remaining. If the estimate never overestimates, as straight-line distance never does on a map, A* is guaranteed to find the shortest path, usually while checking far fewer places.

  4. Heuristics inside bigger AI

    Game programs like AlphaGo combine search with learned estimates of which moves look good, a heuristic learned by a neural network rather than written by hand. Older expert systems were built from human rules of thumb. Antivirus software uses heuristic scanning to flag code that looks like known viruses.

Word origin
From the Greek heuriskein, "to discover"
Classic algorithm
A* search, published by Hart, Nilsson and Raphael of Stanford Research Institute in 1968, for the Shakey robot project
In psychology
A famous 1974 paper in Science, "Judgment under Uncertainty: Heuristics and Biases", showed how human shortcuts lead to predictable errors
The trade-off
Speed in exchange for no guarantee of the best possible answer

Questions people ask

What is a heuristic in simple words?

A rule of thumb: a quick, practical shortcut that usually works. In AI, it helps a program decide which options to try first so it can find a good answer without checking everything.

What is the difference between a heuristic and an algorithm?

An algorithm is any precise step-by-step procedure. A heuristic is a shortcut rule, often used inside an algorithm to guide it. An exact algorithm guarantees the best answer; a heuristic usually gives a good one faster.

What is an example of a heuristic in AI?

Route planning: estimate the remaining distance as a straight line and explore roads that reduce it first. In chess or Go, a program might estimate which positions look strong without playing every game to the end.

What are heuristics in psychology?

Mental shortcuts people use to make quick judgements, such as judging how common something is by how easily examples come to mind. They usually work but cause predictable mistakes, called biases.

What does heuristic mean in antivirus software?

Heuristic scanning looks for code or behaviour that resembles known viruses, instead of matching an exact signature. It can catch new, self-changing variants that exact matching would miss.

Was this clear?

1 is confusing, 5 is crystal clear. One tap, no account needed.

Spotted something wrong, or know a better example? Suggest a change

Further reading