A06: Prolog Pokédex

This assignment helps you practice with Prolog. Your task is to write rules that encode the various game rules (gen VI / XY) regarding breeding. See below for the exact rules (in English) that need to be encoded.

Start with the code on londo in the directory /home/jeckroth/csci431/assignments/A06/. Write your code in the breeding.pl file. The files pok_facts.pl and pok_moves.pl have been pre-populated with facts (no rules) with data translated from this github project.

Breeding rules

The following rules are, to the best of my knowledge, accurate for the gen VI / XY games. Some special exceptions (e.g., involving legendary Pokémon) are not included for simplicity’s sake.

Two Pokémon can breed if,

Ditto is an exception to all of those rules. A Ditto can breed with any other non-Ditto Pokémon, as long as the other is an adult in its evolution.

The child Pokémon is the baby version of the species of the mother, except in the case of breeding with Ditto, in which case the child is the baby version of the non-Ditto parent.

Moves are inherited from the parents according to the following rules:

Ultimately, the baby will have at most four moves. Preference is given to Level Up moves.

Test cases

A series of test cases are given in breeding_tests.pl. Run the test cases with this londo command:

pl -s breeding_tests.pl -t run_tests

If the tests pass, you should see only some dots (1 dot per test group) and no error or warning messages.


Submit your breeding.pl file. Include the files breeding_tests.pl, pok_moves.pl, and pok_facts.pl as well, even though you do not need to modify them.

Note: You must not write any new facts. Only write rules. The files pok_facts.pl and pok_moves.pl have all the facts that are needed.

You’ll probably want to start your breeding.pl file like so:

:- [pok_facts]. % import pok_facts.pl
:- [pok_moves]. % import pok_moves.pl

Grading rubric

CSCI 431 material by Joshua Eckroth is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License. Source code for this website available at GitHub.