Skip to content

Instantly share code, notes, and snippets.

@EgonSpengler
Last active August 29, 2015 13:58
Show Gist options
  • Save EgonSpengler/9940814 to your computer and use it in GitHub Desktop.
Save EgonSpengler/9940814 to your computer and use it in GitHub Desktop.
Prog3
// tjadam, jawaterm
// 2014.3.26
// Group Assignment 3 - Play By Your Own Rules
int topcard[5]; // 0 through 3 for each player
proctype player(int i) {
do
:: atomic{
if
:: topcard[(i+4)%5] > topcard[i] -> topcard[i] = topcard[(i+4)%5]
:: topcard[(i+1)%5] > topcard[i] -> topcard[i] = topcard[(i+1)%5]
fi;
}
od;
}
proctype owner() {
atomic{
//shuffle n number of times
int j;
int v;
for( j : 0..4 ){
select (v : 0..3);
topcard[j] = v;
}
}
}
init{
//shuffle once
int j;
int v;
for( j : 0..4 ){
select (v : 0..3);
topcard[j] = v;
}
int x;
for(x : 0..4){
run player(x);
}
run owner();
}
#define winning (topcard[0] == topcard[1] && topcard[1] == topcard[2] && \
topcard[2] == topcard[3] && topcard[3] == topcard[4])
ltl victory { <> [] winning };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment