[
"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
$min_poolsize = 3 ;
$max_processors_per_job = 10 ;
$storage = 1000 ;
if( !var[ $obots ][ "count" ] ) bounce( "$obots AA missing 'count'") ;
if( var[ $obots ][ "count" ] < $min_poolsize ) bounce( "waiting for " || $obots || " to have " || $min_poolsize || " registered obots" ) ;
if( trigger.data.computation_rounds ) bounce( " computation_rounds = " || var[ 'computation_rounds' ] ) ;
$min_poolsize >= 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 min_poolsize 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
trigger.address == $obots AND trigger.data.message AND trigger.data.choosen
}",
"init": "{
$omessage = json_parse( trigger.data.message ) ;
$processors = $omessage.processors + 1 ;
$message = "{ args: '" || $omessage.args || "', processors: " || $processors || ", round: " || ( var[ "round" ] + 1 ) || " }" ;
$cruncher = trigger.data.choosen;
}",
"messages": [
{
"if": "{ $processors < $max_processors_per_job AND trigger.output[[asset=base]] > 1000 }",
"app": "payment",
"payload": {
"asset": "base",
"outputs": [
{
"address": "{ $obots }",
"amount": "{ trigger.output[[asset=base]] - $storage }"
}
]
}
},
{
"if": "{ $processors < $max_processors_per_job AND trigger.output[[asset=base]] > 1000 }",
"app": "data",
"payload": {
"message": "{ $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;
}
*/
}"
}
]
}
]
}
}
]
}
}
]