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.

12 thoughts on “Prolog Via Pokémon

  1. That’s fascinating! I remember reading about AI and LISP..
    I think my late 80s books also mentioned Fortran?!
    Expert systems were great for database applications, I remember.
    There was Q&A, Question and Answer, for example. Ran on IBM PCs.

  2. Prolog enables people to realise they should choose the right tool for a job. It makes it easy to express one type of problem/design in a natural way, whereas trying to do it in C would be very obscure and difficult. Too often people don’t realise that, and end up realising Greenspun’s tenth rule: “Any sufficiently complicated C or Fortran program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp. ”

    Prolog is a notably simple language, even simpler than Smalltalk – which was the progenitor of everything you see in modern computing.

      1. Well, yes… but I did write “see” :)

        As the saying goes, Algol was an improvement on most of its successors.

        I learned programming on Tony Hoare’s Algol-60 compiler. Still remember the light bulb illuminating when I realised what the compiler was actually doing. Saw one of those 39-bit computers running only last Sunday :)

  3. My problem with prolog always was that you needed (still need?? I didn’t touch it ~10years) to know how it works internally to write efficient queries. It was quite slow even on small data, if it was queried wrong way.

  4. Ah what a blast from the past! I used Turbo Prolog to create my first chat bot (yikes a couple of decades ago now lol) It is a really fun language compared to some. Good to see it is still getting some love :)

  5. I had to implement several different algorithms in several different programming languages for one of my classes at university, prolog was one of the languages. I don’t recall any of my classmates eking any enjoyment from prolog.

  6. Scene: mid-1980s. A university instructor and a grad student have been tapped to teach computer science to a group of gifted and talented teens. Difficulty: in that day, some of them had been programming for years, and some had never touched a computer. What do?

    Brilliant solution: we’ll teach them PROLOG! That way none of them will be bored or left behind, because none of them will know what’s going on. Including, to some extent, the instructor and the great student.

    Not, I think, one of the program’s finest hours. But I, as the grad student in question, did get to give the last lecture, and I talked about where it all was going as computers kept getting faster and cheaper. The stuff I said about graphics is old news now. The stuff I said about AI – well, that was mostly a rehash of Vernor Vinge, and we’ve seen how that’s unfolding. The kids ate it up.

    I sometimes wonder if any of them remember that final lecture. I don’t find myself wondering if they remember any Prolog.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.