-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrules.ansp
53 lines (46 loc) · 2.35 KB
/
rules.ansp
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
% Map size
#const size=8.
dimension(0..size).
% One tile for every point (X,Y).
1 { tile(X,Y,ID) :inst_id(ID) } 1 :- dimension(X;Y).
% In Carcassonne, you always start with this particular tile
% We'll just put it in the centre of the map.
#const start_id=12.
tile(size/2,size/2,start_id).
% Edge types of adjacent tiles must be the same
:- tile(X,Y,ID), tile_inst(ID,Top,Bot,Left,Right),
tile(X-1,Y,ID2), tile_inst(ID2,Top2,Bot2,Left2,Right2),
Left != Right2.
:- tile(X,Y,ID), tile_inst(ID,Top,Bot,Left,Right),
tile(X,Y-1,ID2), tile_inst(ID2,Top2,Bot2,Left2,Right2),
Top != Bot2.
% Just for fun, all edges of the world must have grass
:- tile(0,Y,ID), tile_inst(ID,Top,Bot,Left,Right), Left != grass.
:- tile(size-1,Y,ID), tile_inst(ID,Top,Bot,Left,Right), Right != grass.
:- tile(X,0,ID), tile_inst(ID,Top,Bot,Left,Right), Top != grass.
:- tile(X,size-1,ID), tile_inst(ID,Top,Bot,Left,Right), Bot != grass.
% Use no more than the number of tiles provided in Carcassonne.
:- 6 { tile(X,Y,ID) :tile_inst(ID,L,R,T,B) :tile_type(0,L,R,T,B) }.
:- 4 { tile(X,Y,ID) :tile_inst(ID,L,R,T,B) :tile_type(1,L,R,T,B) }.
:- 4 { tile(X,Y,ID) :tile_inst(ID,L,R,T,B) :tile_type(2,L,R,T,B) }.
:- 5 { tile(X,Y,ID) :tile_inst(ID,L,R,T,B) :tile_type(3,L,R,T,B) }.
:- 3 { tile(X,Y,ID) :tile_inst(ID,L,R,T,B) :tile_type(4,L,R,T,B) }.
:- 2 { tile(X,Y,ID) :tile_inst(ID,L,R,T,B) :tile_type(5,L,R,T,B) }.
:- 10 { tile(X,Y,ID) :tile_inst(ID,L,R,T,B) :tile_type(6,L,R,T,B) }.
:- 9 { tile(X,Y,ID) :tile_inst(ID,L,R,T,B) :tile_type(7,L,R,T,B) }.
:- 5 { tile(X,Y,ID) :tile_inst(ID,L,R,T,B) :tile_type(8,L,R,T,B) }.
:- 2 { tile(X,Y,ID) :tile_inst(ID,L,R,T,B) :tile_type(9,L,R,T,B) }.
:- 5 { tile(X,Y,ID) :tile_inst(ID,L,R,T,B) :tile_type(10,L,R,T,B) }.
:- 4 { tile(X,Y,ID) :tile_inst(ID,L,R,T,B) :tile_type(11,L,R,T,B) }.
:- 3 { tile(X,Y,ID) :tile_inst(ID,L,R,T,B) :tile_type(12,L,R,T,B) }.
:- 6 { tile(X,Y,ID) :tile_inst(ID,L,R,T,B) :tile_type(13,L,R,T,B) }.
:- 5 { tile(X,Y,ID) :tile_inst(ID,L,R,T,B) :tile_type(14,L,R,T,B) }.
:- 4 { tile(X,Y,ID) :tile_inst(ID,L,R,T,B) :tile_type(15,L,R,T,B) }.
:- 4 { tile(X,Y,ID) :tile_inst(ID,L,R,T,B) :tile_type(16,L,R,T,B) }.
:- 4 { tile(X,Y,ID) :tile_inst(ID,L,R,T,B) :tile_type(17,L,R,T,B) }.
:- 6 { tile(X,Y,ID) :tile_inst(ID,L,R,T,B) :tile_type(18,L,R,T,B) }.
% Make parsing the output a little simpler.
#hide.
#show dimension/1.
#show tile/3.
#show tileset/2.