Breaking

Monday, 18 May 2026

Prolog Via Pokémon

Like many people who read Hackaday, we are fairly fluent in a number of computer languages, but we have to admit it is easier to pick up languages that look like they group with things like Fortran. Sure, modern languages have all sorts of features, but the idea that you have a text file that executes in some order, variables, statements, and so on runs through most popular languages, but not all of them. Lisp and its variants are a different way of looking at things. And then there’s Prolog. [Alexander Petros] has an interesting way of explaining Prolog as a Pokémon game.

Prolog was “the next big thing” when AI meant expert systems. It is more of a specialized database where you define facts and rules that the computer can infer answers to queries. For example, if the facts say that Paul and Anna both have Mary as a parent, and a rule says that people with the same parent are siblings, then a query asking whether Paul and Anna are siblings will indicate that they are.

How does this relate to Pokémon? The classic card game pits teams of different characters against each other, and each has particular traits and moves. Prolog is well-suited to expressing situations like this, where there are many facts and rules about how they relate to one another.

In the example, characters like Bulbasaur and Squirtle are known to be pokemon. Each character can have one or more types (e.g., Bulbasaur is both a grass and poison type). Then, rules can define things like the types of moves and traits each character has. The way Prolog works, you can provide a variable as part of a query and get lists of matches, much like a database.

We didn’t see [Alex] mention the cut operator, and many people do not like to use it. There are probably other parts of Prolog left out, too, like backtracking. However, this is as good a place to start as any, and the example is exactly the sort of problem that Prolog is good at.

If you really prefer C, you can mix C and Prolog. We can’t imagine how it worked, but there was even a computer with a Prolog operating system.



No comments:

Post a Comment