What i'm trying to do is:
Given a list of characters to know which list best contradicts it, so image I put on the list [kraken,scorpia,zulrah] so it will check the type of attack of each and would see would be the most effective type of attack for each and with that, I would receive a list of 3 bosses.
% boss(Name, Type) Name = Name of boss, Type = Attack type
boss(kraken,magic).
boss(scorpia,melee).
boss(zulrah,ranged).
boss(cerberus,melee).
boss(abyssal_sire,melee).
boss(obor,melee).
boss(sarachnis,ranged).
boss(skotizo,melee).
boss(venenatis,magic).
superEffective(magic,melee). %magic is more effective against melee
superEffective(ranged,magic). %ranged is more effective against magic
superEffective(melee,ranged). %melee is more effective against ranged
First, create a predicate to verify the counter of a single Boss:
Notice that this predicate will get always the first best counter to the input boss. If you want all the possible combinations, just delete the
, !at the end.Second, use recursion to iterate over the input list and build the output list. You can use
append/3to append the output array.If necessary, you can define the
append/3function at the top of your code like this:Examples
Single output:
List input:
Full code: