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_moves.pl have been pre-populated with facts (no rules) with data translated from this github project.
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
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:
- if both parents know the same Level Up move and the baby can learn that move by levelling up, the baby can be born with that move (see the
- if either parent knows an Egg move that the baby can learn as an egg move but not learn by level up, the baby can be born with that move
Ultimately, the baby will have at most four moves. Preference is given to Level Up moves.
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.
breeding.pl file. Include the files
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_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
- 5 pts: All 8 tests pass with no warnings (no Singleton warnings, etc.).
- 4 pts: Between 5 and 7 tests pass with no warnings.
- 3 pts: 3 or 4 tests pass with no warnings.
- 2 pts: 1 or 2 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.