Prolog Basics Explained with Pokémon
The project that inspired this post is a little silly—I am about to describe the mechanics of a children’s video game in great detail—but this particular problem is what finally made Prolog click for me, an epiphany I’ve been hunting for ever since reading Bruce Tate’s “Seven Languages in Seven Weeks.”
This exercise has taught me a lot about the kinds of interfaces I’m trying to build in somewhat more practical domains. For certain kinds of relationships, logic programming is by far the most concise and expressive programming system I’ve ever used.
To understand why, let’s talk about Pokémon.
Pokémon basics
Pokémon is a video game series/multimedia franchise/lifestyle brand set in a world where humans live alongside a menagerie of colorful animal characters.
“Pokémon” is both the name of the franchise and the generic term for the animal characters themselves, which all have their own individual species names. There are over a thousand distinct species of Pokémon, from Bulbasaur (#1) to Pecharunt (#1025).
Popular Pokémon include (from left to right):
Pikachu (#25), Archeops (#567) , and Dipplin (#1101).
I rarely include images on this blog and I am very excited that this post warrants them.
There are all sorts of Pokémon games now, but the main series has always been about catching and battling them. During a battle, your team of six Pokémon faces off against another team. Each Pokémon is equipped with four moves that it can choose to (usually) do damage to their opponent. You need to reduce the HP (Hit Points) of all your opponent’s Pokémon to zero before they are able to do so to you.
Each Pokémon has unique traits that affects how it battles. They have a set of base stats, a large pool of possible moves, a handful of abilities, and a typing. As you will see in a moment, the immense number of combinations here is the motivation for trying to track this with software.
Scizor is a Bug/Steel type with high Attack and low Speed (via Smogon)
Speed controls which…