| 1 | [ |
| 2 | "autonomous agent", |
| 3 | { |
| 4 | "messages": { |
| 5 | "cases": [ |
| 6 | { |
| 7 | "if": "{ |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | $project = "5IZAANLACSTY5ILLCJ6N5P4OX73ZWRJY" ; |
| 13 | $min_poolsize = 3 ; |
| 14 | $processors_per_round = 3 ; |
| 15 | $storage = 1000 ; |
| 16 | |
| 17 | $min_round_cost = $processors_per_round * 21000 + $storage * 3 ; |
| 18 | if( !var[ $project ][ "count" ] ) bounce( "$project AA missing 'count'") ; |
| 19 | if( var[ $project ][ "count" ] < $min_poolsize ) bounce( "waiting for " || $project || " to have " || $min_poolsize || " registered obots" ) ; |
| 20 | if( trigger.data.computation_rounds ) bounce( " computation_rounds = " || var[ 'computation_rounds' ] ) ; |
| 21 | $min_poolsize >= 3 |
| 22 | }", |
| 23 | "messages": { |
| 24 | "cases": [ |
| 25 | { |
| 26 | "if": "{ |
| 27 | if( !trigger.data.message AND !trigger.data.round AND trigger.output[[asset=base]] < $min_round_cost ) bounce( 'need to send ' || $min_round_cost || ' to request a new round'); |
| 28 | |
| 29 | ( !trigger.data.message AND !trigger.data.round ) |
| 30 | }", |
| 31 | "init": "{ |
| 32 | |
| 33 | $process = '{ "args": "' || 'obotic' || '", "processors": 1, "round": ' || ( var[ "round" ] + 1 ) || ' }' ; |
| 34 | |
| 35 | }", |
| 36 | "messages": [ |
| 37 | { |
| 38 | "app": "data", |
| 39 | "payload": { |
| 40 | "message": "{ $process }", |
| 41 | "nosend": true |
| 42 | } |
| 43 | }, |
| 44 | { |
| 45 | "app": "payment", |
| 46 | "payload": { |
| 47 | "asset": "base", |
| 48 | "outputs": [ |
| 49 | { |
| 50 | "address": "{ $project }", |
| 51 | "amount": "{ trigger.output[[asset=base]] - $storage }" |
| 52 | } |
| 53 | ] |
| 54 | } |
| 55 | }, |
| 56 | { |
| 57 | "app": "state", |
| 58 | "state": "{ var[ "round" ] += 1 ; }" |
| 59 | } |
| 60 | ] |
| 61 | }, |
| 62 | { |
| 63 | "if": "{ |
| 64 | trigger.address == $project AND trigger.data.message AND trigger.data.choosen |
| 65 | }", |
| 66 | "init": "{ |
| 67 | $process = json_parse( trigger.data.message ) ; |
| 68 | $args = json_stringify( $process.args ) ; |
| 69 | $processors = json_parse( $process.processors ) + 1 ; |
| 70 | $round = $process.round ; |
| 71 | $morebot = '{ "args": "' || $args || '", "processors": ' || $processors || ', "round": ' || $round || ' }' ; |
| 72 | |
| 73 | $obot = trigger.data.choosen ; |
| 74 | $fee = var[ $obot ][ "fee" ] otherwise 21000 ; |
| 75 | }", |
| 76 | "messages": [ |
| 77 | { |
| 78 | "app": "state", |
| 79 | "state": "{ |
| 80 | response[ "processors" ] = $processors ; |
| 81 | /* |
| 82 | if( $round ){ |
| 83 | var[ "g" || $round ] = timestamp + 43200; |
| 84 | response[ "message" ] = $message; |
| 85 | response[ "round" ] = $round; |
| 86 | response[ "redplayer" ] = $sendred; |
| 87 | response[ "blueplayer" ] = $sendblue; |
| 88 | } |
| 89 | if( trigger.address == $project ){ |
| 90 | var[ "redaddr" ] += 1; |
| 91 | var[ "r" || var[ "redaddr" ] ] = trigger.data.choosen; |
| 92 | } |
| 93 | if( trigger.address == $blue ){ |
| 94 | var[ "blueaddr" ] += 1; |
| 95 | var[ "b" || var[ "blueaddr" ] ] = trigger.data.choosen; |
| 96 | } |
| 97 | */ |
| 98 | }" |
| 99 | } |
| 100 | ] |
| 101 | } |
| 102 | ] |
| 103 | } |
| 104 | } |
| 105 | ] |
| 106 | } |
| 107 | } |
| 108 | ] |