From 6c5ebe1756425c965842cb3232561203959985eb Mon Sep 17 00:00:00 2001 From: Anton Vakhrushev Date: Sun, 17 Jun 2018 10:39:24 +0300 Subject: [PATCH] Remove debug logs --- lib/predictor.js | 2 +- source/Daemon.js | 1 - source/Supervisor.js | 2 -- 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/predictor.js b/lib/predictor.js index 6127bbf..fb82a70 100644 --- a/lib/predictor.js +++ b/lib/predictor.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("predictor",[],t):"object"==typeof exports?exports.predictor=t():e.predictor=t()}(window,function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=5)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n2&&void 0!==arguments[2]?arguments[2]:i;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.weights={},this.humanCount=t,this.robotCount=n,this.epsilon=r}return r(e,[{key:"predict",value:function(e){var t=this._getStepSlice(e),n=this._getWeight([].concat(o(t),[0]));return this._getWeight([].concat(o(t),[1]))>n?1:0}},{key:"adjust",value:function(e,t){var n=this._getStepSlice(e),r=this._getAdjustmentWeight(e.length);this._adjustWeight([].concat(o(n),[t]),r)}},{key:"_getStepSlice",value:function(e){return e.getLastMovements(this.humanCount,this.robotCount)}},{key:"_getAdjustmentWeight",value:function(e){return Math.pow(1+this.epsilon,e)}},{key:"_getWeight",value:function(e){var t=u(e),n=this.weights[t];return void 0===n?0:n}},{key:"_setWeight",value:function(e,t){var n=u(e);this.weights[n]=t,console.log("WEIGHTS",this.weights)}},{key:"_adjustWeight",value:function(e,t){var n=this._getWeight(e)+t;this._setWeight(e,n)}},{key:"power",get:function(){return this.humanCount+this.robotCount}}]),e}();t.default=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:o;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.daemons=[],!t)throw Error("Empty daemon list");this.daemons=t.map(function(e){return{daemon:e,rate:0}}),this.epsilon=n}return r(e,[{key:"predict",value:function(e){var t=this._createPredictions(e),n=this._sortPredictions(t);return console.log(n),n[0].value}},{key:"adjust",value:function(e,t){var n=this._createPredictions(e),r=!0,o=!1,i=void 0;try{for(var u,a=n[Symbol.iterator]();!(r=(u=a.next()).done);r=!0){var s=u.value;s.value===t&&(s.daemon.rate+=this._getAdjustmentWeight(e.length)),s.daemon.daemon.adjust(e,t)}}catch(e){o=!0,i=e}finally{try{!r&&a.return&&a.return()}finally{if(o)throw i}}}},{key:"_createPredictions",value:function(e){return this.daemons.map(function(t){return{daemon:t,power:t.daemon.power,rate:t.rate,value:t.daemon.predict(e)}})}},{key:"_sortPredictions",value:function(e){return e.sort(function(e,t){var n=t.rate-e.rate;return Math.abs(n)>1e-6?n:e.power-t.power})}},{key:"_getAdjustmentWeight",value:function(e){return Math.pow(1+this.epsilon,e)}}]),e}();t.default=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:[];!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.moves=[],this.moves=t}return o(e,[{key:"makeMove",value:function(e,t){this.moves.push(new u.default(e,t))}},{key:"getLastMovements",value:function(e,t){var n=this.moves.map(function(e){return e.human}),r=this.moves.map(function(e){return e.robot});return[].concat(r.slice(-t),n.slice(-e))}},{key:"length",get:function(){return this.moves.length}}]),e}();t.default=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:s;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.score=0,this.journal=new o.default;var n=t.daemons.map(function(e){return new u.default(e.human,e.robot,e.epsilon||.01)});this.supervisor=new i.default(n,t.supervisor_epsilon)}return r(e,[{key:"pass",value:function(e){var t=this.supervisor.predict(this.journal);return this.score+=t===e?-1:1,this.supervisor.adjust(this.journal,e),this.journal.makeMove(e,t),t}}]),e}();t.default=c},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r,o=n(4),i=(r=o)&&r.__esModule?r:{default:r};t.default=i.default}])}); \ No newline at end of file +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("predictor",[],t):"object"==typeof exports?exports.predictor=t():e.predictor=t()}(window,function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=5)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n2&&void 0!==arguments[2]?arguments[2]:i;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.weights={},this.humanCount=t,this.robotCount=n,this.epsilon=r}return r(e,[{key:"predict",value:function(e){var t=this._getStepSlice(e),n=this._getWeight([].concat(o(t),[0]));return this._getWeight([].concat(o(t),[1]))>n?1:0}},{key:"adjust",value:function(e,t){var n=this._getStepSlice(e),r=this._getAdjustmentWeight(e.length);this._adjustWeight([].concat(o(n),[t]),r)}},{key:"_getStepSlice",value:function(e){return e.getLastMovements(this.humanCount,this.robotCount)}},{key:"_getAdjustmentWeight",value:function(e){return Math.pow(1+this.epsilon,e)}},{key:"_getWeight",value:function(e){var t=u(e),n=this.weights[t];return void 0===n?0:n}},{key:"_setWeight",value:function(e,t){var n=u(e);this.weights[n]=t}},{key:"_adjustWeight",value:function(e,t){var n=this._getWeight(e)+t;this._setWeight(e,n)}},{key:"power",get:function(){return this.humanCount+this.robotCount}}]),e}();t.default=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:o;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.daemons=[],!t)throw Error("Empty daemon list");this.daemons=t.map(function(e){return{daemon:e,rate:0}}),this.epsilon=n}return r(e,[{key:"predict",value:function(e){var t=this._createPredictions(e);return this._sortPredictions(t)[0].value}},{key:"adjust",value:function(e,t){var n=this._createPredictions(e),r=!0,o=!1,i=void 0;try{for(var u,a=n[Symbol.iterator]();!(r=(u=a.next()).done);r=!0){var s=u.value;s.value===t&&(s.daemon.rate+=this._getAdjustmentWeight(e.length)),s.daemon.daemon.adjust(e,t)}}catch(e){o=!0,i=e}finally{try{!r&&a.return&&a.return()}finally{if(o)throw i}}}},{key:"_createPredictions",value:function(e){return this.daemons.map(function(t){return{daemon:t,power:t.daemon.power,rate:t.rate,value:t.daemon.predict(e)}})}},{key:"_sortPredictions",value:function(e){return e.sort(function(e,t){var n=t.rate-e.rate;return Math.abs(n)>1e-6?n:e.power-t.power})}},{key:"_getAdjustmentWeight",value:function(e){return Math.pow(1+this.epsilon,e)}}]),e}();t.default=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:[];!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.moves=[],this.moves=t}return o(e,[{key:"makeMove",value:function(e,t){this.moves.push(new u.default(e,t))}},{key:"getLastMovements",value:function(e,t){var n=this.moves.map(function(e){return e.human}),r=this.moves.map(function(e){return e.robot});return[].concat(r.slice(-t),n.slice(-e))}},{key:"length",get:function(){return this.moves.length}}]),e}();t.default=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:s;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.score=0,this.journal=new o.default;var n=t.daemons.map(function(e){return new u.default(e.human,e.robot,e.epsilon||.01)});this.supervisor=new i.default(n,t.supervisor_epsilon)}return r(e,[{key:"pass",value:function(e){var t=this.supervisor.predict(this.journal);return this.score+=t===e?-1:1,this.supervisor.adjust(this.journal,e),this.journal.makeMove(e,t),t}}]),e}();t.default=c},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r,o=n(4),i=(r=o)&&r.__esModule?r:{default:r};t.default=i.default}])}); \ No newline at end of file diff --git a/source/Daemon.js b/source/Daemon.js index a8b766e..52659bb 100644 --- a/source/Daemon.js +++ b/source/Daemon.js @@ -51,7 +51,6 @@ export default class Daemon { _setWeight(steps, value) { const key = create_key(steps); this.weights[key] = value; - console.log('WEIGHTS', this.weights); } _adjustWeight(steps, weight) { diff --git a/source/Supervisor.js b/source/Supervisor.js index b787592..50ca98a 100644 --- a/source/Supervisor.js +++ b/source/Supervisor.js @@ -19,8 +19,6 @@ export default class Supervisor { const predictions = this._createPredictions(journal); const ordered = this._sortPredictions(predictions); - console.log(ordered); - return ordered[0].value; }