[
"autonomous agent",
{
"messages": {
"cases": [
{
"if": "{
// RED vs BLUE the contentious game by
[email protected]
// usage
// 1) setup two "choose address AA" and replace below $red and $blue addresses
$red = "
PMELVVGURT2J6EGSHBYJRCEVQXVIATPW";
$blue = "
PMELVVGURT2J6EGSHBYJRCEVQXVIATPW";
$minimum = 3;
if( var[ $red ][ "count" ] < $minimum OR var[ $blue ][ "count" ] < $minimum ) bounce( "waiting for red=" || $red || " or blue=" || $blue || " sides to have " || $minimum || " players" );
if( trigger.data.needle ) bounce( "Round " || var[ 'round' ] || " Red = " || var[ 'red' ] || " vs Blue = " || var[ 'blue' ] );
$minimum
}",
"messages": {
"cases": [
{
"if": "{
trigger.data.round > 0
}",
"messages": [
{
"app": "payment",
"payload": {
"asset": "base",
"outputs": [
{
"address": "{$red}",
"amount": 11000
},
{
"address": "{$blue}",
"amount": 11000
}
]
}
}
]
},
{
"if": "{
trigger.data.round
}",
"messages": [
{
"app": "state",
"state": "{
var[ 'round' ] += 1;
var[ 'red' ] += 1;
var[ 'blue' ] += 1;
response[ 'message' ] = "Round " || var[ 'round' ] || " Red = " || var[ 'red' ] || " vs Blue = " || var[ 'blue' ];
}"
}
]
},
{
"if": "{
if( trigger.output[[ asset=base ]] < 23000 ) bounce( "need to send 23000 to request a new round");
trigger.output[[ asset=base ]] >= 23000
}",
"messages": [
{
"app": "payment",
"payload": {
"asset": "base",
"outputs": [
{
"address": "{$red}",
"amount": 11000
},
{
"address": "{$blue}",
"amount": 11000
}
]
}
},
{
"app": "data",
"payload": {
"deadline": "some time later",
"red": "address",
"blue": "address",
"choose": "send data vote r1 to this address"
}
}
]
}
]
}
}
]
}
}
]