-
Notifications
You must be signed in to change notification settings - Fork 0
/
board.pl
118 lines (98 loc) · 3.82 KB
/
board.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
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
:- use_module(library(lists)).
/*BOARD INICICIALMENTE VAZIA*/
hexBoard0(Board) :- Board =
[ [[' '], [' '],[' '], [' '],
[' ']],
[[' '], [' '],[' '], [' '],
[' '], [' ']],
[[' '], [' '],[' '], [' '],
[' '], [' '],[' ']],
[[' '], [' '],[' '], [' '],
[' '], [' '],[' '], [' ']],
[[' '], [' '],[' '], [' '],
[' '], [' '],[' '], [' '],
[' ']],
[[' '], [' '],[' '], [' '],
[' '], [' '],[' '], [' ']],
[[' '], [' '],[' '], [' '],
[' '], [' '],[' ']],
[[' '], [' '],[' '], [' '],
[' '], [' ']],
[[' '], [' '],[' '], [' '],
[' ']]
].
/*BOARD COM UM JOGO A DECORRER*/
hexBoard1(Board) :- Board =
[ [['B'], [' '],[' '], [' '],[' ']],
[[' '], [' '],['R'], [' '],[' '], [' ']],
[['R'], ['Y'],['Y'], [' '],['B'], ['B'],[' ']],
[['G'], ['R'],['R'], ['Y'],['Y'], ['Y'],['B'], [' ']],
[['R'], ['R'],['R'], ['Y'],['G'], ['G'],['G'], ['B'], [' ']],
[['B'], ['G'],['Y'], ['G'],['G'], ['B'],['B'], [' ']],
[['B'], ['B'],['B'], ['B'],['B'], [' '],['B']],
[[' '], [' '],[' '], [' '],[' '], [' ']],
[[' '], [' '],[' '], ['G'],[' ']]
].
/*BOARD COM APENAS A PEÇA INICIAL*/
hexBoard2(Board) :- Board =
[ [[' '], [' '],[' '], [' '],[' ']],
[[' '], [' '],[' '], [' '],[' '], [' ']],
[[' '], [' '],[' '], [' '],[' '], [' '],[' ']],
[[' '], [' '],[' '], [' '],[' '], [' '],[' '], [' ']],
[[' '], [' '],[' '], [' '],[' '], [' '],[' '], [' '], [' ']],
[[' '], [' '],[' '], [' '],[' '], [' '],[' '], [' ']],
[[' '], [' '],['B'], [' '],[' '], [' '],[' ']],
[[' '], [' '],[' '], [' '],[' '], [' ']],
[[' '], [' '],[' '], [' '],[' ']]
].
/*BOARD COM O FIM DE JOGO 1- 15 PEÇAS DA MESMA COR NO TABULEIRO*/
hexBoard3(Board) :- Board =
[ [['B'], ['R'],['R'], ['R'],['R']],
[['R'], ['R'],['R'], ['R'],[' '], [' ']],
[['R'], ['Y'],['Y'], ['R'],['B'], ['B'],[' ']],
[['G'], ['R'],['R'], ['Y'],['Y'], ['Y'],['B'], [' ']],
[['R'], ['R'],['R'], ['Y'],['G'], ['G'],['G'], ['B'], [' ']],
[['B'], ['G'],['Y'], ['G'],['G'], ['B'],['B'], [' ']],
[['B'], ['B'],['B'], ['B'],['B'], [' '],['B']],
[[' '], [' '],[' '], [' '],[' '], [' ']],
[[' '], [' '],[' '], ['G'],[' ']]
].
/*BOARD COM O FIM DE JOGO 2- EMPATE COM O MAIOR GRUPO*/
hexBoard4(Board) :- Board =
[ [['B'], ['G'],['G'], ['Y'],['G']],
[['G'], ['G'],['R'], ['Y'],['Y'], ['Y']],
[['R'], ['Y'],['Y'], ['Y'],['B'], ['B'],['Y']],
[['G'], ['R'],['R'], ['Y'],['Y'], ['Y'],['B'], ['Y']],
[['R'], ['R'],['R'], ['Y'],['G'], ['G'],['G'], ['B'], [' ']],
[['B'], ['G'],['Y'], ['G'],['G'], ['B'],['B'], [' ']],
[['B'], ['B'],['B'], ['B'],['B'], ['R'],['B']],
[['G'], ['R'],['R'], ['R'],['R'], [' ']],
[[' '], [' '],['R'], ['G'],['R']]
].
drawBoard(Board) :- secundaryDrawBoard(Board, 0).
secundaryDrawBoard([Line | Board], Number) :- Board \= [],
drawIdentation(Number), displayBoarder(Line),
drawIdentation(Number), displayLine(Line),
NewNumber is Number+1,
secundaryDrawBoard(Board, NewNumber).
secundaryDrawBoard([Line], Number) :- drawIdentation(Number), displayBoarder(Line),
drawIdentation(Number), displayLine(Line),
drawIdentation(Number), displayBoarder(Line).
displayBoarder([_|Line]) :- write(' *---'), displayAuxBorder(Line).
displayAuxBorder([]) :- write('*\n').
displayAuxBorder([_|Line]) :- write('*---'), displayAuxBorder(Line).
writeAuxLine([]) :- write('|\n').
writeAuxLine([Elem|Line]) :- write('|'), writeSymbol(Elem),
writeAuxLine(Line).
displayLine(Line) :- write(' '), write(' '), write(' '),
writeAuxLine(Line).
writeSymbol([Color]) :- write(' '), write(Color), write(' ').
drawIdentation(0) :- write(' ').
drawIdentation(1) :- write(' ').
drawIdentation(2) :- write(' ').
drawIdentation(3) :- write(' ').
drawIdentation(4) :- write('').
drawIdentation(5) :- write(' ').
drawIdentation(6) :- write(' ').
drawIdentation(7) :- write(' ').
drawIdentation(8) :- write(' ').