diff --git a/classes/Hubs.sc b/classes/Hubs.sc index 1e6028d..d9d7017 100644 --- a/classes/Hubs.sc +++ b/classes/Hubs.sc @@ -1,42 +1,42 @@ AbstractHub : Participation { var <>hub, <>locked=false; - + init { this.addResponder('/theHubIsMe', {|t,r,msg| var who = msg[1].asSymbol, addr; if(this.canBeChanged) { addr = collective.everybody[who]; - if(addr.notNil) { - hub = addr - } { + if(addr.notNil) { + hub = addr + } { "something went wrong: hub % could not be assigned.".format(who).warn } - } { + } { if(hub.name !== who) { "can't change hub to %, it is locked.".format(who).warn } }; - + }) } - + canBeChanged { ^locked.not or: hub.isNil } - + theHubIsMe { collective.sendToAll('/theHubIsMe', collective.myName) } - + isTheHubMe { ^hub == collective.myAddr } - + stop { super.stop; } - + } @@ -44,15 +44,15 @@ AbstractHub : Participation { TheDiningPhilosophers : Participation { var nextFunc, <>action; + var <>nextFunc, <>action; init { - this.addResponder(channel, { arg r, t, msg; + channel='/transference'; + this.addResponder(channel, { arg r, t, msg; var follow = this.nextIndex; var delta, n, blendFactor, recvedData; - + #delta, n ... recvedData = msg[1..]; - + recvedData = this.transform(recvedData); this.react(recvedData, delta, n); - + if(n > 0 and: { follow.notNil }) { SystemClock.sched(delta, { collective.sendToIndex(follow, channel, delta, n - 1, *recvedData) }); }; - - + + }) } transform { arg data; @@ -110,18 +111,19 @@ AbstractTransference : Participation { var i = this.nextIndex; collective.sendToIndex(i, channel, delta, length - 1, *data) } - + } */ // todo: generalize generation of next message MarkovNet : Participation { - var <>data, <>transitions, <>weights, data, <>transitions, <>weights; var <>function; - + init { - this.addResponder(channel, { arg r, t, msg; + channel='/markov'; + this.addResponder(channel, { arg r, t, msg; var delta, n, blendFactor, recvedData, forwardData; var sendData, infoSize, inject; // length @@ -140,16 +142,16 @@ MarkovNet : Participation { SystemClock.sched(delta, { this.newChain(delta, n - 1, blendFactor, inject, forwardData); }); }; - function.value(sendData); + function.value(sendData); }) } - + nextIndex { var res; if(transitions.isNil) { ^collective.addresses.size.rand }; - ^if(weights.isNil) { - transitions.size.rand - } { + ^if(weights.isNil) { + transitions.size.rand + } { res = transitions[weights.windex]; if(res.isNil) { Error("not the right number of transitions / weights").throw }; res @@ -159,9 +161,9 @@ MarkovNet : Participation { var info; info = [delta, blendFactor, inject.binaryValue]; sendData = sendData ? data; - collective.sendToIndex(this.nextIndex, + collective.sendToIndex(this.nextIndex, channel, length, info.size, *(info ++ sendData) ) } - + }