GitHub - alexpetros/prologdex: Pokemon Draft tools in Prolog

2 min read Original article ↗

Prologdex

A prolog-based Pokemon Draft database. It has the goal of eventually being a general, wasm-based web tool.

Right now it mostly lets me query facts about my current draft league.

Installation

  1. Install the rust toolchain
  2. Run cargo install scryer-prolog just

Usage

just starts the prolog engine.

Prolog tries to "unify" your queries by coming up with all possible matches for the given variables. Variables are denoted by names that start with uppercase letters, and facts start with lowercase ones. The dex.pl database contains facts with basic Pokedex info.

pokemon(zapdos).

type(zapdos, electric).
type(zapdos, flying).

learns(zapdos, defog).
learns(zapdos, hurricane).
% and so on

You can ask who all the pokemon on Morry's team are with the following query:

% Get morry's team
morry(Pokemon).

The interactive shell will then present you with one possible match:

?- morry(Pokemon).
   Pokemon = mawilemega

From here, you can control what to do based on hitting certain keys:

  • a - show all the solutions
  • n - show the next solution
  • . - stop showing solutions
  • h - show the help message

So if you press a, you'll see (at the time of this writing):

?- morry(Pokemon).
   Pokemon = mawilemega
;  Pokemon = walkingwake
;  Pokemon = zapdos
;  Pokemon = ursaluna
;  Pokemon = lokix
;  Pokemon = alakazam
;  Pokemon = skarmory
;  Pokemon = froslass
;  Pokemon = carbink
;  Pokemon = dipplin.
?-

A couple other queries I've been using:

% Which undrafted steel types learn Volt Switch?
undrafted(Mon), type(Mon, steel), learns(Mon, voltswitch).

% Which draft mons have removal?
drafted(Mon), learns_removal(Mon).

% The point value of Morry's draft
total_points(morry, Points).

% The remaining points in Morry's draft
total_points(morry, Points), Remaining is 90 - Points.

% The remaining points in everyone's drafts
total_points(Player, Points), Remaining is 90 - Points.

The structure is still messy, but most of the season 6 draft facts, such as the draft board and people's teams, can be found in s6.pl.

Other resources