summaryrefslogtreecommitdiff
path: root/command.prolog
blob: b8989f407bb1474a1b9ded30c6192404e6af048d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47


:- module(command, [getCommand/2]).


:- consult('parser.prolog').




% functions for parsing a list of words into a recognised command

getCommand(['quit'],C) :- C = [quit].
getCommand(['exit'],C) :- C = [quit].


getCommand(['go',X],C) :- C = [move,X].
getCommand(['move',X],C) :- C = [move,X].


getCommand(['n'],C) :- C = [move,north].
getCommand(['north'],C) :- C = [move,north].
getCommand(['s'],C) :- C = [move,south].
getCommand(['south'],C) :- C = [move,south].
getCommand(['e'],C) :- C = [move,east].
getCommand(['east'],C) :- C = [move,east].
getCommand(['w'],C) :- C = [move,west].
getCommand(['west'],C) :- C = [move,west].


getCommand(['nw'],C) :- C = [move,northwest].
getCommand(['northwest'],C) :- C = [move,northwest].
getCommand(['ne'],C) :- C = [move,northeast].
getCommand(['northeast'],C) :- C = [move,northeast].
getCommand(['sw'],C) :- C = [move,southwest].
getCommand(['southwest'],C) :- C = [move,southwest].
getCommand(['se'],C) :- C = [move,southeast].
getCommand(['southeast'],C) :- C = [move,southeast].


getCommand(['take',X],C) :- C = [take,X].
getCommand(['shoot',X],C) :- C = [shoot,X].


getCommand(['l'],C) :- C = [look].
getCommand(['look'],C) :- C = [look].