Dear User,
Quote:
> This function that will determine if all 4 players are in the first room and
> nobody is in the second room
> Here is the state I want to check.
> [ [alice, mary, john, joe], [] ]
> 1. I want to check if the input provided is equal to the above state.
There is no one way to do it, of course. It appears that you have only 2
rooms. You may want to represent who is in them by a tuple rather than a
list, such as in_rooms(Room1,Room2), where Room1 and Room2 are lists of
the people in each room. Then if you want to check whether PlayerA is in
Room1, you can use memberchk(PlayerA, Room1). If you want to check that
Room2 is empty, you can use
Room2 == []. You may also be able to use unification. For instance, if
the lists of players are alphabetized, then you can just see if
in_rooms(Room1,Room2) = in_rooms([alice,joe,john,mary],[]).
Of course, you would probably use unification through matching.
Good luck!
Bill