Created
April 11, 2018 14:13
-
-
Save ewenmaclean/445454a6749f871499f3ff78aa8f9730 to your computer and use it in GitHub Desktop.
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
receive (f:fill) { | |
if (state.cabbage == Client && state.goat == Client) then | |
{ | |
state.cabbage = Eaten | |
return | |
} | |
if (state.goat == Client && state.wolf == Client) then | |
{ | |
state.goat = Eaten | |
return | |
} | |
state.act = f.act | |
state.obj = f.obj | |
if f.act == SwapTransit then state.transit = Client | |
else if f.act == Pick then | |
{ | |
if (state.cabbage == Transit || state.goat == Transit || state.wolf == Transit) then return | |
let thisObjVal = if f.obj == (Some Cabbage) then state.cabbage | |
else if f.obj == (Some Wolf) then state.wolf else state.goat | |
if thisObjVal == Exchange then | |
{ | |
if f.obj == (Some Cabbage) then state.cabbage = Transit else | |
if f.obj == (Some Wolf) then state.wolf = Transit else | |
state.goat = Transit | |
} | |
} | |
else | |
{ | |
let thisObjVal = if f.obj == (Some Cabbage) then state.cabbage | |
else if f.obj == (Some Wolf) then state.wolf else state.goat | |
if thisObjVal == Transit then | |
{ | |
if f.obj == (Some Cabbage) then state.cabbage = Exchange | |
else if f.obj == (Some Wolf) then state.wolf = Exchange | |
else state.goat = Exchange | |
} | |
} | |
send ExecutionReport state | |
} | |
receive (m:NewOrderSingle){ | |
if (state.cabbage == Exchange && state.goat == Exchange) then | |
{ | |
state.cabbage = Eaten | |
return | |
} | |
if (state.goat == Exchange && state.wolf == Exchange) then | |
{ | |
state.goat = Eaten | |
return | |
} | |
assignFrom(m,state) | |
if m.act == SwapTransit then state.transit = Exchange | |
else if m.act == Pick then | |
{ | |
if (state.cabbage == Transit || state.goat == Transit || state.wolf == Transit) then return | |
let thisObjVal = if m.obj == (Some Cabbage) then state.cabbage | |
else if m.obj == (Some Wolf) then state.wolf else state.goat | |
if thisObjVal == Client then | |
{ | |
if m.obj == (Some Cabbage) then state.cabbage = Transit | |
else if m.obj == (Some Wolf) then state.wolf = Transit | |
else if m.obj == (Some Goat) then state.goat = Transit | |
} | |
} | |
else { | |
let thisObjVal = if m.obj == (Some Cabbage) then state.cabbage | |
else if m.obj == (Some Wolf) then state.wolf else state.goat | |
if thisObjVal == Transit then | |
{ | |
if m.obj == (Some Cabbage) then state.cabbage = Client | |
else if m.obj == (Some Wolf) then state.wolf = Client | |
else state.goat = Client | |
} | |
} | |
send ExecutionReport state | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment