UNPKG

phaser3-rex-plugins

Version:
2 lines (1 loc) 23.9 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).rexfuzzyplugin=e();}(undefined,(function(){function t(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function e(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,(i=n.key,s=void 0,"symbol"==typeof(s=function(t,e){if("object"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return ("string"===e?String:Number)(t)}(i,"string"))?s:String(s)),n);}var i,s;}function r(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function n(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&s(t,e);}function i(t){return i=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},i(t)}function s(t,e){return s=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},s(t,e)}function o(){if("undefined"==typeof Reflect||!Reflect.construct)return !1;if(Reflect.construct.sham)return !1;if("function"==typeof Proxy)return !0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return !1}}function a(t,e,r){return a=o()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var i=new(Function.bind.apply(t,n));return r&&s(i,r.prototype),i},a.apply(null,arguments)}function h(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function u(t){var e=o();return function(){var r,n=i(t);if(e){var s=i(this).constructor;r=Reflect.construct(n,arguments,s);}else r=n.apply(this,arguments);return h(this,r)}}function l(t){return function(t){if(Array.isArray(t))return c(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return c(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return c(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var f=function(t){return -1!==t.indexOf(".")?t.split(".")[0]:t.replace(/[+-]*/g,"")},y=function(){function e(){t(this,e),this.rules=[],this.flvs={};}return r(e,[{key:"addFLV",value:function(t,e){return this.flvs[t]=e,this}},{key:"removeFLV",value:function(t){return delete this.flvs[t],this}},{key:"hasFLV",value:function(t){return this.flvs.hasOwnProperty(t)}},{key:"addRule",value:function(t){return this.rules.push(t),this}},{key:"removeRule",value:function(t){var e=this.rules,r=e.indexOf(t);return e.splice(r,1),this}},{key:"fuzzify",value:function(t,e){if("string"==typeof t)this._fuzzify(t,e);else {var r=t;for(t in r)this._fuzzify(t,r[t]);}return this.dirty=!0,this}},{key:"_fuzzify",value:function(t,e){this.hasFLV(t)&&this.flvs[t].fuzzify(e);}},{key:"defuzzify",value:function(t){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.DEFUZ_TYPE.MAXAV;if(this._evaluate(),"string"==typeof t)r=this._defuzzify(t,n);else if(Array.isArray(t)){r={};for(var i=t,s=0,o=i.length;s<o;s++)r[t=i[s]]=this._defuzzify(t,n);}else {for(var a=[],h=this.rules,u=0,l=h.length;u<l;u++){var c=h[u].consequence,y=f(c.name);-1===a.indexOf(y)&&a.push(y);}r=this.defuzzify(a,n);}return r}},{key:"_defuzzify",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.DEFUZ_TYPE.MAXAV;if(this.hasFLV(t)){var n,i=this.flvs[t];switch(r){case e.DEFUZ_TYPE.MAXAV:n=i.defuzzifyMaxAv();break;case e.DEFUZ_TYPE.CENTROID:n=i.defuzzifyCentroid();break;default:n=i.defuzzifyMaxAv();}return n}}},{key:"_evaluate",value:function(){if(this.dirty){var t=this.rules;this._initConsequences();for(var e=0,r=t.length;e<r;e++)t[e].evaluate();this.dirty=!1;}}},{key:"_initConsequences",value:function(){for(var t=this.rules,e=0,r=t.length;e<r;e++){t[e].initConsequence();}return this}}]),e}();y.DEFUZ_TYPE=Object.freeze({MAXAV:0,CENTROID:1});var p=function(){function e(){t(this,e),this.fuzzySets=[],this.minRange=1/0,this.maxRange=-1/0;}return r(e,[{key:"add",value:function(t){return this.fuzzySets.push(t),t.left<this.minRange&&(this.minRange=t.left),t.right>this.maxRange&&(this.maxRange=t.right),this}},{key:"remove",value:function(t){var e=this.fuzzySets,r=e.indexOf(t);e.splice(r,1),this.minRange=1/0,this.maxRange=-1/0;for(var n=0,i=e.length;n<i;n++){var s=e[n];s.left<this.minRange&&(this.minRange=s.left),s.right>this.maxRange&&(this.maxRange=s.right);}return this}},{key:"fuzzify",value:function(t){if(!(t<this.minRange||t>this.maxRange)){for(var e=this.fuzzySets,r=0,n=e.length;r<n;r++){var i=e[r];i.degreeOfMembership=i.computeDegreeOfMembership(t);}return this}}},{key:"defuzzifyMaxAv",value:function(){for(var t=this.fuzzySets,e=0,r=0,n=0,i=t.length;n<i;n++){var s=t[n];e+=s.degreeOfMembership,r+=s.representativeValue*s.degreeOfMembership;}return 0===e?0:r/e}},{key:"defuzzifyCentroid",value:function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10,e=this.fuzzySets,r=(this.maxRange-this.minRange)/t,n=0,i=0,s=1;s<=t;s++)for(var o=this.minRange+s*r,a=0,h=e.length;a<h;a++){var u=e[a],l=Math.min(u.degreeOfMembership,u.computeDegreeOfMembership(o));n+=l,i+=o*l;}return 0===n?0:i/n}}]),e}(),g=function(){function e(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;t(this,e),this.degreeOfMembership=0,this.representativeValue=r,this.left=0,this.right=0;}return r(e,[{key:"computeDegreeOfMembership",value:function(){}},{key:"clearDegreeOfMembership",value:function(){return this.degreeOfMembership=0,this}},{key:"getDegreeOfMembership",value:function(){return this.degreeOfMembership}},{key:"updateDegreeOfMembership",value:function(t){return t>this.degreeOfMembership&&(this.degreeOfMembership=t),this}}]),e}(),m=function(e){n(s,e);var i=u(s);function s(e,r,n){var o;t(this,s);var a=(r+e)/2;return (o=i.call(this,a)).left=e,o.midpoint=r,o.right=n,o}return r(s,[{key:"computeDegreeOfMembership",value:function(t){var e=this.midpoint,r=this.left,n=this.right;return t>=r&&t<=e?1:t>e&&t<=n?1/(n-e)*(n-t):0}}]),s}(g),v=function(e){n(s,e);var i=u(s);function s(e,r,n){var o;t(this,s);var a=(r+e)/2;return (o=i.call(this,a)).left=e,o.midpoint=r,o.right=n,o}return r(s,[{key:"computeDegreeOfMembership",value:function(t){var e=this.midpoint,r=this.left,n=this.right;return t>=r&&t<=e?1:t>e&&t<=n?t>=(e+n)/2?2*Math.pow((t-n)/(e-n),2):1-2*Math.pow((t-e)/(e-n),2):0}}]),s}(g),d=function(e){n(s,e);var i=u(s);function s(e,r,n){var o;t(this,s);var a=(r+n)/2;return (o=i.call(this,a)).left=e,o.midpoint=r,o.right=n,o}return r(s,[{key:"computeDegreeOfMembership",value:function(t){var e=this.midpoint,r=this.left,n=this.right;return t>=r&&t<=e?1/(e-r)*(t-r):t>e&&t<=n?1:0}}]),s}(g),b=function(e){n(s,e);var i=u(s);function s(e,r,n){var o;t(this,s);var a=(r+n)/2;return (o=i.call(this,a)).left=e,o.midpoint=r,o.right=n,o}return r(s,[{key:"computeDegreeOfMembership",value:function(t){var e=this.midpoint,r=this.left,n=this.right;return t>=r&&t<=e?t<=(r+e)/2?2*Math.pow((t-r)/(e-r),2):1-2*Math.pow((t-e)/(e-r),2):t>e&&t<=n?1:0}}]),s}(g),_=function(e){n(s,e);var i=u(s);function s(e,r,n){var o;return t(this,s),(o=i.call(this,r)).left=e,o.midpoint=r,o.right=n,o}return r(s,[{key:"computeDegreeOfMembership",value:function(t){var e=this.midpoint,r=this.left,n=this.right;return t>=r&&t<=e?1/(e-r)*(t-r):t>e&&t<=n?1/(n-e)*(n-t):0}}]),s}(g),k=function(e){n(s,e);var i=u(s);function s(e,r,n){var o;return t(this,s),(o=i.call(this,r)).left=e,o.midpoint=r,o.right=n,o}return r(s,[{key:"computeDegreeOfMembership",value:function(t){var e=this.left,r=this.right;return t>=e&&t<=r?1:0}}]),s}(g),O=function(e){n(s,e);var i=u(s);function s(e,r,n,o){var a;return t(this,s),(a=i.call(this,r)).left=e,a.midpoint=r,a.right=n,a.standardDeviation=o,a._cache={},a}return r(s,[{key:"computeDegreeOfMembership",value:function(t){return this._updateCache(),t>=this.right||t<=this.left?0:M(t,this.midpoint,this._cache.variance)/this._cache.normalizationFactor}},{key:"_updateCache",value:function(){var t=this._cache,e=this.midpoint,r=this.standardDeviation;if(e!==t.midpoint||r!==t.standardDeviation){var n=r*r;t.midpoint=e,t.standardDeviation=r,t.variance=n,t.normalizationFactor=M(e,e,n);}return this}}]),s}(g),M=function(t,e,r){return 1/Math.sqrt(2*Math.PI*r)*Math.exp(-Math.pow(t-e,2)/(2*r))},x={leftShoulder:m,leftSCurve:v,rightShoulder:d,rightSCurve:b,triangular:_,singleton:k,normal:O},w=function(t){for(var e,r,n,i=new p,s=0,o=t.length;s<o;s++){var h=t[s],u=(r=0===s?0:s==o-1?2:3,n=void 0,void 0===(n=(e=h).type)&&(n=0===r?"leftShoulder":2===r?"rightShoulder":"triangular"),a(x[n],l(e.parameters)));u.name=h.name,i.add(u);}return i};function z(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function D(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var A={};!function(t){var e=function(){var t=function(t,e,r,n){for(r=r||{},n=t.length;n--;r[t[n]]=e);return r},e=[1,5],r=[1,6],n=[1,7],i=[1,10],s=[1,11],o=[1,12],a=[2,14],h=[1,15],u=[5,16,17],l=[5,13,14,16,17],c={trace:function(){},yy:{},symbols_:{error:2,expressions:3,varExp:4,EOF:5,ruleExp:6,NAME:7,":":8,NUMBER:9,",":10,VERY:11,FAIRLY:12,AND:13,OR:14,"(":15,")":16,"=>":17,$accept:0,$end:1},terminals_:{2:"error",5:"EOF",7:"NAME",8:":",9:"NUMBER",10:",",11:"VERY",12:"FAIRLY",13:"AND",14:"OR",15:"(",16:")",17:"=>"},productions_:[0,[3,2],[3,2],[4,11],[4,9],[4,7],[4,5],[4,7],[6,2],[6,2],[6,3],[6,3],[6,3],[6,3],[6,1]],performAction:function(t,e,r,n,i,s,o){var a,h,u=s.length-1;switch(i){case 1:case 2:return s[u-1];case 3:var l=s[u-10],c=s[u],f=Number(s[u-8]),y=Number(s[u-6]),p=Number(s[u-4]),g=Number(s[u-2]);this.$={name:l,type:c,parameters:[f,y,p,g]};break;case 4:l=s[u-8],c=s[u],f=Number(s[u-6]),y=Number(s[u-4]),p=Number(s[u-2]);this.$={name:l,type:c,parameters:[f,y,p]};break;case 5:l=s[u-6],c=void 0,f=Number(s[u-4]),y=Number(s[u-2]),p=Number(s[u]);this.$={name:l,type:c,parameters:[f,y,p]};break;case 6:l=s[u-4],c=void 0,y=((f=Number(s[u-2]))+(p=Number(s[u])))/2;this.$={name:l,type:c,parameters:[f,y,p]};break;case 7:l=s[u-6],c=s[u],y=((f=Number(s[u-4]))+(p=Number(s[u-2])))/2;this.$={name:l,type:c,parameters:[f,y,p]};break;case 8:case 9:this.$=(a=s[u-1],h=s[u],[a=a.toLowerCase(),h]);break;case 10:case 11:this.$=function(t,e,r){t=t.toLowerCase();var n=[t];if(Array.isArray(e)&&e[0]===t)for(var i=1,s=e.length;i<s;i++)n.push(e[i]);else n.push(e);if(Array.isArray(r)&&r[0]===t)for(i=1,s=r.length;i<s;i++)n.push(r[i]);else n.push(r);return n}(s[u-1],s[u-2],s[u]);break;case 12:this.$=s[u-1];break;case 13:this.$=["=>",s[u-2],s[u]];break;case 14:this.$=s[u];}},table:[{3:1,4:2,6:3,7:[1,4],11:e,12:r,15:n},{1:[3]},{5:[1,8]},{5:[1,9],13:i,14:s,17:o},t([5,13,14,17],a,{8:[1,13]}),{6:14,7:h,11:e,12:r,15:n},{6:16,7:h,11:e,12:r,15:n},{6:17,7:h,11:e,12:r,15:n},{1:[2,1]},{1:[2,2]},{6:18,7:h,11:e,12:r,15:n},{6:19,7:h,11:e,12:r,15:n},{7:[1,20]},{9:[1,21]},t(u,[2,8],{13:i,14:s}),t(l,a),t(u,[2,9],{13:i,14:s}),{13:i,14:s,16:[1,22],17:o},t([5,13,16,17],[2,10],{14:s}),t(l,[2,11]),t(l,[2,13]),{10:[1,23]},t(l,[2,12]),{9:[1,24]},{5:[2,6],10:[1,25]},{7:[1,27],9:[1,26]},{5:[2,5],10:[1,28]},{5:[2,7]},{7:[1,30],9:[1,29]},{10:[1,31]},{5:[2,4]},{7:[1,32]},{5:[2,3]}],defaultActions:{8:[2,1],9:[2,2],27:[2,7],30:[2,4],32:[2,3]},parseError:function(t,e){if(!e.recoverable){var r=new Error(t);throw r.hash=e,r}this.trace(t);},parse:function(t){var e=this,r=[0],n=[null],i=[],s=this.table,o="",a=0,h=0,u=i.slice.call(arguments,1),l=Object.create(this.lexer),c={yy:{}};for(var f in this.yy)Object.prototype.hasOwnProperty.call(this.yy,f)&&(c.yy[f]=this.yy[f]);l.setInput(t,c.yy),c.yy.lexer=l,c.yy.parser=this,void 0===l.yylloc&&(l.yylloc={});var y=l.yylloc;i.push(y);var p=l.options&&l.options.ranges;"function"==typeof c.yy.parseError?this.parseError=c.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;for(var g,m,v,d,b,_,k,O,M,x={};;){if(m=r[r.length-1],this.defaultActions[m]?v=this.defaultActions[m]:(null==g&&(M=void 0,"number"!=typeof(M=l.lex()||1)&&(M=e.symbols_[M]||M),g=M),v=s[m]&&s[m][g]),void 0===v||!v.length||!v[0]){var w="";for(b in O=[],s[m])this.terminals_[b]&&b>2&&O.push("'"+this.terminals_[b]+"'");w=l.showPosition?"Parse error on line "+(a+1)+":\n"+l.showPosition()+"\nExpecting "+O.join(", ")+", got '"+(this.terminals_[g]||g)+"'":"Parse error on line "+(a+1)+": Unexpected "+(1==g?"end of input":"'"+(this.terminals_[g]||g)+"'"),this.parseError(w,{text:l.match,token:this.terminals_[g]||g,line:l.yylineno,loc:y,expected:O});}if(v[0]instanceof Array&&v.length>1)throw new Error("Parse Error: multiple actions possible at state: "+m+", token: "+g);switch(v[0]){case 1:r.push(g),n.push(l.yytext),i.push(l.yylloc),r.push(v[1]),g=null,h=l.yyleng,o=l.yytext,a=l.yylineno,y=l.yylloc;break;case 2:if(_=this.productions_[v[1]][1],x.$=n[n.length-_],x._$={first_line:i[i.length-(_||1)].first_line,last_line:i[i.length-1].last_line,first_column:i[i.length-(_||1)].first_column,last_column:i[i.length-1].last_column},p&&(x._$.range=[i[i.length-(_||1)].range[0],i[i.length-1].range[1]]),void 0!==(d=this.performAction.apply(x,[o,h,a,c.yy,v[1],n,i].concat(u))))return d;_&&(r=r.slice(0,-1*_*2),n=n.slice(0,-1*_),i=i.slice(0,-1*_)),r.push(this.productions_[v[1]][0]),n.push(x.$),i.push(x._$),k=s[r[r.length-2]][r[r.length-1]],r.push(k);break;case 3:return !0}}return !0}};var f={EOF:1,parseError:function(t,e){if(!this.yy.parser)throw new Error(t);this.yy.parser.parseError(t,e);},setInput:function(t,e){return this.yy=e||this.yy||{},this._input=t,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var t=this._input[0];return this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t,t.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),t},unput:function(t){var e=t.length,r=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-e),this.offset-=e;var n=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),r.length-1&&(this.yylineno-=r.length-1);var i=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:r?(r.length===n.length?this.yylloc.first_column:0)+n[n.length-r.length].length-r[0].length:this.yylloc.first_column-e},this.options.ranges&&(this.yylloc.range=[i[0],i[0]+this.yyleng-e]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(t){this.unput(this.match.slice(t));},pastInput:function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return (t.length>20?"...":"")+t.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var t=this.match;return t.length<20&&(t+=this._input.substr(0,20-t.length)),(t.substr(0,20)+(t.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var t=this.pastInput(),e=new Array(t.length+1).join("-");return t+this.upcomingInput()+"\n"+e+"^"},test_match:function(t,e){var r,n,i;if(this.options.backtrack_lexer&&(i={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(i.yylloc.range=this.yylloc.range.slice(0))),(n=t[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=n.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:n?n[n.length-1].length-n[n.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+t[0].length},this.yytext+=t[0],this.match+=t[0],this.matches=t,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(t[0].length),this.matched+=t[0],r=this.performAction.call(this,this.yy,this,e,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),r)return r;if(this._backtrack){for(var s in i)this[s]=i[s];return !1}return !1},next:function(){if(this.done)return this.EOF;var t,e,r,n;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var i=this._currentRules(),s=0;s<i.length;s++)if((r=this._input.match(this.rules[i[s]]))&&(!e||r[0].length>e[0].length)){if(e=r,n=s,this.options.backtrack_lexer){if(!1!==(t=this.test_match(r,i[s])))return t;if(this._backtrack){e=!1;continue}return !1}if(!this.options.flex)break}return e?!1!==(t=this.test_match(e,i[n]))&&t:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var t=this.next();return t||this.lex()},begin:function(t){this.conditionStack.push(t);},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(t){return (t=this.conditionStack.length-1-Math.abs(t||0))>=0?this.conditionStack[t]:"INITIAL"},pushState:function(t){this.begin(t);},stateStackSize:function(){return this.conditionStack.length},options:{},performAction:function(t,e,r,n){switch(r){case 0:break;case 1:return ":";case 2:return ",";case 3:return 17;case 4:case 5:return 14;case 6:case 7:return 13;case 8:case 9:return 11;case 10:case 11:return 12;case 12:return 15;case 13:return 16;case 14:return 9;case 15:return 7;case 16:return 5;case 17:return "INVALID"}},rules:[/^(?:\s+)/,/^(?::)/,/^(?:,)/,/^(?:=>)/,/^(?:or\b)/,/^(?:OR\b)/,/^(?:and\b)/,/^(?:AND\b)/,/^(?:very\b)/,/^(?:VERY\b)/,/^(?:fairly\b)/,/^(?:FAIRLY\b)/,/^(?:\()/,/^(?:\))/,/^(?:[0-9]+(\.[0-9]+)?\b)/,/^(?:[0-9a-zA-Z_.]+[+-]*)/,/^(?:$)/,/^(?:.)/],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17],inclusive:!0}}};function y(){this.yy={};}return c.lexer=f,y.prototype=c,c.Parser=y,new y}();void 0!==D&&(t.parser=e,t.Parser=e.Parser,t.parse=function(){return e.parse.apply(e,arguments)});}(A);var E=new(z(A).Parser),S=function(t){return E.parse(t)},R=function(t){return 0===t.length||!t.trim()||("//"===t.trimStart().substring(0,2)||void 0)},P=function(t){for(var e={},r=0,n=t.length;r<n;r++){var i=t[r],s=f(i.name);e.hasOwnProperty(s)||(e[s]=[]),e[s].push(i);}return e},I=function(){function e(r,n){t(this,e),this.antecedent=r,this.consequence=n;}return r(e,[{key:"initConsequence",value:function(){return this.consequence.clearDegreeOfMembership(),this}},{key:"evaluate",value:function(){return this.consequence.updateDegreeOfMembership(this.antecedent.getDegreeOfMembership()),this}}]),e}(),N=function(){function e(r){t(this,e),this.terms=r;}return r(e,[{key:"clearDegreeOfMembership",value:function(){for(var t=this.terms,e=0,r=t.length;e<r;e++)t[e].clearDegreeOfMembership();return this}},{key:"updateDegreeOfMembership",value:function(t){for(var e=this.terms,r=0,n=e.length;r<n;r++)e[r].updateDegreeOfMembership(t);return this}}]),e}(),j=function(e){n(s,e);var i=u(s);function s(){t(this,s);var e=Array.from(arguments);return i.call(this,e)}return r(s,[{key:"getDegreeOfMembership",value:function(){for(var t=this.terms,e=1/0,r=0,n=t.length;r<n;r++){var i=t[r].getDegreeOfMembership();i<e&&(e=i);}return e}}]),s}(N),F=function(e){n(s,e);var i=u(s);function s(){t(this,s);var e=Array.from(arguments);return i.call(this,e)}return r(s,[{key:"getDegreeOfMembership",value:function(){for(var t=this.terms,e=-1/0,r=0,n=t.length;r<n;r++){var i=t[r].getDegreeOfMembership();i>e&&(e=i);}return e}}]),s}(N),T=function(e){n(s,e);var i=u(s);function s(e){return t(this,s),i.call(this,[e])}return r(s,[{key:"clearDegreeOfMembership",value:function(){return this.terms[0].clearDegreeOfMembership(),this}},{key:"getDegreeOfMembership",value:function(){var t=this.terms[0].getDegreeOfMembership();return Math.sqrt(t)}},{key:"updateDegreeOfMembership",value:function(t){return this.terms[0].updateDegreeOfMembership(Math.sqrt(t)),this}}]),s}(N),$=function(e){n(s,e);var i=u(s);function s(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return t(this,s),i.call(this,[e])}return r(s,[{key:"clearDegreeOfMembership",value:function(){return this.terms[0].clearDegreeOfMembership(),this}},{key:"getDegreeOfMembership",value:function(){var t=this.terms[0].getDegreeOfMembership();return t*t}},{key:"updateDegreeOfMembership",value:function(t){return this.terms[0].updateDegreeOfMembership(t*t),this}}]),s}(N),C=function(t,e){var r=S(t),n=L(r[1],e),i=e[r[2]];return new I(n,i)},L=function t(e,r){if(!e)return null;if("string"==typeof e){if(!r.hasOwnProperty(e))throw "Can't find fuzzy set ".concat(e);return r[e]}for(var n=[],i=1,s=e.length;i<s;i++)n.push(t(e[i],r));return a(V[e[0]],n)},V={and:j,or:F,fairly:T,very:$},q=function(t){if("string"==typeof t){for(var e=[],r=[],n=t.split("\n"),i=0,s=n.length;i<s;i++){var o=n[i];R(o)||(-1!==o.indexOf("=>")?r.push(o):e.push(o));}t={variables:e,rules:r};}var a=new y;return function(t,e){if("string"==typeof e&&(e=e.split("\n")),Array.isArray(e)){var r=e;e=[];for(var n=0,i=r.length;n<i;n++){var s=r[n];"string"==typeof s?R(s)||e.push(S(s)):e.push(s);}e=P(e);}for(var o in e){var a=w(e[o]);t.addFLV(o,a);}}(a,t.variables),function(t,e,r){"string"==typeof e&&(e=e.split("\n"));for(var n=0,i=e.length;n<i;n++){var s=e[n];R(s)||t.addRule(C(s,r));}}(a,t.rules,function(t){var e={},r=t.flvs;for(var n in r)for(var i=r[n].fuzzySets,s=0,o=i.length;s<o;s++){var a=i[s];e[a.name]=a;}return e}(a)),a};return function(e){n(s,Phaser.Plugins.BasePlugin);var i=u(s);function s(e){return t(this,s),i.call(this,e)}return r(s,[{key:"start",value:function(){this.game.events.on("destroy",this.destroy,this);}},{key:"add",value:function(t){return q(t)}}]),s}()}));