-
Notifications
You must be signed in to change notification settings - Fork 0
/
is_move_conflict.m
103 lines (96 loc) · 2.84 KB
/
is_move_conflict.m
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
function [is_conflict] = is_move_conflict(v1, v2, direction)
%IS_MOVE_CONFLICT 判断两个移动方向是否冲突,direction为在左方还是右方
% 此处显示详细说明
conf = config();
is_conflict = 0;
switch v1
case conf.MOVE_LEFTUP
if v2 == conf.MOVE_RIGHTDOWN
is_conflict = 1;
else
if direction == conf.DIRECTION_LEFT
is_conflict = is_move_contains(conf.MOVE_RIGHTUP, v2);
end
if direction == conf.DIRECTION_RIGHT
is_conflict = is_move_contains(conf.MOVE_LEFTDOWN, v2);
end
end
case conf.MOVE_LEFTDOWN
if v2 == conf.MOVE_RIGHTUP
is_conflict = 1;
else
if direction == conf.DIRECTION_LEFT
is_conflict = is_move_contains(conf.MOVE_LEFTUP, v2);
end
if direction == conf.DIRECTION_RIGHT
is_conflict = is_move_contains(conf.MOVE_RIGHTDOWN, v2);
end
end
case conf.MOVE_RIGHTUP
if v2 == conf.MOVE_LEFTDOWN
is_conflict = 1;
else
if direction == conf.DIRECTION_LEFT
is_conflict = is_move_contains(conf.MOVE_RIGHTDOWN, v2);
end
if direction == conf.DIRECTION_RIGHT
is_conflict = is_move_contains(conf.MOVE_LEFTUP, v2);
end
end
case conf.MOVE_RIGHTDOWN
if v2 == conf.MOVE_LEFTUP
is_conflict = 1;
else
if direction == conf.DIRECTION_LEFT
is_conflict = is_move_contains(conf.MOVE_LEFTDOWN, v2);
end
if direction == conf.DIRECTION_RIGHT
is_conflict = is_move_contains(conf.MOVE_RIGHTUP, v2);
end
end
case conf.MOVE_UP
if v2 == conf.MOVE_DOWN
is_conflict = 1;
else
if direction == conf.DIRECTION_LEFT
is_conflict = is_move_contains(conf.MOVE_RIGHT, v2);
end
if direction == conf.DIRECTION_RIGHT
is_conflict = is_move_contains(conf.MOVE_LEFT, v2);
end
end
case conf.MOVE_DOWN
if v2 == conf.MOVE_UP
is_conflict = 1;
else
if direction == conf.DIRECTION_LEFT
is_conflict = is_move_contains(conf.MOVE_LEFT, v2);
end
if direction == conf.DIRECTION_RIGHT
is_conflict = is_move_contains(conf.MOVE_RIGHT, v2);
end
end
case conf.MOVE_LEFT
if v2 == conf.MOVE_RIGHT
is_conflict = 1;
else
if direction == conf.DIRECTION_LEFT
is_conflict = is_move_contains(conf.MOVE_UP, v2);
end
if direction == conf.DIRECTION_RIGHT
is_conflict = is_move_contains(conf.MOVE_DOWN, v2);
end
end
case conf.MOVE_RIGHT
if v2 == conf.MOVE_LEFT
is_conflict = 1;
else
if direction == conf.DIRECTION_LEFT
is_conflict = is_move_contains(conf.MOVE_DOWN, v2);
end
if direction == conf.DIRECTION_RIGHT
is_conflict = is_move_contains(conf.MOVE_UP, v2);
end
end
end
end