From 785e316dc2fd1c0aa6a17fef50fdf5a1d2a33d66 Mon Sep 17 00:00:00 2001 From: sbosse Date: Mon, 21 Jul 2025 23:13:34 +0200 Subject: [PATCH] Mon 21 Jul 22:43:21 CEST 2025 --- js/test/agent7.js | 120 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 js/test/agent7.js diff --git a/js/test/agent7.js b/js/test/agent7.js new file mode 100644 index 0000000..fa4869d --- /dev/null +++ b/js/test/agent7.js @@ -0,0 +1,120 @@ +global.TOP='/home/sbosse/proj/jam/js'; +require(TOP+'/top/module')([process.cwd(),TOP]); +var Io = Require('com/io'); +var Aios = Require('jam/aios'); +var Comp = Require('com/compat'); + +var node_ac = function (x,y) { + //var self=this; + // Data State + this.pos={x:x,y:y}; + + this.x; + // Activities + this.init = function () { + this.x=0; + }; + this.end = function () { + log('finalize'); + kill(); + }; + this.act1 = function () { + log('act1'); + }; + this.act2 = function () { + //log('act2 '+this.x); + this.x++; + //sleep(1000); + }; + this.act3 = function () { + //log('act3'); + }; + this.on = { + error : function (e) { + log('Caught exception '+e); + }, + exit : function () { + log('Terminating.'); + } + }; + // Transition network + this.trans = { + init: function () { + return 'act1'; + }, + act1: function () { + if (this.pos.x==3 && this.pos.y==3) return 'act2'; + else return 'end'; + }, + act2: function () { + if (this.x<1000) return 'act3'; + else return 'end'; + }, + act3: function () { + return 'act2'; + }, + end: function () { + + } + } + // Control State + this.next='init'; +} + +var world_ac = function () { + this.init = function () { + log('World: Starting node agents ['+ + this.options.x+','+this.options.y+'] ..'); + for (var j=0;j