The first set of exercises continues with the world of caves from Supplement 2. Suppose that, as in many computer Adventure games, the world is populated by vicious animals, all inimical to human life. Each animal has a worth:
There are weapons, each with its own destructive power:
We say, in a way typical of such games, that a weapon W can
kill an animal A
if W has more power than A is worth. Express this as
a predicate can_kill(W,A)
which is true if weapon W can kill animal
A.
Assume also that the player can pick up and use weapons. Let the fact
mean that Fred is holding a gun: in general, let holds(P,W)
be true if
player P is holding weapon W. Can you now define a predicate
scorns(P,A)
which is true if player P holds a strong enough weapon to
kill animal A?
These are all applications of comparisons and ``and''.