Skip to content

Instantly share code, notes, and snippets.

@mzaks
Created July 15, 2011 21:04
Show Gist options
  • Save mzaks/1085546 to your computer and use it in GitHub Desktop.
Save mzaks/1085546 to your computer and use it in GitHub Desktop.
tic tac toe definition
resource Cross
resource Zerro
place Start {
Cross: 1/..
Zerro: 0/..
}
place _1X1 {
Cross: 0/1
Zerro: 0/1
}
place _2X1 {
Cross: 0/1
Zerro: 0/1
}
place _3X1 {
Cross: 0/1
Zerro: 0/1
}
place _1X2 {
Cross: 0/1
Zerro: 0/1
}
place _2X2 {
Cross: 0/1
Zerro: 0/1
}
place _3X2 {
Cross: 0/1
Zerro: 0/1
}
place _1X3 {
Cross: 0/1
Zerro: 0/1
}
place _2X3 {
Cross: 0/1
Zerro: 0/1
}
place _3X3 {
Cross: 0/1
Zerro: 0/1
}
// Transactions for X - Cross
transaction X_To_1X1 {
assure 0 Zerro in _1X1
assure 0 Cross in _1X1
take 1 Cross from Start
put 1 Zerro into Start
put 1 Cross into _1X1
}
transaction X_To_2X1 {
assure 0 Zerro in _2X1
assure 0 Cross in _2X1
take 1 Cross from Start
put 1 Zerro into Start
put 1 Cross into _2X1
}
transaction X_To_3X1 {
assure 0 Zerro in _3X1
assure 0 Cross in _3X1
take 1 Cross from Start
put 1 Zerro into Start
put 1 Cross into _3X1
}
transaction X_To_1X2 {
assure 0 Zerro in _1X2
assure 0 Cross in _1X2
take 1 Cross from Start
put 1 Zerro into Start
put 1 Cross into _1X2
}
transaction X_To_2X2 {
assure 0 Zerro in _2X2
assure 0 Cross in _2X2
take 1 Cross from Start
put 1 Zerro into Start
put 1 Cross into _2X2
}
transaction X_To_3X2 {
assure 0 Zerro in _3X2
assure 0 Cross in _3X2
take 1 Cross from Start
put 1 Zerro into Start
put 1 Cross into _3X2
}
transaction X_To_1X3 {
assure 0 Zerro in _1X3
assure 0 Cross in _1X3
take 1 Cross from Start
put 1 Zerro into Start
put 1 Cross into _1X3
}
transaction X_To_2X3 {
assure 0 Zerro in _2X3
assure 0 Cross in _2X3
take 1 Cross from Start
put 1 Zerro into Start
put 1 Cross into _2X3
}
transaction X_To_3X3 {
assure 0 Zerro in _3X3
assure 0 Cross in _3X3
take 1 Cross from Start
put 1 Zerro into Start
put 1 Cross into _3X3
}
// Transactions for O - Zerro
transaction O_To_1X1 {
assure 0 Zerro in _1X1
assure 0 Cross in _1X1
take 1 Zerro from Start
put 1 Cross into Start
put 1 Zerro into _1X1
}
transaction O_To_2X1 {
assure 0 Zerro in _2X1
assure 0 Cross in _2X1
take 1 Zerro from Start
put 1 Cross into Start
put 1 Zerro into _2X1
}
transaction O_To_3X1 {
assure 0 Zerro in _3X1
assure 0 Cross in _3X1
take 1 Zerro from Start
put 1 Cross into Start
put 1 Zerro into _3X1
}
transaction O_To_1X2 {
assure 0 Zerro in _1X2
assure 0 Cross in _1X2
take 1 Zerro from Start
put 1 Cross into Start
put 1 Zerro into _1X2
}
transaction O_To_2X2 {
assure 0 Zerro in _2X2
assure 0 Cross in _2X2
take 1 Zerro from Start
put 1 Cross into Start
put 1 Zerro into _2X2
}
transaction O_To_3X2 {
assure 0 Zerro in _3X2
assure 0 Cross in _3X2
take 1 Zerro from Start
put 1 Cross into Start
put 1 Zerro into _3X2
}
transaction O_To_1X3 {
assure 0 Zerro in _1X3
assure 0 Cross in _1X3
take 1 Zerro from Start
put 1 Cross into Start
put 1 Zerro into _1X3
}
transaction O_To_2X3 {
assure 0 Zerro in _2X3
assure 0 Cross in _2X3
take 1 Zerro from Start
put 1 Cross into Start
put 1 Zerro into _2X3
}
transaction O_To_3X3 {
assure 0 Zerro in _3X3
assure 0 Cross in _3X3
take 1 Zerro from Start
put 1 Cross into Start
put 1 Zerro into _3X3
}
@mzaks
Copy link
Author

mzaks commented Jul 15, 2011

______#######
______# Start #
______#######

1X1 # 2X1 # 3X1

1X2 # 2X2 # 3X2

1X3 # 2X3 # 3X3

A resource X or O (Cross or Zerro)
Is moved from Start to a field place by a transaction.
Transaction is only alive if there are no resources on field place.
There are two types of transactions, transaction that place X to field place and transaction that place O to field place.
X transaction puts a O into start place. This assures that the X and O transactions alternate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment