-
Notifications
You must be signed in to change notification settings - Fork 0
/
play_can_do.pl
49 lines (34 loc) · 1.03 KB
/
play_can_do.pl
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
% cell(BugType, Row, Column, Color, StackPosition, InGame)
:- module(play_can_do, [play_can_do/2]).
:- use_module(game).
:- use_module(bug_can_move).
:- use_module(bug_can_power).
:- use_module(win).
play_can_do(_, []) :-
game_finished(_).
play_can_do(Color, Plays) :-
not(game_finished(_)),
can_put(Color, Put),
can_move(Color, Move),
can_power(Color, Power),
append([Put, Move, Power], Plays).
can_move(Color, []) :-
cell(queen, _, _, Color, _, false).
can_move(Color, X) :-
cell(queen, _, _, Color, _, true),
bug_can_move_only_one(Color, BugCanMove),
can_move2(BugCanMove, X).
can_move2([], []).
can_move2([_|_], [move]).
can_put(Color, []) :-
not(cell(_, _, _, Color, _, false)).
can_put(Color, [put]) :-
cell(_, _, _, Color, _, false).
can_power(Color, []) :-
cell(queen, _, _, Color, _, false).
can_power(Color, X) :-
cell(queen, _, _, Color, _, true),
bug_can_power_only_one(Color, BugCanPower),
can_power2(BugCanPower, X).
can_power2([], []).
can_power2([_|_], [power]).