[
"autonomous agent",
{
"messages": {
"cases": [
{
"if": "{
// Obotic / MicroGrid by
[email protected]
// My best entry, combines techniques from all my previous AA, structure based on REDvsBLUE
// 1) Scientist send args to be processed by obots
$obots = "
5IZAANLACSTY5ILLCJ6N5P4OX73ZWRJY" ; // Select Random Registered Address AA
$minimum = 3 ;
$storage = 1000 ;
if( !var[ $obots ][ "count" ] ) bounce( "$obots AA missing 'count'") ;
if( var[ $obots ][ "count" ] < $minimum ) bounce( "waiting for obots=" || $obots || " to have " || $minimum || " obots" ) ;
if( trigger.data.computation_rounds ) bounce( " computation_rounds = " || var[ 'computation_rounds' ] ) ;
$minimum >= 3
}",
"messages": {
"cases": [
{
"if": "{ // REQUEST NEW ROUND
if( !trigger.data.message AND !trigger.data.round AND trigger.output[[asset=base]] < 25000 ) bounce( "need to send minimum 25000 to request a new round");
// TODO check for trigger.data.args
( !trigger.data.message AND !trigger.data.round ) // means not messages from obots nor obot
}",
"messages": [
{
"app": "payment",
"payload": {
"asset": "base",
"outputs": [
{
"address": "{ $obots }",
"amount": "{ trigger.output[[asset=base]] - $storage }"
}
]
}
},
{
"app": "data",
"payload": {
"message": "obotic",
"nosend": true
}
}
]
},
{
"if": "{ // START ROUND
if ( trigger.address == $obots AND trigger.data.message AND trigger.data.choosen ){
$check = json_parse( trigger.data.message ) ;
//if( !$message.round ) $message.round = var[ "round" ] + 1 ;
if( !$check.round ) $message = "{ args: " || $message.args || ", round: " || ( var[ "round" ] + 1 ) || " }" ;
else $message = "{ args: " || $message.args || ", round: " || $check.round || " }" ;
$cruncher = trigger.data.choosen ;
}
( trigger.address == $obots AND trigger.data.message AND trigger.data.choosen )
}",
"messages": [
{
"if": "{ trigger.output[[asset=base]] > 1000 }",
"app": "payment",
"payload": {
"asset": "base",
"outputs": [
{
"address": "{ $obots }",
"amount": "{ trigger.output[[asset=base]] - $storage }"
}
]
}
},
{
"if": "{ trigger.output[[asset=base]] > 1000 }",
"app": "data",
"payload": {
"message": "{ trigger.data.message }",
"nosend": true
}
},
{
"app": "state",
"state": "{ // TASK JOB TRACKER
response[ "message" ] = $message ;
/*
if( $round ){
var[ "g" || $round ] = timestamp + 43200; // start countdown
response[ "message" ] = $message;
response[ "round" ] = $round;
response[ "redplayer" ] = $sendred;
response[ "blueplayer" ] = $sendblue;
}
if( trigger.address == $obots ){
var[ "redaddr" ] += 1; // new red address
var[ "r" || var[ "redaddr" ] ] = trigger.data.choosen; // save red address
}
if( trigger.address == $blue ){
var[ "blueaddr" ] += 1; // new blue address
var[ "b" || var[ "blueaddr" ] ] = trigger.data.choosen;
}
*/
}"
}
]
}
]
}
}
]
}
}
]