Problem description
A popular fictional monster battling game features a type system that is used to determine the effectiveness of a monster’s ability to attack or defend against another monster. In this coursework you will write a Prolog program to represent knowledge about this system and to answer queries using the resulting knowledge base.
The version of the game we will use includes five monsters: charmander, bulbasaur, squirtle, pikachu, and eevee. Each monster can be one of five basic types: fire, grass, water, electric, and normal. Each monster has four abilities that it can use. Each ability is also assigned one of the basic types. The details of each monster, its type, its abilities, and the ability types are given in the following table:
Monster
Monster type
Ability
Ability type
charmander
fire
scratch fireFang firePunch thunderPunch
normal fire fire electric
bulbasaur
grass
tackle vineWhip razorLeaf solarBeam
normal grass grass grass
squirtle
water
tackle waterPulse aquaTail bodySlam
normal water water normal
pikachu
electric
thunderPunch surf grassKnot thunderbolt
electric water grass electric
eevee
normal
rainDance sunnyDay bite lastResort
water fire normal normal
E.g., charmander is a fire type monster with four abilities: scratch (a normal type ability), fireFang (a fire type ability), firePunch (a fire type ability), and thunderPunch (an electric type ability).
The effectiveness of a monster’s ability when used on another monster depends on the ability type (of the monster using the ability) and the monster type (of the monster the ability is being used on). Certain abilities are super effective against certain types of monsters while other abilities are weak against other monster types. The effectiveness of an ability type against a monster type is represented in the following table:
ability \ monster
fire
water
electric
grass
normal
normal
ordinary
ordinary
ordinary
ordinary
ordinary
fire
weak
weak
ordinary
super
ordinary
water
super
weak
ordinary
weak
ordinary
electric
ordinary
super
weak
weak
ordinary
grass
weak
super
ordinary
weak
ordinary
E.g., a fire type ability is weak against water type monsters but a water type ability is super against fire type monsters. Combinations that aren’t super or weak are ordinary.
What to do
Write a Prolog program to represent the knowledge in the monster game according to the following specification:
1. Encode information about the monsters and their abilities using Prolog facts of the following form:
− type(t): to represent the idea that t is a basic type.
− monster(m,tm): to represent the idea that m is a monster of type tm.
− ability(a,ta): to represent the idea that a is an ability of type ta.
− monsterAbility(m,a): to represent the idea that monster m has an ability a.
2. Encode effectiveness information using Prolog facts of the form typeEffectiveness(ta,tm,e): an ability of type ta has effectiveness e against monsters of type tm.
3. Define a Prolog rule called abilityEffectiveness(A,M,E) to represent the idea that E is the effectiveness of an ability A against a monster M. A, M, and E should be variables in your rule definition.
4. Define a Prolog rule called superAbility(M1,A,M2) to represent the idea that ability A is a super effective ability for monster M1 to use against monster M2. M1, A, and M2 should be variables in your rule definition.
5. Define a Prolog rule called typeAbility(M,A) to represent the idea that ability A is an ability of monster M and that M and A have the same type. M and A should be variables in your rule definition.
6. Define a Prolog rule called moreEffectiveAbility(A1,A2,T) to represent the idea that ability A1 is more effective than ability A2 against monsters of type T: ordinary is more effective than weak, and super is more effective than ordinary and weak. A1, A2, and T should be variables in your rule definition.
7. Define a Prolog rule called counterAbility(M1,A1,M2,A2) to represent the idea that if monster M1 performs ability A1 and monster M2 performs ability A2 that A2 is a more effective than A1: ordinary is more effective than weak, and super is more effective than ordinary and weak. M1, A1, M2, and A2 should be variables in your rule definition.
NOTE: For parts 3-7 of the specification, ensure that you write Prolog rules. You should not implement Prolog facts as your solution for these parts and you will lose marks if you do this. However, it is okay if need to write multiple rules for each definition. If you are interested, the game mechanics in this coursework are based on information from https://pokemondb.net/.
What to hand in
• Prolog program file: Submit a single Prolog program file with all your Prolog facts and rules. Ensure that the file is a plain text file with the name monster.pl. Make sure there are comments in your program file to describe the different parts of your program
• Output file: Test your program by selecting a series of Prolog queries to demonstrate the various facts and rules you have implemented. Capture the queries and output to a text file. Include at least 10 queries in your output file. Ensure that the file is a plain text file with the name output.txt.