diff --git a/app/creature.js b/app/creature.js index 534e1de..bfac2fa 100644 --- a/app/creature.js +++ b/app/creature.js @@ -1,10 +1,11 @@ var _ = require('./util.js'); // abstract factory that adds a superclass of baseCreature -var creatureFactory = (function () { +var factory = (function () { function baseCreature() { this.age = 0; } + function baseCA() {} baseCreature.prototype.initialEnergy = 50; baseCreature.prototype.maxEnergy = 100; @@ -33,7 +34,7 @@ var creatureFactory = (function () { if (spots.length) { var step = spots[_.random(spots.length - 1)]; var coords = step.coords; - var creature = creatureFactory.make(this.type); + var creature = factory.make(this.type); var successFn = (function () { this.energy -= this.initialEnergy; @@ -119,6 +120,11 @@ var creatureFactory = (function () { } else return false; }; + baseCA.prototype.boundEnergy = function () {}; + baseCA.prototype.isDead = function () { return false; }; + baseCA.prototype.queue = function (neighbors) {}; + baseCA.prototype.wait = function () {}; + // Storage for our creature types var types = {}; @@ -128,7 +134,7 @@ var creatureFactory = (function () { return (Creature ? new Creature(options) : false); }, - register: function (options, init) { + registerCreature: function (options, init) { // required attributes var type = options.type; // only register classes that fulfill the creature contract @@ -162,10 +168,37 @@ var creatureFactory = (function () { types[type].prototype.failureFn = types[type].wait; types[type].prototype.energy = options.initialEnergy; + return true; + } else return false; + }, + + registerCA: function (options, init) { + // required attributes + var type = options.type; + // only register classes that fulfill the creature contract + if (typeof type === 'string' && typeof types[type] === 'undefined') { + // set the constructor, including init if it's defined + types[type] = typeof init === 'function' ? + function () { init.call(this); } : + function () {}; + + var color = options.color; + // set the color randomly if none is provided + if (typeof color !== 'object' || color.length !== 3) { + options.color = [_.random(255), _.random(255), _.random(255)]; + } + + types[type].prototype = new baseCA(); + types[type].prototype.constructor = types[type]; + + _.each(options, function(value, key) { + types[type].prototype[key] = value; + }); + return true; } else return false; } }; })(); -module.exports = creatureFactory; +module.exports = factory; diff --git a/app/main.js b/app/main.js index a2c3c01..ca62ce6 100644 --- a/app/main.js +++ b/app/main.js @@ -1,7 +1,8 @@ var Terrarium = require('./terrarium.js'); -var creatureFactory = require('./creature.js'); +var factory = require('./creature.js'); module.exports = { Terrarium: Terrarium, - creatureFactory: creatureFactory + registerCreature: factory.registerCreature, + registerCA: factory.registerCA }; diff --git a/app/terrarium.js b/app/terrarium.js index 91fd695..a90826b 100644 --- a/app/terrarium.js +++ b/app/terrarium.js @@ -1,5 +1,5 @@ var _ = require('./util'); -var creatureFactory = require('./creature.js'); +var factory = require('./creature.js'); var display = require('./display.js'); var dom = require('./dom.js'); @@ -34,7 +34,7 @@ Terrarium.prototype.makeGrid = function (content) { for (var x = 0, _w = this.width; x < _w; x++) { grid.push([]); for (var y = 0, _h = this.height; y < _h; y++) { - grid[x].push(creatureFactory.make( + grid[x].push(factory.make( type === 'function' ? content(x, y) : type === 'object' && content.length ? (content[y] || [])[x] : type === 'string' ? content : @@ -53,7 +53,7 @@ Terrarium.prototype.makeGridWithDistribution = function (distribution) { for (var x = 0, _w = this.width; x < _w; x++) { grid.push([]); for (var y = 0, _h = this.height; y < _h; y++) { - grid[x].push(creatureFactory.make(_.pickRandomWeighted(distribution))); + grid[x].push(factory.make(_.pickRandomWeighted(distribution))); } } return grid; }; diff --git a/dist/terra.js b/dist/terra.js index ec4150f..ab61b21 100755 --- a/dist/terra.js +++ b/dist/terra.js @@ -1,20 +1,22 @@ !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.terra=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;othis.maxEnergy&&(this.energy=this.maxEnergy)},t.prototype.isDead=function(){return this.energy<=0},t.prototype.reproduce=function(t){var e=n.filter(t,function(t){return!t.creature});if(e.length){var o=e[n.random(e.length-1)],i=o.coords,u=r.make(this.type),a=function(){return this.energy-=this.initialEnergy,!0}.bind(this),c=this.wait;return{x:i.x,y:i.y,creature:u,successFn:a,failureFn:c}}return!1},t.prototype.move=function(t){var e=this,r=n.filter(t,function(t){return t.creature.sizen*this.reproduceLv&&this.reproduce?e=this.reproduce(t):this.energy>n*this.moveLv&&this.move&&(e=this.move(t));var r=e.creature;return r?(r.successFn=e.successFn||r.wait,r.failureFn=e.failureFn||r.wait,{x:e.x,y:e.y,creature:r}):!1};var e={};return{make:function(t,n){var r=e[t];return r?new r(n):!1},register:function(r,o){var i=r.type;if("string"==typeof i&&"undefined"==typeof e[i]){e[i]="function"==typeof o?function(){this.energy=this.initialEnergy,o.call(this)}:function(){this.energy=this.initialEnergy};var u=r.color;return("object"!=typeof u||3!==u.length)&&(r.color=[n.random(255),n.random(255),n.random(255)]),e[i].prototype=new t,e[i].prototype.constructor=e[i],n.each(r,function(t,n){e[i].prototype[n]=t}),e[i].prototype.successFn=e[i].wait,e[i].prototype.failureFn=e[i].wait,e[i].prototype.energy=r.initialEnergy,!0}return!1}}}();e.exports=r},{"./util.js":6}],3:[function(t,e){var n=t("./util.js");e.exports=function(t,e,r){var o=t.getContext("2d");o.clearRect(0,0,t.width,t.height),n.each(e,function(t,e){n.each(t,function(t,n){if(t){var i=t.colorFn?t.colorFn():t.color+","+t.energy/t.maxEnergy;o.fillStyle="rgba("+i+")",t.character?o.fillText(t.character,e*r,n*r+r):o.fillRect(e*r,n*r,r,r)}})})}},{"./util.js":6}],4:[function(t,e){var n=function(t,e,n,r,o){function i(o){var i=document.createElement("canvas"),u=i.getContext("2d");return o=function(){var t=document.createElement("canvas").getContext("2d"),e=window.devicePixelRatio||1,n=t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1;return e/n}(),i.width=t*o,i.height=e*o,i.style.width=t+"px",i.style.height=e+"px",u.setTransform(o,0,0,o,0,0),u.font="bold "+n+"px Arial",r&&(i.id=r),i}t*=n,e*=n;var u=i();return o?o.parentNode.insertBefore(u,o.nextSibling):document.body.appendChild(u),u};e.exports={createCanvasElement:n}},{}],5:[function(t,e){function n(t,e,n,r,o){r=r||10,this.cellSize=r,this.width=t,this.height=e,this.grid=[],this.canvas=u.createCanvasElement(t,e,r,n,o),this.nextFrame=!1}var r=t("./util"),o=t("./creature.js"),i=t("./display.js"),u=t("./dom.js");n.prototype.makeGrid=function(t){for(var e=[],n=typeof t,r=0,i=this.width;i>r;r++){e.push([]);for(var u=0,a=this.height;a>u;u++)e[r].push(o.make("function"===n?t(r,u):"object"===n&&t.length?(t[u]||[])[r]:"string"===n?t:void 0))}return e},n.prototype.makeGridWithDistribution=function(t){for(var e=[],n=0,i=this.width;i>n;n++){e.push([]);for(var u=0,a=this.height;a>u;u++)e[n].push(o.make(r.pickRandomWeighted(t)))}return e},n.prototype.step=function(t){function e(t){if(t){var e=r.assign(new t.constructor,t);return e&&!e.isDead()?e:!1}return!1}function n(t){return r.map(t,e)}function o(t){return{coords:t,creature:y[t.x][t.y]}}function i(t){var e=t.creature;e?(e.failureFn(),e.boundEnergy()):(t.wait(),t.boundEnergy())}function u(t,e,n){if(t){var u=r.map(r.getNeighborCoords(e,n,p-1,h-1,t.actionRadius),o),a=t.queue(u);if(a){var c=l[a.x];c[a.y]||(c[a.y]=[]),c[a.y].push({x:e,y:n,creature:a.creature})}else i(t)}}function a(t,e){r.each(t,function(t,n){u(t,e,n)})}function c(t,e,n){if(t){var o=t.splice(r.random(t.length-1),1)[0],u=o.creature;u.successFn()||(s[o.x][o.y]=!1),u.boundEnergy(),s[e][n]=u,r.each(t,i)}}function f(t,e){r.each(t,function(t,n){c(t,e,n)})}var s,l,p=this.width,h=this.height,y=this.grid;for("number"!=typeof t&&(t=1);t--;)y=s?r.clone(s):this.grid,s=r.map(y,n),l=this.makeGrid(),r.each(s,a),r.each(l,f);return s},n.prototype.draw=function(){i(this.canvas,this.grid,this.cellSize)},n.prototype.animate=function(t,e){function n(){o.grid=o.step(),o.draw(),r++!==t?o.nextFrame=requestAnimationFrame(n):(o.nextFrame=!1,e())}if(!this.nextFrame){var r=0,o=this;o.nextFrame=requestAnimationFrame(n)}},n.prototype.stop=function(){cancelAnimationFrame(this.nextFrame),this.nextFrame=!1},e.exports=n},{"./creature.js":2,"./display.js":3,"./dom.js":4,"./util":6}],6:[function(t,e){t("../bower_components/seedrandom/seedrandom.js")("terra :)",{global:!0});var n=t("../lodash_custom/lodash.custom.min.js")._;n.getNeighborCoords=function(t,e,n,r,o){var i,u,a,c,f=[];("number"!=typeof o||1>o)&&(o=1),i=Math.max(0,t-o),a=Math.max(0,e-o),u=Math.min(t+o,n),c=Math.min(e+o,r);for(var s=i;u>=s;s++)for(var l=a;c>=l;l++)(s!==t||l!==e)&&f.push({x:s,y:l});return f},n.pickRandomWeighted=function(t){var e,r,o=0,i=n.random(100,!0);for(r=0,_len=t.length;_len>r;r++)if(e=t[r],o+=e[1],o>i)return e[0];return!1},e.exports=n},{"../bower_components/seedrandom/seedrandom.js":7,"../lodash_custom/lodash.custom.min.js":8}],7:[function(e,n){!function(t,e,n,r,o,i,u,a,c){function f(t){var e,n=t.length,o=this,i=0,u=o.i=o.j=0,a=o.S=[];for(n||(t=[n++]);r>i;)a[i]=i++;for(i=0;r>i;i++)a[i]=a[u=m&u+t[i%n]+(e=a[i])],a[u]=e;(o.g=function(t){for(var e,n=0,i=o.i,u=o.j,a=o.S;t--;)e=a[i=m&i+1],n=n*r+a[m&(a[i]=a[u=m&u+e])+(a[u]=e)];return o.i=i,o.j=u,n})(r)}function s(t,e){var n,r=[],o=typeof t;if(e&&"object"==o)for(n in t)try{r.push(s(t[n],e-1))}catch(i){}return r.length?r:"string"==o?t:t+"\x00"}function l(t,e){for(var n,r=t+"",o=0;ot;)t=(t+n)*r,e*=r,n=v.g(1);for(;t>=d;)t/=2,e/=2,n>>>=1;return(t+n)/e},m,"global"in i?i.global:this==n)};l(n[c](),e),u&&u.exports?u.exports=v:a&&a.amd&&a(function(){return v})}(this,[],Math,256,6,52,"object"==typeof n&&n,"function"==typeof t&&t,"random")},{}],8:[function(t,e,n){(function(t){(function(){function r(t){return"function"!=typeof t.toString&&"string"==typeof(t+"")}function o(t){t.length=0,A.lengthn?0:n);++rk;k++)r+="n='"+n.h[k]+"';if((!(r&&x[n])&&m.call(t,n))",n.j||(r+="||(!x[n]&&t[n]!==A[n])"),r+="){"+n.g+"}";r+="}"}return(n.b||xe.nonEnumArgs)&&(r+="}"),r+=n.c+";return E",t("d,j,k,m,o,p,q,s,v,A,B,y,I,J,L",e+r+"}")(s,T,ee,ce,D,d,we,b,V.f,ne,H,be,U,re,oe)}function g(t){return"function"==typeof t&&ie.test(t)}function d(t){return t&&"object"==typeof t&&"number"==typeof t.length&&oe.call(t)==z||!1}function m(t){return"function"==typeof t}function v(t){return!(!t||!H[typeof t])}function b(t){return"string"==typeof t||t&&"object"==typeof t&&oe.call(t)==U||!1}function x(t,e,n){var r=[];if(e=u.createCallback(e,n,3),we(t)){n=-1;for(var o=t.length;++narguments.length;if(e=u.createCallback(e,r,4),we(t)){var i=-1,a=t.length;for(o&&(n=t[++i]);++i3&&typeof a[c-2]=='function'){var e=d(a[--c-1],a[c--],2)}else if(c>2&&typeof a[c-1]=='function'){e=a[--c]}"),g:"E[n]=e?e(E[n],t[n]):t[n]"}),Oe=y(Z,Fe,{j:!1}),Ce=y(Z,Fe);m(/x/)&&(m=function(t){return"function"==typeof t&&"[object Function]"==oe.call(t)}),u.assign=Se,u.bind=F,u.createCallback=function(t,e,n){var r=typeof t;if(null==t||"function"==r)return s(t,e,n);if("object"!=r)return C(t);var o=_e(t),i=o[0],u=t[i];return 1!=o.length||u!==u||v(u)?function(e){for(var n=o.length,r=!1;n--&&(r=p(e[o[n]],t[o[n]],null,!0)););return r}:function(t){return t=t[i],u===t&&(0!==u||1/u==1/t)}},u.filter=x,u.forEach=j,u.forIn=Oe,u.forOwn=Ce,u.keys=_e,u.map=w,u.property=C,u.collect=w,u.each=j,u.extend=Se,u.select=x,u.clone=function(t,e,n,r){return"boolean"!=typeof e&&null!=e&&(r=n,n=e,e=!1),c(t,e,"function"==typeof n&&s(n,r,1))},u.identity=S,u.isArguments=d,u.isArray=we,u.isFunction=m,u.isObject=v,u.isString=b,u.noop=O,u.random=function(t,e,n){var r=null==t,o=null==e;return null==n&&("boolean"==typeof t&&o?(n=t,t=1):o||"boolean"!=typeof e||(n=e,o=!0)),r&&o&&(e=1),t=+t||0,o?(e=t,t=0):e=+e||0,n||t%1||e%1?(n=me(),de(t+n*(e-t+parseFloat("1e-"+((n+"").length-1))),e)):t+ue(me()*(e-t+1))},u.reduce=E,u.some=_,u.any=_,u.foldl=E,u.inject=E,u.VERSION="2.4.1",X&&Y&&(X._=u)}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1])(1)}); \ No newline at end of file +!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;"undefined"!=typeof window?e=window:"undefined"!=typeof global?e=global:"undefined"!=typeof self&&(e=self),e.terra=t()}}(function(){var t;return function e(t,n,r){function o(u,a){if(!n[u]){if(!t[u]){var c="function"==typeof require&&require;if(!a&&c)return c(u,!0);if(i)return i(u,!0);var f=new Error("Cannot find module '"+u+"'");throw f.code="MODULE_NOT_FOUND",f}var s=n[u]={exports:{}};t[u][0].call(s.exports,function(e){var n=t[u][1][e];return o(n?n:e)},s,s.exports,e,t,n,r)}return n[u].exports}for(var i="function"==typeof require&&require,u=0;uthis.maxEnergy&&(this.energy=this.maxEnergy)},t.prototype.isDead=function(){return this.energy<=0},t.prototype.reproduce=function(t){var e=n.filter(t,function(t){return!t.creature});if(e.length){var o=e[n.random(e.length-1)],i=o.coords,u=r.make(this.type),a=function(){return this.energy-=this.initialEnergy,!0}.bind(this),c=this.wait;return{x:i.x,y:i.y,creature:u,successFn:a,failureFn:c}}return!1},t.prototype.move=function(t){var e=this,r=n.filter(t,function(t){return t.creature.sizen*this.reproduceLv&&this.reproduce?e=this.reproduce(t):this.energy>n*this.moveLv&&this.move&&(e=this.move(t));var r=e.creature;return r?(r.successFn=e.successFn||r.wait,r.failureFn=e.failureFn||r.wait,{x:e.x,y:e.y,creature:r}):!1},e.prototype.boundEnergy=function(){},e.prototype.isDead=function(){return!1},e.prototype.queue=function(){},e.prototype.wait=function(){};var o={};return{make:function(t,e){var n=o[t];return n?new n(e):!1},registerCreature:function(e,r){var i=e.type;if("string"==typeof i&&"undefined"==typeof o[i]){o[i]="function"==typeof r?function(){this.energy=this.initialEnergy,r.call(this)}:function(){this.energy=this.initialEnergy};var u=e.color;return("object"!=typeof u||3!==u.length)&&(e.color=[n.random(255),n.random(255),n.random(255)]),o[i].prototype=new t,o[i].prototype.constructor=o[i],n.each(e,function(t,e){o[i].prototype[e]=t}),o[i].prototype.successFn=o[i].wait,o[i].prototype.failureFn=o[i].wait,o[i].prototype.energy=e.initialEnergy,!0}return!1},registerCA:function(t,r){var i=t.type;if("string"==typeof i&&"undefined"==typeof o[i]){o[i]="function"==typeof r?function(){r.call(this)}:function(){};var u=t.color;return("object"!=typeof u||3!==u.length)&&(t.color=[n.random(255),n.random(255),n.random(255)]),o[i].prototype=new e,o[i].prototype.constructor=o[i],n.each(t,function(t,e){o[i].prototype[e]=t}),!0}return!1}}}();e.exports=r},{"./util.js":6}],3:[function(t,e){var n=t("./util.js");e.exports=function(t,e,r){var o=t.getContext("2d");o.clearRect(0,0,t.width,t.height),n.each(e,function(t,e){n.each(t,function(t,n){if(t){var i=t.colorFn?t.colorFn():t.color+","+t.energy/t.maxEnergy;o.fillStyle="rgba("+i+")",t.character?o.fillText(t.character,e*r,n*r+r):o.fillRect(e*r,n*r,r,r)}})})}},{"./util.js":6}],4:[function(t,e){var n=function(t,e,n,r,o){function i(o){var i=document.createElement("canvas"),u=i.getContext("2d");return o=function(){var t=document.createElement("canvas").getContext("2d"),e=window.devicePixelRatio||1,n=t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1;return e/n}(),i.width=t*o,i.height=e*o,i.style.width=t+"px",i.style.height=e+"px",u.setTransform(o,0,0,o,0,0),u.font="bold "+n+"px Arial",r&&(i.id=r),i}t*=n,e*=n;var u=i();return o?o.parentNode.insertBefore(u,o.nextSibling):document.body.appendChild(u),u};e.exports={createCanvasElement:n}},{}],5:[function(t,e){function n(t,e,n,r,o){r=r||10,this.cellSize=r,this.width=t,this.height=e,this.grid=[],this.canvas=u.createCanvasElement(t,e,r,n,o),this.nextFrame=!1}var r=t("./util"),o=t("./creature.js"),i=t("./display.js"),u=t("./dom.js");n.prototype.makeGrid=function(t){for(var e=[],n=typeof t,r=0,i=this.width;i>r;r++){e.push([]);for(var u=0,a=this.height;a>u;u++)e[r].push(o.make("function"===n?t(r,u):"object"===n&&t.length?(t[u]||[])[r]:"string"===n?t:void 0))}return e},n.prototype.makeGridWithDistribution=function(t){for(var e=[],n=0,i=this.width;i>n;n++){e.push([]);for(var u=0,a=this.height;a>u;u++)e[n].push(o.make(r.pickRandomWeighted(t)))}return e},n.prototype.step=function(t){function e(t){if(t){var e=r.assign(new t.constructor,t);return e&&!e.isDead()?e:!1}return!1}function n(t){return r.map(t,e)}function o(t){return{coords:t,creature:h[t.x][t.y]}}function i(t){var e=t.creature;e?(e.failureFn(),e.boundEnergy()):(t.wait(),t.boundEnergy())}function u(t,e,n){if(t){var u=r.map(r.getNeighborCoords(e,n,p-1,y-1,t.actionRadius),o),a=t.queue(u);if(a){var c=l[a.x];c[a.y]||(c[a.y]=[]),c[a.y].push({x:e,y:n,creature:a.creature})}else i(t)}}function a(t,e){r.each(t,function(t,n){u(t,e,n)})}function c(t,e,n){if(t){var o=t.splice(r.random(t.length-1),1)[0],u=o.creature;u.successFn()||(s[o.x][o.y]=!1),u.boundEnergy(),s[e][n]=u,r.each(t,i)}}function f(t,e){r.each(t,function(t,n){c(t,e,n)})}var s,l,p=this.width,y=this.height,h=this.grid;for("number"!=typeof t&&(t=1);t--;)h=s?r.clone(s):this.grid,s=r.map(h,n),l=this.makeGrid(),r.each(s,a),r.each(l,f);return s},n.prototype.draw=function(){i(this.canvas,this.grid,this.cellSize)},n.prototype.animate=function(t,e){function n(){o.grid=o.step(),o.draw(),r++!==t?o.nextFrame=requestAnimationFrame(n):(o.nextFrame=!1,e())}if(!this.nextFrame){var r=0,o=this;o.nextFrame=requestAnimationFrame(n)}},n.prototype.stop=function(){cancelAnimationFrame(this.nextFrame),this.nextFrame=!1},e.exports=n},{"./creature.js":2,"./display.js":3,"./dom.js":4,"./util":6}],6:[function(t,e){t("../bower_components/seedrandom/seedrandom.js")("terra :)",{global:!0});var n=t("../lodash_custom/lodash.custom.min.js")._;n.getNeighborCoords=function(t,e,n,r,o){var i,u,a,c,f=[];("number"!=typeof o||1>o)&&(o=1),i=Math.max(0,t-o),a=Math.max(0,e-o),u=Math.min(t+o,n),c=Math.min(e+o,r);for(var s=i;u>=s;s++)for(var l=a;c>=l;l++)(s!==t||l!==e)&&f.push({x:s,y:l});return f},n.pickRandomWeighted=function(t){var e,r,o=0,i=n.random(100,!0);for(r=0,_len=t.length;_len>r;r++)if(e=t[r],o+=e[1],o>i)return e[0];return!1},e.exports=n},{"../bower_components/seedrandom/seedrandom.js":7,"../lodash_custom/lodash.custom.min.js":8}],7:[function(e,n){!function(t,e,n,r,o,i,u,a,c){function f(t){var e,n=t.length,o=this,i=0,u=o.i=o.j=0,a=o.S=[];for(n||(t=[n++]);r>i;)a[i]=i++;for(i=0;r>i;i++)a[i]=a[u=m&u+t[i%n]+(e=a[i])],a[u]=e;(o.g=function(t){for(var e,n=0,i=o.i,u=o.j,a=o.S;t--;)e=a[i=m&i+1],n=n*r+a[m&(a[i]=a[u=m&u+e])+(a[u]=e)];return o.i=i,o.j=u,n})(r)}function s(t,e){var n,r=[],o=typeof t;if(e&&"object"==o)for(n in t)try{r.push(s(t[n],e-1))}catch(i){}return r.length?r:"string"==o?t:t+"\x00"}function l(t,e){for(var n,r=t+"",o=0;ot;)t=(t+n)*r,e*=r,n=v.g(1);for(;t>=d;)t/=2,e/=2,n>>>=1;return(t+n)/e},m,"global"in i?i.global:this==n)};l(n[c](),e),u&&u.exports?u.exports=v:a&&a.amd&&a(function(){return v})}(this,[],Math,256,6,52,"object"==typeof n&&n,"function"==typeof t&&t,"random")},{}],8:[function(t,e,n){(function(t){(function(){function r(t){return"function"!=typeof t.toString&&"string"==typeof(t+"")}function o(t){t.length=0,A.lengthn?0:n);++rk;k++)r+="n='"+n.h[k]+"';if((!(r&&x[n])&&m.call(t,n))",n.j||(r+="||(!x[n]&&t[n]!==A[n])"),r+="){"+n.g+"}";r+="}"}return(n.b||xe.nonEnumArgs)&&(r+="}"),r+=n.c+";return E",t("d,j,k,m,o,p,q,s,v,A,B,y,I,J,L",e+r+"}")(s,T,ee,ce,D,d,we,b,V.f,ne,H,be,U,re,oe)}function g(t){return"function"==typeof t&&ie.test(t)}function d(t){return t&&"object"==typeof t&&"number"==typeof t.length&&oe.call(t)==z||!1}function m(t){return"function"==typeof t}function v(t){return!(!t||!H[typeof t])}function b(t){return"string"==typeof t||t&&"object"==typeof t&&oe.call(t)==U||!1}function x(t,e,n){var r=[];if(e=u.createCallback(e,n,3),we(t)){n=-1;for(var o=t.length;++narguments.length;if(e=u.createCallback(e,r,4),we(t)){var i=-1,a=t.length;for(o&&(n=t[++i]);++i3&&typeof a[c-2]=='function'){var e=d(a[--c-1],a[c--],2)}else if(c>2&&typeof a[c-1]=='function'){e=a[--c]}"),g:"E[n]=e?e(E[n],t[n]):t[n]"}),Se=h(Z,Fe,{j:!1}),Oe=h(Z,Fe);m(/x/)&&(m=function(t){return"function"==typeof t&&"[object Function]"==oe.call(t)}),u.assign=ke,u.bind=F,u.createCallback=function(t,e,n){var r=typeof t;if(null==t||"function"==r)return s(t,e,n);if("object"!=r)return O(t);var o=_e(t),i=o[0],u=t[i];return 1!=o.length||u!==u||v(u)?function(e){for(var n=o.length,r=!1;n--&&(r=p(e[o[n]],t[o[n]],null,!0)););return r}:function(t){return t=t[i],u===t&&(0!==u||1/u==1/t)}},u.filter=x,u.forEach=j,u.forIn=Se,u.forOwn=Oe,u.keys=_e,u.map=w,u.property=O,u.collect=w,u.each=j,u.extend=ke,u.select=x,u.clone=function(t,e,n,r){return"boolean"!=typeof e&&null!=e&&(r=n,n=e,e=!1),c(t,e,"function"==typeof n&&s(n,r,1))},u.identity=C,u.isArguments=d,u.isArray=we,u.isFunction=m,u.isObject=v,u.isString=b,u.noop=S,u.random=function(t,e,n){var r=null==t,o=null==e;return null==n&&("boolean"==typeof t&&o?(n=t,t=1):o||"boolean"!=typeof e||(n=e,o=!0)),r&&o&&(e=1),t=+t||0,o?(e=t,t=0):e=+e||0,n||t%1||e%1?(n=me(),de(t+n*(e-t+parseFloat("1e-"+((n+"").length-1))),e)):t+ue(me()*(e-t+1))},u.reduce=E,u.some=_,u.any=_,u.foldl=E,u.inject=E,u.VERSION="2.4.1",X&&Y&&(X._=u)}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1])(1)}); \ No newline at end of file