Skip to content

Commit a68d17a

Browse files
committed
Wrote nice comments in the code to explain the pirates demo
1 parent 3b6cbe8 commit a68d17a

3 files changed

Lines changed: 23 additions & 2 deletions

File tree

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,8 @@ pirates:
211211
--model=demo/pirates/alice.pml \
212212
--phi=demo/pirates/phi.pml \
213213
--Q=demo/pirates/bob.pml \
214-
--IO=demo/pirates/IO.txt \
215-
--max_attacks=10 \
214+
--IO=demo/pirates/IO.txt \
215+
--max_attacks=1 \
216216
--with_recovery=True \
217217
--name=pirates \
218218
--characterize=True

demo/pirates/alice.pml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,29 @@ bool aliceRetired = false
88
active proctype alice() {
99
SCOPING:
1010
if
11+
/* When Alice is scoping for Bob, as soon as she
12+
* notices him, she immediately attacks, _regardless_
13+
* of what flags he waves.
14+
*/
1115
:: bob2alice ? _ -> goto PIRATESTUFF;
1216
fi
1317
PIRATESTUFF:
18+
/* When Alice attacks, she first hoists the pirate
19+
* flag, to make it clear that she is, in fact, a big
20+
* scary pirate.
21+
*/
1422
alice2bob ! pirate;
1523
if
24+
/* If Bob shows the white flag of surrender then Alice
25+
* takes his loot and then returns to the high sea to
26+
* scope for another ship to plunder.
27+
*/
1628
:: bob2alice ? white -> goto SCOPING;
29+
/* On the other hand, if Bob hoists the official colors of
30+
* Her Majesty's Royal Navy, then Alice will surrender,
31+
* because she knows that she is no match for the Royal
32+
* Navy in battle!
33+
*/
1734
:: bob2alice ? royal -> goto end;
1835
fi
1936
end:

demo/pirates/bob.pml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
active proctype bob() {
22
FISHING:
33
do
4+
/* When Bob sees Alice, he offers to trade. */
45
:: bob2alice ! trading;
6+
/* If Alice says she is a pirate then Bob
7+
* surrenders immediately. He has a peaceful soul.
8+
*/
59
:: alice2bob ? pirate -> bob2alice ! white;
610
od
711
end:

0 commit comments

Comments
 (0)