-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
563 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
class stdCounter(int x) { | ||
state Counting { | ||
if (x <= 0) { | ||
exit; | ||
} | ||
x = x - 1; | ||
enter Counting; | ||
} | ||
} | ||
|
||
class stdPredicateExists(Predicate p) { | ||
state ExitWhen { | ||
if (exists(p)) { | ||
exit; | ||
} | ||
enter ExitWhen; | ||
} | ||
|
||
state ExitWhenNo { | ||
if (!exists(p)) { | ||
exit; | ||
} | ||
enter ExitWhenNo; | ||
} | ||
} | ||
|
||
class stdPredicateAmount(Predicate p, int x) { | ||
state ExitLessThan { | ||
if (count(p) < x) { | ||
exit; | ||
} | ||
enter ExitLessThan; | ||
} | ||
|
||
state ExitMoreThan { | ||
if (count(p) > x) { | ||
exit; | ||
} | ||
enter ExitMoreThan; | ||
} | ||
} | ||
|
||
|
||
|
||
// exit the simulation after the specified amount of ticks | ||
function ExitAfterTicks(int ticks) -> void { | ||
create stdCounter::Counting(x: ticks); | ||
} | ||
|
||
// exit the simulation when there exists an agent fulfilling `pred` | ||
function ExitWhenExists(Predicate pred) -> void { | ||
create stdPredicateExists::ExitWhen(p: pred); | ||
} | ||
|
||
// exit the simulation when there no longer exists any agents fulfilling `pred` | ||
function ExitWhenNoLongerExists(Predicate pred) -> void { | ||
create stdPredicateExists::ExitWhenNo(p: pred); | ||
} | ||
|
||
// exit the simulation when there exists `amount` agents fulfilling `pred` | ||
function ExitWhenMoreThan(Predicate pred, int amount) -> void { | ||
create stdPredicateAmount::ExitMoreThan(p: pred, x: amount); | ||
} | ||
|
||
// exit the simulation when there are less than `amount` agents fulfilling `pred` | ||
function ExitWhenLessThan(Predicate pred, int amount) -> void { | ||
create stdPredicateAmount::ExitLessThan(p: pred, x: amount); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
SocietalConstructionToolTests/Snapshots/BehaviourTests/StdlibExitAfter.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
[ | ||
{ | ||
"State": "Counting", | ||
"Fields": { | ||
"x": 3 | ||
}, | ||
"ClassName": "stdCounter" | ||
} | ||
][ | ||
{ | ||
"State": "Counting", | ||
"Fields": { | ||
"x": 2 | ||
}, | ||
"ClassName": "stdCounter" | ||
} | ||
][ | ||
{ | ||
"State": "Counting", | ||
"Fields": { | ||
"x": 1 | ||
}, | ||
"ClassName": "stdCounter" | ||
} | ||
][ | ||
{ | ||
"State": "Counting", | ||
"Fields": { | ||
"x": 0 | ||
}, | ||
"ClassName": "stdCounter" | ||
} | ||
][] |
41 changes: 41 additions & 0 deletions
41
SocietalConstructionToolTests/Snapshots/BehaviourTests/StdlibExitWhenExists.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
[ | ||
{ | ||
"State": "Bar", | ||
"Fields": {}, | ||
"ClassName": "Foo" | ||
}, | ||
{ | ||
"State": "ExitWhen", | ||
"Fields": { | ||
"p": { | ||
"ClassName": "__sct_Foo", | ||
"State": "__sct_Baz", | ||
"Fields": {} | ||
} | ||
}, | ||
"ClassName": "stdPredicateExists" | ||
} | ||
][ | ||
{ | ||
"State": "Baz", | ||
"Fields": {}, | ||
"ClassName": "Foo" | ||
}, | ||
{ | ||
"State": "ExitWhen", | ||
"Fields": { | ||
"p": { | ||
"ClassName": "__sct_Foo", | ||
"State": "__sct_Baz", | ||
"Fields": {} | ||
} | ||
}, | ||
"ClassName": "stdPredicateExists" | ||
} | ||
][ | ||
{ | ||
"State": "Baz", | ||
"Fields": {}, | ||
"ClassName": "Foo" | ||
} | ||
] |
47 changes: 47 additions & 0 deletions
47
SocietalConstructionToolTests/Snapshots/BehaviourTests/StdlibExitWhenLessThan.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
[ | ||
{ | ||
"State": "Bar", | ||
"Fields": {}, | ||
"ClassName": "Foo" | ||
}, | ||
{ | ||
"State": "Baz", | ||
"Fields": {}, | ||
"ClassName": "Foo" | ||
}, | ||
{ | ||
"State": "Baz", | ||
"Fields": {}, | ||
"ClassName": "Foo" | ||
}, | ||
{ | ||
"State": "ExitLessThan", | ||
"Fields": { | ||
"p": { | ||
"ClassName": "__sct_Foo", | ||
"State": null, | ||
"Fields": {} | ||
}, | ||
"x": 2 | ||
}, | ||
"ClassName": "stdPredicateAmount" | ||
} | ||
][ | ||
{ | ||
"State": "Baz", | ||
"Fields": {}, | ||
"ClassName": "Foo" | ||
}, | ||
{ | ||
"State": "ExitLessThan", | ||
"Fields": { | ||
"p": { | ||
"ClassName": "__sct_Foo", | ||
"State": null, | ||
"Fields": {} | ||
}, | ||
"x": 2 | ||
}, | ||
"ClassName": "stdPredicateAmount" | ||
} | ||
][] |
114 changes: 114 additions & 0 deletions
114
SocietalConstructionToolTests/Snapshots/BehaviourTests/StdlibExitWhenMoreThan.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
[ | ||
{ | ||
"State": "Bar", | ||
"Fields": {}, | ||
"ClassName": "Foo" | ||
}, | ||
{ | ||
"State": "ExitMoreThan", | ||
"Fields": { | ||
"p": { | ||
"ClassName": "__sct_Foo", | ||
"State": "__sct_Baz", | ||
"Fields": {} | ||
}, | ||
"x": 1 | ||
}, | ||
"ClassName": "stdPredicateAmount" | ||
} | ||
][ | ||
{ | ||
"State": "Baz", | ||
"Fields": {}, | ||
"ClassName": "Foo" | ||
}, | ||
{ | ||
"State": "ExitMoreThan", | ||
"Fields": { | ||
"p": { | ||
"ClassName": "__sct_Foo", | ||
"State": "__sct_Baz", | ||
"Fields": {} | ||
}, | ||
"x": 1 | ||
}, | ||
"ClassName": "stdPredicateAmount" | ||
} | ||
][ | ||
{ | ||
"State": "Bar", | ||
"Fields": {}, | ||
"ClassName": "Foo" | ||
}, | ||
{ | ||
"State": "Baz", | ||
"Fields": {}, | ||
"ClassName": "Foo" | ||
}, | ||
{ | ||
"State": "ExitMoreThan", | ||
"Fields": { | ||
"p": { | ||
"ClassName": "__sct_Foo", | ||
"State": "__sct_Baz", | ||
"Fields": {} | ||
}, | ||
"x": 1 | ||
}, | ||
"ClassName": "stdPredicateAmount" | ||
} | ||
][ | ||
{ | ||
"State": "Baz", | ||
"Fields": {}, | ||
"ClassName": "Foo" | ||
}, | ||
{ | ||
"State": "Bar", | ||
"Fields": {}, | ||
"ClassName": "Foo" | ||
}, | ||
{ | ||
"State": "Baz", | ||
"Fields": {}, | ||
"ClassName": "Foo" | ||
}, | ||
{ | ||
"State": "ExitMoreThan", | ||
"Fields": { | ||
"p": { | ||
"ClassName": "__sct_Foo", | ||
"State": "__sct_Baz", | ||
"Fields": {} | ||
}, | ||
"x": 1 | ||
}, | ||
"ClassName": "stdPredicateAmount" | ||
} | ||
][ | ||
{ | ||
"State": "Bar", | ||
"Fields": {}, | ||
"ClassName": "Foo" | ||
}, | ||
{ | ||
"State": "Baz", | ||
"Fields": {}, | ||
"ClassName": "Foo" | ||
}, | ||
{ | ||
"State": "Baz", | ||
"Fields": {}, | ||
"ClassName": "Foo" | ||
}, | ||
{ | ||
"State": "Bar", | ||
"Fields": {}, | ||
"ClassName": "Foo" | ||
}, | ||
{ | ||
"State": "Baz", | ||
"Fields": {}, | ||
"ClassName": "Foo" | ||
} | ||
] |
Oops, something went wrong.