1 % file: proglang_v3.pro 2 % line: some knowledge about pokemon 3 4 5 % pokemon(N, type(T),A, D, S). 6 % N = Name 7 % T = Type 8 % A = Attack 9 % D = Defense 10 % S = Speed 11 12 pokemon(eevee,type(normal),45,50,65). 13 pokemon(leafeon,type(leaf),30,45,48). 14 pokemon(espeon,type(psychic),45,61,47). 15 pokemon(flareon,type(fire),74,85,35). 16 pokemon(vaporeon,type(water),56,41,65). 17 pokemon(jolteon,type(electric),47,28,23). 18 pokemon(bulbasaur,type(leaf),52,78,37). 19 pokemon(squirtle,type(water),23,12,25). 20 pokemon(pikachu,type(electric),59,48,23). 21 pokemon(charmander,type(fire),21,89,14). 22 23 % Predicated based on rules 24 % 25 26 % Rules for listing pokemon by name 27 names :- pokemon(N,_,_,_,_), write(N),nl,fail. 28 names. 29 30 31 % Rules for listing pokemon by type 32 types :- pokemon(_,type(T),_,_,_), write(T),nl,fail. 33 types. 34 35 36 % Rules for listing pokemon by name and type 37 pokemons :- names, types. 38 pokemons. 39 40 %Rules for determining if a pokemon associated with the name is the correct type 41 leaf(N) :- pokemon(N, type(leaf),_,_,_). 42 fire(N) :- pokemon(N, type(fire),_,_,_). 43 water(N) :- pokemon(N, type(water),_,_,_). 44 electric(N) :- pokemon(N, type(electric),_,_,_). 45 normal(N) :- pokemon(N, type(normal),_,_,_). 46 psychic(N) :- pokemon(N, type(psychic),_,_,_). 47 48 49 50 % strong(N)/weakN) :: for defining pokemon by strong and weak attack 51 strongatk(N) :- pokemon(N, _, A,_,_), A >= 50. 52 weakatk(N) :- pokemon(N, _, A,_,_), A < 50. 53 54 % strongdef(N)/weakdef(N) :: for defining pokemon by strong and weak defence 55 strongdef(N):- pokemon(N, _,_,D,_), D >= 50. 56 weakdef(N) :- pokemon(N, _,_,D,_), D < 50. 57 58 % fast(N)/slow(N) :: for defining pokemon by slow and fast speed 59 fast(N) :- pokemon(N, _, _,_,S), S >= 50. 60 slow(N) :- pokemon(N, _, _,_,S), S < 50.