A01: 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/A01/. Write your code in the breeding_nomoves.pl file. The file pok_facts.pl has 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,

  • both parents are adults in their species evolution (note, this doesn’t match how the game actually works)
  • neither parent is genderless
  • both parents have the same egg group, and that group is not no_eggs

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.

Test cases

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

swipl -q -s breeding_tests_nomoves.pl -t run_tests

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


Submit your breeding_nomoves.pl file. Include the files breeding_tests_nomoves.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 file pok_facts.pl has all the facts that are needed.

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

:- [pok_facts]. % import pok_facts.pl

Grading rubric

  • 5 pts: All tests pass with no warnings (no Singleton warnings, etc.).
  • 4 pts: At least 80% of tests pass with no warnings.
  • 3 pts: At least 60% tests pass with no warnings.
  • 2 pts: At least 40% tests pass with no warnings, or more tests pass with warnings.
  • 1 pt: No tests pass, but code has no syntax or logic errors (i.e., the code can be loaded and queried).
  • 0 pts: Code has syntax or logic errors, cannot be loaded and/or queried, or missing submission.

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.