forked from elkoDev/Cirrina-UseCases
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.pkl
More file actions
100 lines (96 loc) · 2.72 KB
/
Copy pathmain.pkl
File metadata and controls
100 lines (96 loc) · 2.72 KB
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
amends "https://raw.githubusercontent.com/CollaborativeStateMachines/Cirrina/refs/heads/develop/src/main/resources/pkl/csm/csml.pkl"
local n = 12
collaborativeStateMachine {
stateMachines {
["chameneos"] {
transient {
["color"] = "std:takeRandom([1,2,3,...])"
}
states {
["request"] = new Initial {
entry {
new Emit {
event {
topic = "requesting"
data { ["id"] = "id"; ["color"] = "color" }
}
target = "'mall'"
}
}
on {
["matchMade"] = new Transition {
to = "request"
yields {
new Eval { expression = "color = (function (x,y) { if (x == y) {x} else {x ^ y} })(color, $color)" }
new Emit {
event {
topic = "change"
data { ["color"] = "color" }
}
target = "$partner.toString()"
}
}
}
["change"] = new Transition {
to = "request"
yields {
new Eval { expression = "color = $color" }
}
}
}
}
}
}
["mall"] {
transient {
["waiting"] = "[...]"
["count"] = "0"
}
states {
["wait"] = new Initial {
on {
["requesting"] = new Transition {
yields {
new Match {
cases {
new Case {
of = "waiting.isEmpty()"
yields { new Eval { expression = "waiting += [$id]" } }
}
new Case {
of = "!waiting.isEmpty()"
yields {
new Eval { expression = "++count" }
new Ctr { counter = "mall.meetings" }
new Emit {
event {
topic = "matchMade"
data {
["partner"] = "$id"
["color"] = "$color"
}
}
target = "waiting.get(0).toString()"
}
new Eval { expression = "waiting -= [waiting.get(0)]" }
}
}
}
}
}
}
}
}
}
}
}
}
instances {
["mall"] { stateMachineName = "mall" }
for (i in IntSeq(0, n - 1)) {
["\(i)"] {
stateMachineName = "chameneos"
data { ["id"] = "\(i)" }
}
}
}