# define a cat animal parentanimal[cat] cat:size[10] cat:speed[15] # leave a cat's social values as the defaults # define a velociraptor parentanimal[raptor] raptor:size[20] raptor:speed[40] # do not mess with raptors. raptor:scariness[100] raptor:aggression[85] raptor:social[20] # define a couple of cats cat[steve] cat[vlad] steve:size[12] steve:aggression[65] vlad:social[raptor:scariness] # define a raptor raptor[fiona] # define a unique animal animal[squeek] squeek:size[4] squeek:speed[cat:speed] squeek:scariness[2] squeek:aggression[5] squeek:social[50] # define some possible actions, remember walk is defined by default action[befriend] action[attack] # This action is defined, but never actually given a query to evaluate # It shouldn't show up in the .cpp file action[explode] # create some queries so we can perform the actions # befriend if the animal is sociable, and if it is not scared of the other animal isSocial[A] ? A:social > 50 isScarier[A,B] ? A:scariness > B:scariness isSmaller[A,B] ? A:size < B:size isNotScared[A,B] ? isScarier[A,B] | isSmaller[B,A] befriend[A,B] ? isSocial[A] & isNotScared[A,B] # attack animals if you are unfriendly, and they are slow isSlower[A,B] ? A:speed < B:speed isUnsocial[A] ? A:social < 30 isUnfriendly[B,A] ? isUnsocial[B] & A:scariness < B:aggression attack[A,B] ? isSlower[B,A] | isSmaller[B,A] & isUnfriendly[A,B]