This assignment uses Prolog and the biductive computing paradigm to allow a user to query a Pokémon database, i.e., a Pokédex. 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 rather than code) that need to be encoded.
Refer to the code linked at the bottom of this page. Write your code in a new file
breeding_nomoves.pl. The file
pok_facts.pl has been pre-populated with facts (no rules) with data translated from this GitHub project.
The following rules are mostly 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 resulting 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.
You will write rules with the following names and arguments:
species_base_evolution(Species, BaseSpecies)— gives the base or first evolution of a given species, e.g., the base species of Raichu is Pichu.
can_breed(MaleSpecies, FemaleSpecies)— indicates that two species can breed based on their evolutionary status (adult or not), genders, and egg groups; for example, Arbok and Charizard can breed but Claydol and Charizard cannot.
child_pok(Male, Female, ChildPok)— gives the type of child Pokémon resulting from breeding the two parents, e.g., the child of Mantine and Swanna is Ducklett.
Each of the three required rules listed above may be used with an arbitrary mix of variable arguments and arguments with fixed values. For example,
can_breed(MaleSpecies, claydol) will find a male Pokémon that can breed with Claydol, while
child_pok(ditto, Female, seel) will find a female Pokémon that can breed with a Ditto to have a child Seel.
A series of test cases are given in
breeding_tests_nomoves.pl. Run the test cases with this 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.
breeding_nomoves.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 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
This assignment can be more difficult by introducing logic about inherited Pokémon moves. There are different types of moves, e.g., Level Up moves and Egg Moves. Some 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. The file
breeding_tests.pl includes test cases about moves, and
pok_moves.pl includes the long list of move facts.