-
Notifications
You must be signed in to change notification settings - Fork 0
/
initiator.asl
62 lines (53 loc) · 1.3 KB
/
initiator.asl
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
// Agent initiator in project course_paper.mas2j
/* Initial beliefs and rules */
rows(15).
columns(15).
win(5).
/* Initial goals */
!initGame.
/* Plans */
@ig
+!initGame
: true
<- !initPlayers;
!initBoard(1, 1);
?rows(Rows);
.broadcast(tell, rows(Rows));
?columns(Columns);
.broadcast(tell, columns(Columns));
?win(W);
.broadcast(tell, win(W));
.broadcast(achieve, lookAround);
.wait(10);
!startGame.
@ib1
+!initBoard(X,Y)
: columns(MaxColumn) & Y <= MaxColumn & rows(MaxRow) & X <= MaxRow
<- .print("Initiating cell (", X, ",", Y, ")");
.concat("cell", X, "_", Y, Cell);
.create_agent(Cell, "cell.asl");
.send(Cell, tell, position(X,Y));
.send(Cell, achieve, lookAround);
!initBoard(X, Y + 1).
@ib2
+!initBoard(X,Y)
: columns(MaxColumn) & Y > MaxColumn
<- !initBoard(X + 1, 1).
@ib3
+!initBoard(X,Y)
: rows(MaxRow) & X > MaxRow
<- .print("Last row built, board complete.").
@ip
+!initPlayers
: true
<- .print("Initiating players");
.concat("player", 1, FirstPlayer);
.concat("player", 2, SecondPlayer);
.create_agent(FirstPlayer, "player.asl");
.create_agent(SecondPlayer, "player.asl");
.send(FirstPlayer, tell, going_first).
@sg
+!startGame
: true
<- .print("Players and board initiated, let the game begin!");
.broadcast(tell, begin).