diff options
-rw-r--r-- | js/rotjs/index.html | 9 | ||||
-rw-r--r-- | js/rotjs/src/game.js | 195 | ||||
-rw-r--r-- | js/rotjs/src/rot.min.js | 143 |
3 files changed, 347 insertions, 0 deletions
diff --git a/js/rotjs/index.html b/js/rotjs/index.html new file mode 100644 index 0000000..978c648 --- /dev/null +++ b/js/rotjs/index.html @@ -0,0 +1,9 @@ +<!DOCTYPE html> +<html> + <head> + <title>rot.js tutorial game</title> + <script src="/src/rot.min.js"></script> + <script src="/src/game.js"></script> + </head> + <body onload="Game.init()"></body> +</html> diff --git a/js/rotjs/src/game.js b/js/rotjs/src/game.js new file mode 100644 index 0000000..41466ba --- /dev/null +++ b/js/rotjs/src/game.js @@ -0,0 +1,195 @@ +let Game = { + display: null, + map: {}, + engine: null, + player: null, + pedro: null, + ananas: null, + + init: function () { + this.display = new ROT.Display({ spacing: 1.1 }); + document.body.appendChild(this.display.getContainer()); + + this._generateMap(); + + let scheduler = new ROT.Scheduler.Simple(); + scheduler.add(this.player, true); + scheduler.add(this.pedro, true); + + this.engine = new ROT.Engine(scheduler); + this.engine.start(); + }, + + _generateMap: function () { + let digger = new ROT.Map.Digger(); + let freeCells = []; + + let digCallback = function (x, y, value) { + if (value) { + return; + } + + let key = x + "," + y; + this.map[key] = "."; + freeCells.push(key); + }; + digger.create(digCallback.bind(this)); + + this._generateBoxes(freeCells); + this._drawWholeMap(); + + this.player = this._createBeing(Player, freeCells); + this.pedro = this._createBeing(Pedro, freeCells); + }, + + _createBeing: function (what, freeCells) { + let index = Math.floor(ROT.RNG.getUniform() * freeCells.length); + let key = freeCells.splice(index, 1)[0]; + let parts = key.split(","); + let x = parseInt(parts[0]); + let y = parseInt(parts[1]); + return new what(x, y); + }, + + _generateBoxes: function (freeCells) { + for (let i = 0; i < 10; i++) { + let index = Math.floor(ROT.RNG.getUniform() * freeCells.length); + let key = freeCells.splice(index, 1)[0]; + this.map[key] = "*"; + if (!i) { + this.ananas = key; + } /* first box contains an ananas */ + } + }, + + _drawWholeMap: function () { + for (let key in this.map) { + let parts = key.split(","); + let x = parseInt(parts[0]); + let y = parseInt(parts[1]); + this.display.draw(x, y, this.map[key]); + } + }, +}; + +let Player = function (x, y) { + this._x = x; + this._y = y; + this._draw(); +}; + +Player.prototype.getSpeed = function () { + return 100; +}; +Player.prototype.getX = function () { + return this._x; +}; +Player.prototype.getY = function () { + return this._y; +}; + +Player.prototype.act = function () { + Game.engine.lock(); + window.addEventListener("keydown", this); +}; + +Player.prototype.handleEvent = function (e) { + let code = e.keyCode; + if (code == 13 || code == 32) { + this._checkBox(); + return; + } + + let keyMap = {}; + keyMap[38] = 0; + keyMap[33] = 1; + keyMap[39] = 2; + keyMap[34] = 3; + keyMap[40] = 4; + keyMap[35] = 5; + keyMap[37] = 6; + keyMap[36] = 7; + + /* one of numpad directions? */ + if (!(code in keyMap)) { + return; + } + + /* is there a free space? */ + let dir = ROT.DIRS[8][keyMap[code]]; + let newX = this._x + dir[0]; + let newY = this._y + dir[1]; + let newKey = newX + "," + newY; + if (!(newKey in Game.map)) { + return; + } + + Game.display.draw(this._x, this._y, Game.map[this._x + "," + this._y]); + this._x = newX; + this._y = newY; + this._draw(); + window.removeEventListener("keydown", this); + Game.engine.unlock(); +}; + +Player.prototype._draw = function () { + Game.display.draw(this._x, this._y, "@", "#ff0"); +}; + +Player.prototype._checkBox = function () { + let key = this._x + "," + this._y; + if (Game.map[key] != "*") { + alert("There is no box here!"); + } else if (key == Game.ananas) { + alert("Hooray! You found an ananas and won this game."); + Game.engine.lock(); + window.removeEventListener("keydown", this); + } else { + alert("This box is empty :-("); + } +}; + +let Pedro = function (x, y) { + this._x = x; + this._y = y; + this._draw(); +}; + +Pedro.prototype.getSpeed = function () { + return 100; +}; + +Pedro.prototype.act = function () { + let x = Game.player.getX(); + let y = Game.player.getY(); + + let passableCallback = function (x, y) { + return x + "," + y in Game.map; + }; + let astar = new ROT.Path.AStar(x, y, passableCallback, { topology: 4 }); + + let path = []; + let pathCallback = function (x, y) { + path.push([x, y]); + }; + astar.compute(this._x, this._y, pathCallback); + + path.shift(); + if (path.length == 1) { + Game.engine.lock(); + alert("Game over - you were captured by Pedro!"); + } else { + x = path[0][0]; + y = path[0][1]; + Game.display.draw(this._x, this._y, Game.map[this._x + "," + this._y]); + this._x = x; + this._y = y; + this._draw(); + } +}; + +Pedro.prototype._draw = function () { + Game.display.draw(this._x, this._y, "P", "red"); +}; + +Game.init(); diff --git a/js/rotjs/src/rot.min.js b/js/rotjs/src/rot.min.js new file mode 100644 index 0000000..e04cc5c --- /dev/null +++ b/js/rotjs/src/rot.min.js @@ -0,0 +1,143 @@ +var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(g,n,q){g!=Array.prototype&&g!=Object.prototype&&(g[n]=q.value)};$jscomp.getGlobal=function(g){return"undefined"!=typeof window&&window===g?g:"undefined"!=typeof global&&null!=global?global:g};$jscomp.global=$jscomp.getGlobal(this); +$jscomp.polyfill=function(g,n,q,t){if(n){q=$jscomp.global;g=g.split(".");for(t=0;t<g.length-1;t++){var v=g[t];v in q||(q[v]={});q=q[v]}g=g[g.length-1];t=q[g];n=n(t);n!=t&&null!=n&&$jscomp.defineProperty(q,g,{configurable:!0,writable:!0,value:n})}};$jscomp.polyfill("Array.prototype.fill",function(g){return g?g:function(g,q,t){var n=this.length||0;0>q&&(q=Math.max(0,n+q));if(null==t||t>n)t=n;t=Number(t);0>t&&(t=Math.max(0,n+t));for(q=Number(q||0);q<t;q++)this[q]=g;return this}},"es6","es3"); +$jscomp.checkStringArgs=function(g,n,q){if(null==g)throw new TypeError("The 'this' value for String.prototype."+q+" must not be null or undefined");if(n instanceof RegExp)throw new TypeError("First argument to String.prototype."+q+" must not be a regular expression");return g+""}; +$jscomp.polyfill("String.prototype.repeat",function(g){return g?g:function(g){var n=$jscomp.checkStringArgs(this,null,"repeat");if(0>g||1342177279<g)throw new RangeError("Invalid count value");g|=0;for(var t="";g;)if(g&1&&(t+=n),g>>>=1)n+=n;return t}},"es6","es3");$jscomp.stringPadding=function(g,n){g=void 0!==g?String(g):" ";return 0<n&&g?g.repeat(Math.ceil(n/g.length)).substring(0,n):""}; +$jscomp.polyfill("String.prototype.padStart",function(g){return g?g:function(g,q){var n=$jscomp.checkStringArgs(this,null,"padStart");return $jscomp.stringPadding(q,g-n.length)+n}},"es8","es3");$jscomp.owns=function(g,n){return Object.prototype.hasOwnProperty.call(g,n)};$jscomp.assign="function"==typeof Object.assign?Object.assign:function(g,n){for(var q=1;q<arguments.length;q++){var t=arguments[q];if(t)for(var v in t)$jscomp.owns(t,v)&&(g[v]=t[v])}return g}; +$jscomp.polyfill("Object.assign",function(g){return g||$jscomp.assign},"es6","es3");$jscomp.SYMBOL_PREFIX="jscomp_symbol_";$jscomp.initSymbol=function(){$jscomp.initSymbol=function(){};$jscomp.global.Symbol||($jscomp.global.Symbol=$jscomp.Symbol)};$jscomp.Symbol=function(){var g=0;return function(n){return $jscomp.SYMBOL_PREFIX+(n||"")+g++}}(); +$jscomp.initSymbolIterator=function(){$jscomp.initSymbol();var g=$jscomp.global.Symbol.iterator;g||(g=$jscomp.global.Symbol.iterator=$jscomp.global.Symbol("iterator"));"function"!=typeof Array.prototype[g]&&$jscomp.defineProperty(Array.prototype,g,{configurable:!0,writable:!0,value:function(){return $jscomp.arrayIterator(this)}});$jscomp.initSymbolIterator=function(){}}; +$jscomp.initSymbolAsyncIterator=function(){$jscomp.initSymbol();var g=$jscomp.global.Symbol.asyncIterator;g||(g=$jscomp.global.Symbol.asyncIterator=$jscomp.global.Symbol("asyncIterator"));$jscomp.initSymbolAsyncIterator=function(){}};$jscomp.arrayIterator=function(g){var n=0;return $jscomp.iteratorPrototype(function(){return n<g.length?{done:!1,value:g[n++]}:{done:!0}})}; +$jscomp.iteratorPrototype=function(g){$jscomp.initSymbolIterator();g={next:g};g[$jscomp.global.Symbol.iterator]=function(){return this};return g};$jscomp.iteratorFromArray=function(g,n){$jscomp.initSymbolIterator();g instanceof String&&(g+="");var q=0,t={next:function(){if(q<g.length){var v=q++;return{value:n(v,g[v]),done:!1}}t.next=function(){return{done:!0,value:void 0}};return t.next()}};t[Symbol.iterator]=function(){return t};return t}; +$jscomp.polyfill("Array.prototype.keys",function(g){return g?g:function(){return $jscomp.iteratorFromArray(this,function(g){return g})}},"es6","es3");$jscomp.findInternal=function(g,n,q){g instanceof String&&(g=String(g));for(var t=g.length,v=0;v<t;v++){var E=g[v];if(n.call(q,E,v,g))return{i:v,v:E}}return{i:-1,v:void 0}};$jscomp.polyfill("Array.prototype.find",function(g){return g?g:function(g,q){return $jscomp.findInternal(this,g,q).v}},"es6","es3"); +function _assertThisInitialized(g){if(void 0===g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return g}function _inheritsLoose(g,n){g.prototype=Object.create(n.prototype);g.prototype.constructor=g;g.__proto__=n} +(function(g,n){"object"===typeof exports&&"undefined"!==typeof module?n(exports):"function"===typeof define&&define.amd?define(["exports"],n):n(g.ROT={})})(this,function(g){function n(d,c){return(d%c+c)%c}function q(d,c,b){void 0===c&&(c=0);void 0===b&&(b=1);return d<c?c:d>b?b:d}function t(d){return d.charAt(0).toUpperCase()+d.substring(1)}function v(d){for(var c=arguments.length,b=Array(1<c?c-1:0),a=1;a<c;a++)b[a-1]=arguments[a];var e=v.map;return d.replace(/%(?:([a-z]+)|(?:{([^}]+)}))/gi,function(a, +l,k,h){if("%"==d.charAt(h-1))return a.substring(1);if(!b.length)return a;k=(l||k).split(",");l=k.shift()||"";h=e[l.toLowerCase()];if(!h)return a;a=b.shift();a=a[h].apply(a,k);l=l.charAt(0);l!=l.toLowerCase()&&(a=t(a));return a})}function E(d){var c;if(d in M)var b=M[d];else{if("#"==d.charAt(0))if(b=(d.match(/[0-9a-f]/gi)||[]).map(function(a){return parseInt(a,16)}),3==b.length)b=b.map(function(a){return 17*a});else for(c=0;3>c;c++)b[c+1]+=16*b[c],b.splice(c,1);else b=(c=d.match(/rgb\(([0-9, ]+)\)/i))? +c[1].split(/\s*,\s*/).map(function(a){return parseInt(a)}):[0,0,0];M[d]=b}return b.slice()}function W(d){for(var c=arguments.length,b=Array(1<c?c-1:0),a=1;a<c;a++)b[a-1]=arguments[a];for(c=0;3>c;c++)for(a=0;a<b.length;a++)d[c]+=b[a][c];return d}function X(d,c,b){void 0===b&&(b=.5);for(var a=d.slice(),e=0;3>e;e++)a[e]=Math.round(a[e]+b*(c[e]-d[e]));return a}function Y(d,c,b){void 0===b&&(b=.5);d=N(d);c=N(c);for(var a=0;3>a;a++)d[a]+=b*(c[a]-d[a]);return Z(d)}function N(d){var c=d[0]/255,b=d[1]/255; +d=d[2]/255;var a=Math.max(c,b,d),e=Math.min(c,b,d),f=0,l=(a+e)/2;if(a==e)e=0;else{var k=a-e;e=.5<l?k/(2-a-e):k/(a+e);switch(a){case c:f=(b-d)/k+(b<d?6:0);break;case b:f=(d-c)/k+2;break;case d:f=(c-b)/k+4}f/=6}return[f,e,l]}function O(d,c,b){0>b&&(b+=1);1<b&&--b;return b<1/6?d+6*(c-d)*b:.5>b?c:b<2/3?d+(c-d)*(2/3-b)*6:d}function Z(d){var c=d[2];if(0==d[1])return c=Math.round(255*c),[c,c,c];var b=d[1];b=.5>c?c*(1+b):c+b-c*b;var a=2*c-b;c=O(a,b,d[0]+1/3);var e=O(a,b,d[0]);d=O(a,b,d[0]-1/3);return[Math.round(255* +c),Math.round(255*e),Math.round(255*d)]}function ka(d,c,b){var a=d.createShader(d.VERTEX_SHADER);d.shaderSource(a,c);d.compileShader(a);if(!d.getShaderParameter(a,d.COMPILE_STATUS))throw Error(d.getShaderInfoLog(a)||"");c=d.createShader(d.FRAGMENT_SHADER);d.shaderSource(c,b);d.compileShader(c);if(!d.getShaderParameter(c,d.COMPILE_STATUS))throw Error(d.getShaderInfoLog(c)||"");b=d.createProgram();d.attachShader(b,a);d.attachShader(b,c);d.linkProgram(b);if(!d.getProgramParameter(b,d.LINK_STATUS))throw Error(d.getProgramInfoLog(b)|| +"");return b}function la(d){var c=new Float32Array([0,0,1,0,0,1,1,1]),b=d.createBuffer();d.bindBuffer(d.ARRAY_BUFFER,b);d.bufferData(d.ARRAY_BUFFER,c,d.STATIC_DRAW);d.enableVertexAttribArray(0);d.vertexAttribPointer(0,2,d.FLOAT,!1,0,0)}function J(d){if(!(d in P)){if("transparent"==d)var c=[0,0,0,0];else if(-1<d.indexOf("rgba")){c=(d.match(/[\d.]+/g)||[]).map(Number);for(var b=0;3>b;b++)c[b]/=255}else c=E(d).map(function(a){return a/255}),c.push(1);P[d]=c}return P[d]}function Q(d){d=E(d);return 36* +Math.floor(.0234375*d[0])+6*Math.floor(.0234375*d[1])+1*Math.floor(.0234375*d[2])+16}function R(d,c){var b=[],a=0;d.replace(ma,function(e,l,k,h){var f=d.substring(a,h);f.length&&b.push({type:0,value:f});b.push({type:"c"==l?2:3,value:k.trim()});a=h+e.length;return""});var e=d.substring(a);e.length&&b.push({type:0,value:e});return na(b,c)}function na(d,c){c||(c=Infinity);for(var b=0,a=0,e=-1;b<d.length;){var f=d[b];1==f.type&&(a=0,e=-1);if(0!=f.type)b++;else{for(;0==a&&" "==f.value.charAt(0);)f.value= +f.value.substring(1);var l=f.value.indexOf("\n");if(-1!=l){f.value=K(d,b,l,!0);for(l=f.value.split("");l.length&&" "==l[l.length-1];)l.pop();f.value=l.join("")}if(f.value.length){if(a+f.value.length>c){for(l=-1;;){var k=f.value.indexOf(" ",l+1);if(-1==k)break;if(a+k>c)break;l=k}-1!=l?f.value=K(d,b,l,!0):-1!=e?(b=d[e],f=b.value.lastIndexOf(" "),b.value=K(d,e,f,!0),b=e):f.value=K(d,b,c-a,!1)}else a+=f.value.length,-1!=f.value.indexOf(" ")&&(e=b);b++}else d.splice(b,1)}}d.push({type:1});c=null;for(a= +0;a<d.length;a++)switch(e=d[a],e.type){case 0:c=e;break;case 1:if(c){for(e=c.value.split("");e.length&&" "==e[e.length-1];)e.pop();c.value=e.join("")}c=null}d.pop();return d}function K(d,c,b,a){a={type:0,value:d[c].value.substring(b+(a?1:0))};d.splice(c+1,0,{type:1},a);return d[c].value.substring(0,b)}function aa(d,c,b){b[c[d+1]]=b[d];c[b[d]]=c[d+1];b[d]=d+1;c[d+1]=d}function ba(d,c,b){b[c[d]]=b[d];c[b[d]]=c[d];b[d]=d;c[d]=d}var r=(new (function(){function d(){this._c=this._s2=this._s1=this._s0=this._seed= +0}var c=d.prototype;c.getSeed=function(){return this._seed};c.setSeed=function(b){this._seed=b=1>b?1/b:b;this._s0=2.3283064365386963E-10*(b>>>0);b=69069*b+1>>>0;this._s1=2.3283064365386963E-10*b;this._s2=2.3283064365386963E-10*(69069*b+1>>>0);this._c=1;return this};c.getUniform=function(){var b=2091639*this._s0+2.3283064365386963E-10*this._c;this._s0=this._s1;this._s1=this._s2;this._c=b|0;return this._s2=b-this._c};c.getUniformInt=function(b,a){var e=Math.max(b,a);b=Math.min(b,a);return Math.floor(this.getUniform()* +(e-b+1))+b};c.getNormal=function(b,a){void 0===b&&(b=0);void 0===a&&(a=1);do{var e=2*this.getUniform()-1;var f=2*this.getUniform()-1;f=e*e+f*f}while(1<f||0==f);return b+e*Math.sqrt(-2*Math.log(f)/f)*a};c.getPercentage=function(){return 1+Math.floor(100*this.getUniform())};c.getItem=function(b){return b.length?b[Math.floor(this.getUniform()*b.length)]:null};c.shuffle=function(b){var a=[];for(b=b.slice();b.length;){var e=b.indexOf(this.getItem(b));a.push(b.splice(e,1)[0])}return a};c.getWeightedValue= +function(b){var a=0;for(f in b)a+=b[f];a*=this.getUniform();var e;var f=0;for(e in b)if(f+=b[e],a<f)break;return e};c.getState=function(){return[this._s0,this._s1,this._s2,this._c]};c.setState=function(b){this._s0=b[0];this._s1=b[1];this._s2=b[2];this._c=b[3];return this};c.clone=function(){return(new d).setState(this.getState())};return d}())).setSeed(Date.now()),G=function(){function d(){}var c=d.prototype;c.getContainer=function(){return null};c.setOptions=function(b){this._options=b};return d}(), +S=function(d){function c(){var a=d.call(this)||this;a._ctx=document.createElement("canvas").getContext("2d");return a}_inheritsLoose(c,d);var b=c.prototype;b.schedule=function(a){requestAnimationFrame(a)};b.getContainer=function(){return this._ctx.canvas};b.setOptions=function(a){d.prototype.setOptions.call(this,a);a=(a.fontStyle?a.fontStyle+" ":"")+" "+a.fontSize+"px "+a.fontFamily;this._ctx.font=a;this._updateSize();this._ctx.font=a;this._ctx.textAlign="center";this._ctx.textBaseline="middle"}; +b.clear=function(){this._ctx.fillStyle=this._options.bg;this._ctx.fillRect(0,0,this._ctx.canvas.width,this._ctx.canvas.height)};b.eventToPosition=function(a,e){var f=this._ctx.canvas,b=f.getBoundingClientRect();a-=b.left;e-=b.top;a*=f.width/b.width;e*=f.height/b.height;return 0>a||0>e||a>=f.width||e>=f.height?[-1,-1]:this._normalizedEventToPosition(a,e)};return c}(G);v.map={s:"toString"};var oa=Object.freeze({mod:n,clamp:q,capitalize:t,format:v}),ca=function(d){function c(){var a=d.call(this)||this; +a._spacingX=0;a._spacingY=0;a._hexSize=0;return a}_inheritsLoose(c,d);var b=c.prototype;b.draw=function(a,e){var f=a[2],b=a[3],k=a[4];a=[(a[0]+1)*this._spacingX,a[1]*this._spacingY+this._hexSize];this._options.transpose&&a.reverse();e&&(this._ctx.fillStyle=k,this._fill(a[0],a[1]));if(f)for(this._ctx.fillStyle=b,e=[].concat(f),f=0;f<e.length;f++)this._ctx.fillText(e[f],a[0],Math.ceil(a[1]))};b.computeSize=function(a,e){this._options.transpose&&(a+=e,e=a-e,a-=e);return[Math.floor(a/this._spacingX)- +1,Math.floor((e-2*this._hexSize)/this._spacingY+1)]};b.computeFontSize=function(a,e){this._options.transpose&&(a+=e,e=a-e,a-=e);a=Math.min(2*a/((this._options.width+1)*Math.sqrt(3))-1,e/(2+1.5*(this._options.height-1)));e=this._ctx.font;this._ctx.font="100px "+this._options.fontFamily;var f=Math.ceil(this._ctx.measureText("W").width);this._ctx.font=e;a=Math.floor(a)+1;return Math.ceil(2*a/(this._options.spacing*(1+f/100/Math.sqrt(3))))-1};b._normalizedEventToPosition=function(a,e){if(this._options.transpose){a+= +e;e=a-e;a-=e;var f=this._ctx.canvas.width}else f=this._ctx.canvas.height;e=Math.floor(e/(f/this._options.height));n(e,2)?(a-=this._spacingX,a=1+2*Math.floor(a/(2*this._spacingX))):a=2*Math.floor(a/(2*this._spacingX));return[a,e]};b._fill=function(a,e){var f=this._hexSize,b=this._options.border,k=this._ctx;k.beginPath();this._options.transpose?(k.moveTo(a-f+b,e),k.lineTo(a-f/2+b,e+this._spacingX-b),k.lineTo(a+f/2-b,e+this._spacingX-b),k.lineTo(a+f-b,e),k.lineTo(a+f/2-b,e-this._spacingX+b),k.lineTo(a- +f/2+b,e-this._spacingX+b),k.lineTo(a-f+b,e)):(k.moveTo(a,e-f+b),k.lineTo(a+this._spacingX-b,e-f/2+b),k.lineTo(a+this._spacingX-b,e+f/2-b),k.lineTo(a,e+f-b),k.lineTo(a-this._spacingX+b,e+f/2-b),k.lineTo(a-this._spacingX+b,e-f/2+b),k.lineTo(a,e-f+b));k.fill()};b._updateSize=function(){var a=this._options,e=Math.ceil(this._ctx.measureText("W").width);this._hexSize=Math.floor(a.spacing*(a.fontSize+e/Math.sqrt(3))/2);this._spacingX=this._hexSize*Math.sqrt(3)/2;this._spacingY=1.5*this._hexSize;if(a.transpose){e= +"height";var f="width"}else e="width",f="height";this._ctx.canvas[e]=Math.ceil((a.width+1)*this._spacingX);this._ctx.canvas[f]=Math.ceil((a.height-1)*this._spacingY+2*this._hexSize)};return c}(S),da=function(){var d=function(c){function b(){var a=c.call(this)||this;a._spacingX=0;a._spacingY=0;a._canvasCache={};return a}_inheritsLoose(b,c);var a=b.prototype;a.setOptions=function(a){c.prototype.setOptions.call(this,a);this._canvasCache={}};a.draw=function(a,f){b.cache?this._drawWithCache(a):this._drawNoCache(a, +f)};a._drawWithCache=function(a){var e=a[0],b=a[1],k=a[2],h=a[3],c=a[4];a=""+k+h+c;if(a in this._canvasCache)var d=this._canvasCache[a];else{var g=this._options.border;d=document.createElement("canvas");var y=d.getContext("2d");d.width=this._spacingX;d.height=this._spacingY;y.fillStyle=c;y.fillRect(g,g,d.width-g,d.height-g);if(k)for(y.fillStyle=h,y.font=this._ctx.font,y.textAlign="center",y.textBaseline="middle",k=[].concat(k),h=0;h<k.length;h++)y.fillText(k[h],this._spacingX/2,Math.ceil(this._spacingY/ +2));this._canvasCache[a]=d}this._ctx.drawImage(d,e*this._spacingX,b*this._spacingY)};a._drawNoCache=function(a,f){var e=a[0],b=a[1],h=a[2],c=a[3];a=a[4];f&&(f=this._options.border,this._ctx.fillStyle=a,this._ctx.fillRect(e*this._spacingX+f,b*this._spacingY+f,this._spacingX-f,this._spacingY-f));if(h)for(this._ctx.fillStyle=c,h=[].concat(h),c=0;c<h.length;c++)this._ctx.fillText(h[c],(e+.5)*this._spacingX,Math.ceil((b+.5)*this._spacingY))};a.computeSize=function(a,f){return[Math.floor(a/this._spacingX), +Math.floor(f/this._spacingY)]};a.computeFontSize=function(a,f){a=Math.floor(a/this._options.width);f=Math.floor(f/this._options.height);var e=this._ctx.font;this._ctx.font="100px "+this._options.fontFamily;var b=Math.ceil(this._ctx.measureText("W").width);this._ctx.font=e;a=b/100*f/a;1<a&&(f=Math.floor(f/a));return Math.floor(f/this._options.spacing)};a._normalizedEventToPosition=function(a,f){return[Math.floor(a/this._spacingX),Math.floor(f/this._spacingY)]};a._updateSize=function(){var a=this._options, +f=Math.ceil(this._ctx.measureText("W").width);this._spacingX=Math.ceil(a.spacing*f);this._spacingY=Math.ceil(a.spacing*a.fontSize);a.forceSquareRatio&&(this._spacingX=this._spacingY=Math.max(this._spacingX,this._spacingY));this._ctx.canvas.width=a.width*this._spacingX;this._ctx.canvas.height=a.height*this._spacingY};return b}(S);d.cache=!1;return d}(),ea=function(d){function c(){var a=d.call(this)||this;a._colorCanvas=document.createElement("canvas");return a}_inheritsLoose(c,d);var b=c.prototype; +b.draw=function(a,e){var f=a[0],b=a[1],k=a[2],h=a[3],c=a[4];a=this._options.tileWidth;var d=this._options.tileHeight;e&&(this._options.tileColorize?this._ctx.clearRect(f*a,b*d,a,d):(this._ctx.fillStyle=c,this._ctx.fillRect(f*a,b*d,a,d)));if(k)for(e=[].concat(k),h=[].concat(h),c=[].concat(c),k=0;k<e.length;k++){var g=this._options.tileMap[e[k]];if(!g)throw Error('Char "'+e[k]+'" not found in tileMap');if(this._options.tileColorize){var y=this._colorCanvas,u=y.getContext("2d");u.globalCompositeOperation= +"source-over";u.clearRect(0,0,a,d);var r=h[k],n=c[k];u.drawImage(this._options.tileSet,g[0],g[1],a,d,0,0,a,d);"transparent"!=r&&(u.fillStyle=r,u.globalCompositeOperation="source-atop",u.fillRect(0,0,a,d));"transparent"!=n&&(u.fillStyle=n,u.globalCompositeOperation="destination-over",u.fillRect(0,0,a,d));this._ctx.drawImage(y,f*a,b*d,a,d)}else this._ctx.drawImage(this._options.tileSet,g[0],g[1],a,d,f*a,b*d,a,d)}};b.computeSize=function(a,e){return[Math.floor(a/this._options.tileWidth),Math.floor(e/ +this._options.tileHeight)]};b.computeFontSize=function(){throw Error("Tile backend does not understand font size");};b._normalizedEventToPosition=function(a,e){return[Math.floor(a/this._options.tileWidth),Math.floor(e/this._options.tileHeight)]};b._updateSize=function(){var a=this._options;this._ctx.canvas.width=a.width*a.tileWidth;this._ctx.canvas.height=a.height*a.tileHeight;this._colorCanvas.width=a.tileWidth;this._colorCanvas.height=a.tileHeight};return c}(S),M={black:[0,0,0],navy:[0,0,128],darkblue:[0, +0,139],mediumblue:[0,0,205],blue:[0,0,255],darkgreen:[0,100,0],green:[0,128,0],teal:[0,128,128],darkcyan:[0,139,139],deepskyblue:[0,191,255],darkturquoise:[0,206,209],mediumspringgreen:[0,250,154],lime:[0,255,0],springgreen:[0,255,127],aqua:[0,255,255],cyan:[0,255,255],midnightblue:[25,25,112],dodgerblue:[30,144,255],forestgreen:[34,139,34],seagreen:[46,139,87],darkslategray:[47,79,79],darkslategrey:[47,79,79],limegreen:[50,205,50],mediumseagreen:[60,179,113],turquoise:[64,224,208],royalblue:[65, +105,225],steelblue:[70,130,180],darkslateblue:[72,61,139],mediumturquoise:[72,209,204],indigo:[75,0,130],darkolivegreen:[85,107,47],cadetblue:[95,158,160],cornflowerblue:[100,149,237],mediumaquamarine:[102,205,170],dimgray:[105,105,105],dimgrey:[105,105,105],slateblue:[106,90,205],olivedrab:[107,142,35],slategray:[112,128,144],slategrey:[112,128,144],lightslategray:[119,136,153],lightslategrey:[119,136,153],mediumslateblue:[123,104,238],lawngreen:[124,252,0],chartreuse:[127,255,0],aquamarine:[127, +255,212],maroon:[128,0,0],purple:[128,0,128],olive:[128,128,0],gray:[128,128,128],grey:[128,128,128],skyblue:[135,206,235],lightskyblue:[135,206,250],blueviolet:[138,43,226],darkred:[139,0,0],darkmagenta:[139,0,139],saddlebrown:[139,69,19],darkseagreen:[143,188,143],lightgreen:[144,238,144],mediumpurple:[147,112,216],darkviolet:[148,0,211],palegreen:[152,251,152],darkorchid:[153,50,204],yellowgreen:[154,205,50],sienna:[160,82,45],brown:[165,42,42],darkgray:[169,169,169],darkgrey:[169,169,169],lightblue:[173, +216,230],greenyellow:[173,255,47],paleturquoise:[175,238,238],lightsteelblue:[176,196,222],powderblue:[176,224,230],firebrick:[178,34,34],darkgoldenrod:[184,134,11],mediumorchid:[186,85,211],rosybrown:[188,143,143],darkkhaki:[189,183,107],silver:[192,192,192],mediumvioletred:[199,21,133],indianred:[205,92,92],peru:[205,133,63],chocolate:[210,105,30],tan:[210,180,140],lightgray:[211,211,211],lightgrey:[211,211,211],palevioletred:[216,112,147],thistle:[216,191,216],orchid:[218,112,214],goldenrod:[218, +165,32],crimson:[220,20,60],gainsboro:[220,220,220],plum:[221,160,221],burlywood:[222,184,135],lightcyan:[224,255,255],lavender:[230,230,250],darksalmon:[233,150,122],violet:[238,130,238],palegoldenrod:[238,232,170],lightcoral:[240,128,128],khaki:[240,230,140],aliceblue:[240,248,255],honeydew:[240,255,240],azure:[240,255,255],sandybrown:[244,164,96],wheat:[245,222,179],beige:[245,245,220],whitesmoke:[245,245,245],mintcream:[245,255,250],ghostwhite:[248,248,255],salmon:[250,128,114],antiquewhite:[250, +235,215],linen:[250,240,230],lightgoldenrodyellow:[250,250,210],oldlace:[253,245,230],red:[255,0,0],fuchsia:[255,0,255],magenta:[255,0,255],deeppink:[255,20,147],orangered:[255,69,0],tomato:[255,99,71],hotpink:[255,105,180],coral:[255,127,80],darkorange:[255,140,0],lightsalmon:[255,160,122],orange:[255,165,0],lightpink:[255,182,193],pink:[255,192,203],gold:[255,215,0],peachpuff:[255,218,185],navajowhite:[255,222,173],moccasin:[255,228,181],bisque:[255,228,196],mistyrose:[255,228,225],blanchedalmond:[255, +235,205],papayawhip:[255,239,213],lavenderblush:[255,240,245],seashell:[255,245,238],cornsilk:[255,248,220],lemonchiffon:[255,250,205],floralwhite:[255,250,240],snow:[255,250,250],yellow:[255,255,0],lightyellow:[255,255,224],ivory:[255,255,240],white:[255,255,255]},pa=Object.freeze({fromString:E,add:function(d){for(var c=d.slice(),b=arguments.length,a=Array(1<b?b-1:0),e=1;e<b;e++)a[e-1]=arguments[e];for(b=0;3>b;b++)for(e=0;e<a.length;e++)c[b]+=a[e][b];return c},add_:W,multiply:function(d){for(var c= +d.slice(),b=arguments.length,a=Array(1<b?b-1:0),e=1;e<b;e++)a[e-1]=arguments[e];for(b=0;3>b;b++){for(e=0;e<a.length;e++)c[b]*=a[e][b]/255;c[b]=Math.round(c[b])}return c},multiply_:function(d){for(var c=arguments.length,b=Array(1<c?c-1:0),a=1;a<c;a++)b[a-1]=arguments[a];for(c=0;3>c;c++){for(a=0;a<b.length;a++)d[c]*=b[a][c]/255;d[c]=Math.round(d[c])}return d},interpolate:X,lerp:X,interpolateHSL:Y,lerpHSL:Y,randomize:function(d,c){c instanceof Array||(c=Math.round(r.getNormal(0,c)));d=d.slice();for(var b= +0;3>b;b++)d[b]+=c instanceof Array?Math.round(r.getNormal(0,c[b])):c;return d},rgb2hsl:N,hsl2rgb:Z,toRGB:function(d){return"rgb("+d.map(function(c){return q(c,0,255)}).join(",")+")"},toHex:function(d){return"#"+d.map(function(c){return q(c,0,255).toString(16).padStart(2,"0")}).join("")}}),fa=function(d){function c(){var a=d.call(this)||this;a._uniforms={};try{a._gl=a._initWebGL()}catch(e){alert(e.message)}return a}_inheritsLoose(c,d);c.isSupported=function(){return!!document.createElement("canvas").getContext("webgl2", +{preserveDrawingBuffer:!0})};var b=c.prototype;b.schedule=function(a){requestAnimationFrame(a)};b.getContainer=function(){return this._gl.canvas};b.setOptions=function(a){var e=this;d.prototype.setOptions.call(this,a);this._updateSize();var f=this._options.tileSet;f&&"complete"in f&&!f.complete?f.addEventListener("load",function(){return e._updateTexture(f)}):this._updateTexture(f)};b.draw=function(a,e){var f=this._gl,b=this._options,k=a[0],h=a[1],c=a[2],d=a[3];a=a[4];f.scissor(k*b.tileWidth,f.canvas.height- +(h+1)*b.tileHeight,b.tileWidth,b.tileHeight);e&&(b.tileColorize?f.clearColor(0,0,0,0):f.clearColor.apply(f,J(a)),f.clear(f.COLOR_BUFFER_BIT));if(c)for(e=[].concat(c),c=[].concat(a),d=[].concat(d),f.uniform2fv(this._uniforms.targetPosRel,[k,h]),k=0;k<e.length;k++){h=this._options.tileMap[e[k]];if(!h)throw Error('Char "'+e[k]+'" not found in tileMap');f.uniform1f(this._uniforms.colorize,b.tileColorize?1:0);f.uniform2fv(this._uniforms.tilesetPosAbs,h);b.tileColorize&&(f.uniform4fv(this._uniforms.tint, +J(d[k])),f.uniform4fv(this._uniforms.bg,J(c[k])));f.drawArrays(f.TRIANGLE_STRIP,0,4)}};b.clear=function(){var a=this._gl;a.clearColor.apply(a,J(this._options.bg));a.scissor(0,0,a.canvas.width,a.canvas.height);a.clear(a.COLOR_BUFFER_BIT)};b.computeSize=function(a,e){return[Math.floor(a/this._options.tileWidth),Math.floor(e/this._options.tileHeight)]};b.computeFontSize=function(){throw Error("Tile backend does not understand font size");};b.eventToPosition=function(a,e){var f=this._gl.canvas,b=f.getBoundingClientRect(); +a-=b.left;e-=b.top;a*=f.width/b.width;e*=f.height/b.height;return 0>a||0>e||a>=f.width||e>=f.height?[-1,-1]:this._normalizedEventToPosition(a,e)};b._initWebGL=function(){var a=this,e=document.createElement("canvas").getContext("webgl2",{preserveDrawingBuffer:!0});window.gl=e;var f=ka(e,qa,ra);e.useProgram(f);la(e);sa.forEach(function(b){return a._uniforms[b]=e.getUniformLocation(f,b)});this._program=f;e.enable(e.BLEND);e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA); +e.enable(e.SCISSOR_TEST);return e};b._normalizedEventToPosition=function(a,e){return[Math.floor(a/this._options.tileWidth),Math.floor(e/this._options.tileHeight)]};b._updateSize=function(){var a=this._gl,e=this._options,f=[e.width*e.tileWidth,e.height*e.tileHeight];a.canvas.width=f[0];a.canvas.height=f[1];a.viewport(0,0,f[0],f[1]);a.uniform2fv(this._uniforms.tileSize,[e.tileWidth,e.tileHeight]);a.uniform2fv(this._uniforms.targetSize,f)};b._updateTexture=function(a){var e=this._gl,f=e.createTexture(); +e.bindTexture(e.TEXTURE_2D,f);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.REPEAT);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.REPEAT);e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,0);e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,a)};return c}(G),sa="targetPosRel tilesetPosAbs tileSize targetSize colorize bg tint".split(" "),qa="#version 300 es\n\nin vec2 tilePosRel;\nout vec2 tilesetPosPx;\n\nuniform vec2 tilesetPosAbs;\nuniform vec2 tileSize;\nuniform vec2 targetSize;\nuniform vec2 targetPosRel;\n\nvoid main() {\n\tvec2 targetPosPx = (targetPosRel + tilePosRel) * tileSize;\n\tvec2 targetPosNdc = ((targetPosPx / targetSize)-0.5)*2.0;\n\ttargetPosNdc.y *= -1.0;\n\n\tgl_Position = vec4(targetPosNdc, 0.0, 1.0);\n\ttilesetPosPx = tilesetPosAbs + tilePosRel * tileSize;\n}", +ra="#version 300 es\nprecision highp float;\n\nin vec2 tilesetPosPx;\nout vec4 fragColor;\nuniform sampler2D image;\nuniform bool colorize;\nuniform vec4 bg;\nuniform vec4 tint;\n\nvoid main() {\n\tfragColor = vec4(0, 0, 0, 1);\n\n\tvec4 texel = texelFetch(image, ivec2(tilesetPosPx), 0);\n\n\tif (colorize) {\n\t\ttexel.rgb = tint.a * tint.rgb + (1.0-tint.a) * texel.rgb;\n\t\tfragColor.rgb = texel.a*texel.rgb + (1.0-texel.a)*bg.rgb;\n\t\tfragColor.a = texel.a + (1.0-texel.a)*bg.a;\n\t} else {\n\t\tfragColor = texel;\n\t}\n}", +P={},ha=function(d){function c(){var a=d.call(this)||this;a._offset=[0,0];a._cursor=[-1,-1];a._lastColor="";return a}_inheritsLoose(c,d);var b=c.prototype;b.schedule=function(a){setTimeout(a,1E3/60)};b.setOptions=function(a){d.prototype.setOptions.call(this,a);var e=[a.width,a.height];this._offset=this.computeSize().map(function(a,b){return Math.floor((a-e[b])/2)})};b.clear=function(){process.stdout.write("\u001b[0;48;5;"+Q(this._options.bg)+"m\u001b[2J")};b.draw=function(a,e){var f=a[2],b=a[3],k= +a[4],h=this._offset[0]+a[0],c=this._offset[1]+a[1];a=this.computeSize();if(!(0>h||h>=a[0]||0>c||c>=a[1])){if(h!==this._cursor[0]||c!==this._cursor[1])process.stdout.write("\u001b["+(c+1)+";"+(h+1)+"H"),this._cursor[0]=h,this._cursor[1]=c;e&&(f||(f=" "));f&&(e="\u001b[0;38;5;"+Q(b)+";48;5;"+Q(k)+"m",e!==this._lastColor&&(process.stdout.write(e),this._lastColor=e),"\t"!=f&&(f=[].concat(f),process.stdout.write(f[0])),this._cursor[0]++,this._cursor[0]>=a[0]&&(this._cursor[0]=0,this._cursor[1]++))}};b.computeFontSize= +function(){throw Error("Terminal backend has no notion of font size");};b.eventToPosition=function(a,e){return[a,e]};b.computeSize=function(){return[process.stdout.columns,process.stdout.rows]};return c}(G),ma=/%([bc]){([^}]*)}/g;G=Object.freeze({TYPE_TEXT:0,TYPE_NEWLINE:1,TYPE_FG:2,TYPE_BG:3,measure:function(d,c){var b={width:0,height:1};d=R(d,c);for(var a=c=0;a<d.length;a++){var e=d[a];switch(e.type){case 0:c+=e.value.length;break;case 1:b.height++,b.width=Math.max(b.width,c),c=0}}b.width=Math.max(b.width, +c);return b},tokenize:R});var w={4:[[0,-1],[1,0],[0,1],[-1,0]],8:[[0,-1],[1,-1],[1,0],[1,1],[0,1],[-1,1],[-1,0],[-1,-1]],6:[[-1,-1],[1,-1],[2,0],[1,1],[-1,1],[-2,0]]},ta={hex:ca,rect:da,tile:ea,"tile-gl":fa,term:ha},ua={width:80,height:25,transpose:!1,layout:"rect",fontSize:15,spacing:1,border:0,forceSquareRatio:!1,fontFamily:"monospace",fontStyle:"",fg:"#ccc",bg:"#000",tileWidth:32,tileHeight:32,tileMap:{},tileSet:null,tileColorize:!1},va=function(){var d=function(){function c(a){void 0===a&&(a= +{});this._data={};this._dirty=!1;this._options={};a=Object.assign({},ua,a);this.setOptions(a);this.DEBUG=this.DEBUG.bind(this);this._tick=this._tick.bind(this);this._backend.schedule(this._tick)}var b=c.prototype;b.DEBUG=function(a,e,f){var b=[this._options.bg,this._options.fg];this.draw(a,e,null,null,b[f%b.length])};b.clear=function(){this._data={};this._dirty=!0};b.setOptions=function(a){Object.assign(this._options,a);if(a.width||a.height||a.fontSize||a.fontFamily||a.spacing||a.layout)a.layout&& +(this._backend=new ta[a.layout]),this._backend.setOptions(this._options),this._dirty=!0;return this};b.getOptions=function(){return this._options};b.getContainer=function(){return this._backend.getContainer()};b.computeSize=function(a,e){return this._backend.computeSize(a,e)};b.computeFontSize=function(a,e){return this._backend.computeFontSize(a,e)};b.computeTileSize=function(a,e){return[Math.floor(a/this._options.width),Math.floor(e/this._options.height)]};b.eventToPosition=function(a){if("touches"in +a){var e=a.touches[0].clientX;a=a.touches[0].clientY}else e=a.clientX,a=a.clientY;return this._backend.eventToPosition(e,a)};b.draw=function(a,e,f,b,k){b||(b=this._options.fg);k||(k=this._options.bg);var l=a+","+e;this._data[l]=[a,e,f,b,k];!0!==this._dirty&&(this._dirty||(this._dirty={}),this._dirty[l]=!0)};b.drawOver=function(a,e,b,l,k){var f=this._data[a+","+e];f?(f[2]=b||f[2],f[3]=l||f[3],f[4]=k||f[4]):this.draw(a,e,b,l,k)};b.drawText=function(a,e,f,b){var k=null,l=null,c=a,d=1;b||(b=this._options.width- +a);for(f=R(f,b);f.length;)switch(b=f.shift(),b.type){case 0:for(var g,y=!1,u,r=!1,n=0;n<b.value.length;n++){g=b.value.charCodeAt(n);var q=b.value.charAt(n);if("term"===this._options.layout&&(u=g>>8,17===u||46<=u&&159>=u||172<=u&&215>=u||43360<=g&&43391>=g)){this.draw(c+0,e,q,k,l);this.draw(c+1,e,"\t",k,l);c+=2;continue}u=65280<g&&65377>g||65500<g&&65512>g||65518<g;g=32==q.charCodeAt(0)||12288==q.charCodeAt(0);!r||u||g||c++;u&&!y&&c++;this.draw(c++,e,q,k,l);y=g;r=u}break;case 2:k=b.value||null;break; +case 3:l=b.value||null;break;case 1:c=a,e++,d++}return d};b._tick=function(){this._backend.schedule(this._tick);if(this._dirty){if(!0===this._dirty){this._backend.clear();for(var a in this._data)this._draw(a,!1)}else for(var e in this._dirty)this._draw(e,!0);this._dirty=!1}};b._draw=function(a,e){a=this._data[a];a[4]!=this._options.bg&&(e=!0);this._backend.draw(a,e)};return c}();d.Rect=da;d.Hex=ca;d.Tile=ea;d.TileGL=fa;d.Term=ha;return d}(),wa=function(){function d(b){this._options={words:!1,order:3, +prior:.001};Object.assign(this._options,b);this._suffix=this._boundary=String.fromCharCode(0);this._prefix=[];for(b=0;b<this._options.order;b++)this._prefix.push(this._boundary);this._priorValues={};this._priorValues[this._boundary]=this._options.prior;this._data={}}var c=d.prototype;c.clear=function(){this._data={};this._priorValues={}};c.generate=function(){for(var b=[this._sample(this._prefix)];b[b.length-1]!=this._boundary;)b.push(this._sample(b));return this._join(b.slice(0,-1))};c.observe=function(b){b= +this._split(b);for(var a=0;a<b.length;a++)this._priorValues[b[a]]=this._options.prior;b=this._prefix.concat(b).concat(this._suffix);for(a=this._options.order;a<b.length;a++)for(var e=b.slice(a-this._options.order,a),f=b[a],l=0;l<e.length;l++){var k=e.slice(l);this._observeEvent(k,f)}};c.getStats=function(){var b=[],a=Object.keys(this._priorValues).length;a--;b.push("distinct samples: "+a);a=Object.keys(this._data).length;var e=0,f;for(f in this._data)e+=Object.keys(this._data[f]).length;b.push("dictionary size (contexts): "+ +a);b.push("dictionary size (events): "+e);return b.join(", ")};c._split=function(b){return b.split(this._options.words?/\s+/:"")};c._join=function(b){return b.join(this._options.words?" ":"")};c._observeEvent=function(b,a){b=this._join(b);b in this._data||(this._data[b]={});b=this._data[b];a in b||(b[a]=0);b[a]++};c._sample=function(b){b=this._backoff(b);b=this._join(b);b=this._data[b];var a={};if(this._options.prior){for(var e in this._priorValues)a[e]=this._priorValues[e];for(var f in b)a[f]+=b[f]}else a= +b;return r.getWeightedValue(a)};c._backoff=function(b){for(b.length>this._options.order?b=b.slice(-this._options.order):b.length<this._options.order&&(b=this._prefix.slice(0,this._options.order-b.length).concat(b));!(this._join(b)in this._data)&&0<b.length;)b=b.slice(1);return b};return d}(),ia=function(){function d(){this.heap=[];this.timestamp=0}var c=d.prototype;c.lessThan=function(b,a){return b.key==a.key?b.timestamp<a.timestamp:b.key<a.key};c.shift=function(b){this.heap=this.heap.map(function(a){return{key:a.key+ +b,value:a.value,timestamp:a.timestamp}})};c.len=function(){return this.heap.length};c.push=function(b,a){this.timestamp+=1;var e=this.len();this.heap.push({value:b,timestamp:this.timestamp,key:a});this.updateUp(e)};c.pop=function(){if(0==this.len())throw Error("no element to pop");var b=this.heap[0];1<this.len()?(this.heap[0]=this.heap.pop(),this.updateDown(0)):this.heap.pop();return b};c.find=function(b){for(var a=0;a<this.len();a++)if(b==this.heap[a].value)return this.heap[a];return null};c.remove= +function(b){for(var a=null,e=0;e<this.len();e++)b==this.heap[e].value&&(a=e);if(null===a)return!1;1<this.len()?(e=this.heap.pop(),e.value!=b&&(this.heap[a]=e,this.updateDown(a))):this.heap.pop();return!0};c.parentNode=function(b){return Math.floor((b-1)/2)};c.leftChildNode=function(b){return 2*b+1};c.rightChildNode=function(b){return 2*b+2};c.existNode=function(b){return 0<=b&&b<this.heap.length};c.swap=function(b,a){var e=this.heap[b];this.heap[b]=this.heap[a];this.heap[a]=e};c.minNode=function(b){var a= +b.filter(this.existNode.bind(this));b=a[0];var e=Array.isArray(a),f=0;for(a=e?a:a[Symbol.iterator]();;){if(e){if(f>=a.length)break;var l=a[f++]}else{f=a.next();if(f.done)break;l=f.value}this.lessThan(this.heap[l],this.heap[b])&&(b=l)}return b};c.updateUp=function(b){if(0!=b){var a=this.parentNode(b);this.existNode(a)&&this.lessThan(this.heap[b],this.heap[a])&&(this.swap(b,a),this.updateUp(a))}};c.updateDown=function(b){var a=this.leftChildNode(b),e=this.rightChildNode(b);this.existNode(a)&&(a=this.minNode([b, +a,e]),a!=b&&(this.swap(b,a),this.updateDown(a)))};c.debugPrint=function(){console.log(this.heap)};return d}(),ja=function(){function d(){this._time=0;this._events=new ia}var c=d.prototype;c.getTime=function(){return this._time};c.clear=function(){this._events=new ia;return this};c.add=function(b,a){this._events.push(b,a)};c.get=function(){if(!this._events.len())return null;var b=this._events.pop(),a=b.key;b=b.value;0<a&&(this._time+=a,this._events.shift(-a));return b};c.getEventTime=function(b){if(b= +this._events.find(b))return b.key};c.remove=function(b){return this._events.remove(b)};return d}(),z=function(){function d(){this._queue=new ja;this._repeat=[];this._current=null}var c=d.prototype;c.getTime=function(){return this._queue.getTime()};c.add=function(b,a){a&&this._repeat.push(b);return this};c.getTimeOf=function(b){return this._queue.getEventTime(b)};c.clear=function(){this._queue.clear();this._repeat=[];this._current=null;return this};c.remove=function(b){var a=this._queue.remove(b), +e=this._repeat.indexOf(b);-1!=e&&this._repeat.splice(e,1);this._current==b&&(this._current=null);return a};c.next=function(){return this._current=this._queue.get()};return d}(),U=function(d){function c(){return d.apply(this,arguments)||this}_inheritsLoose(c,d);var b=c.prototype;b.add=function(a,e){this._queue.add(a,0);return d.prototype.add.call(this,a,e)};b.next=function(){null!==this._current&&-1!=this._repeat.indexOf(this._current)&&this._queue.add(this._current,0);return d.prototype.next.call(this)}; +return c}(z),H=function(d){function c(){return d.apply(this,arguments)||this}_inheritsLoose(c,d);var b=c.prototype;b.add=function(a,e,b){this._queue.add(a,void 0!==b?b:1/a.getSpeed());return d.prototype.add.call(this,a,e)};b.next=function(){this._current&&-1!=this._repeat.indexOf(this._current)&&this._queue.add(this._current,1/this._current.getSpeed());return d.prototype.next.call(this)};return c}(z);z=function(d){function c(){var a=d.call(this)||this;a._defaultDuration=1;a._duration=a._defaultDuration; +return a}_inheritsLoose(c,d);var b=c.prototype;b.add=function(a,e,b){this._queue.add(a,b||this._defaultDuration);return d.prototype.add.call(this,a,e)};b.clear=function(){this._duration=this._defaultDuration;return d.prototype.clear.call(this)};b.remove=function(a){a==this._current&&(this._duration=this._defaultDuration);return d.prototype.remove.call(this,a)};b.next=function(){null!==this._current&&-1!=this._repeat.indexOf(this._current)&&(this._queue.add(this._current,this._duration||this._defaultDuration), +this._duration=this._defaultDuration);return d.prototype.next.call(this)};b.setDuration=function(a){this._current&&(this._duration=a);return this};return c}(z);U={Simple:U,Speed:H,Action:z};var x=function(){function d(c,b){void 0===b&&(b={});this._lightPasses=c;this._options=Object.assign({topology:8},b)}d.prototype._getCircle=function(c,b,a){var e=[];switch(this._options.topology){case 4:var f=1;var l=[0,1];var k=[w[8][7],w[8][1],w[8][3],w[8][5]];break;case 6:k=w[6];f=1;l=[-1,1];break;case 8:k=w[4]; +f=2;l=[-1,1];break;default:throw Error("Incorrect topology for FOV computation");}c+=l[0]*a;b+=l[1]*a;for(l=0;l<k.length;l++)for(var h=0;h<a*f;h++)e.push([c,b]),c+=k[l][0],b+=k[l][1];return e};return d}();H=function(d){function c(){return d.apply(this,arguments)||this}_inheritsLoose(c,d);var b=c.prototype;b.compute=function(a,e,b,l){l(a,e,0,1);if(this._lightPasses(a,e))for(var f=[],c,d,p,g,y,u=1;u<=b;u++)for(var n=this._getCircle(a,e,u),r=360/n.length,q=0;q<n.length;q++)if(p=n[q][0],g=n[q][1],c=r* +(q-.5),d=c+r,y=!this._lightPasses(p,g),this._visibleCoords(Math.floor(c),Math.ceil(d),y,f)&&l(p,g,u,1),2==f.length&&0==f[0]&&360==f[1])return};b._visibleCoords=function(a,e,b,l){if(0>a)return e=this._visibleCoords(0,e,b,l),a=this._visibleCoords(360+a,360,b,l),e||a;for(var f=0;f<l.length&&l[f]<a;)f++;if(f==l.length)return b&&l.push(a,e),!0;var c=0;if(f%2){for(;f<l.length&&l[f]<e;)f++,c++;if(0==c)return!1;b&&(c%2?l.splice(f-c,c,e):l.splice(f-c,c))}else{for(;f<l.length&&l[f]<e;)f++,c++;if(a==l[f-c]&& +1==c)return!1;b&&(c%2?l.splice(f-c,c,a):l.splice(f-c,c,a,e))}return!0};return c}(x);z=function(d){function c(){return d.apply(this,arguments)||this}_inheritsLoose(c,d);var b=c.prototype;b.compute=function(a,e,b,c){c(a,e,0,1);if(this._lightPasses(a,e))for(var f=[],l,d,p,g,y,u=1;u<=b;u++)for(var n=this._getCircle(a,e,u),r=n.length,q=0;q<r;q++)if(l=n[q][0],d=n[q][1],g=[q?2*q-1:2*r-1,2*r],y=[2*q+1,2*r],p=!this._lightPasses(l,d),(p=this._checkVisibility(g,y,p,f))&&c(l,d,u,p),2==f.length&&0==f[0][0]&&f[1][0]== +f[1][1])return};b._checkVisibility=function(a,e,b,c){if(a[0]>e[0])return a=this._checkVisibility(a,[a[1],a[1]],b,c),e=this._checkVisibility([0,1],e,b,c),(a+e)/2;for(var f=0,l=!1;f<c.length;){var d=c[f];d=d[0]*a[1]-a[0]*d[1];if(0<=d){0!=d||f%2||(l=!0);break}f++}d=c.length;for(var p=!1;d--;){var g=c[d];g=e[0]*g[1]-g[0]*e[1];if(0<=g){0==g&&d%2&&(p=!0);break}}g=!0;f==d&&(l||p)?g=!1:l&&p&&f+1==d&&d%2?g=!1:f>d&&f%2&&(g=!1);if(!g)return 0;l=d-f+1;if(l%2)f%2?(d=c[f],d=(e[0]*d[1]-d[0]*e[1])/(d[1]*e[1]),b&& +c.splice(f,l,e)):(d=c[d],d=(d[0]*a[1]-a[0]*d[1])/(a[1]*d[1]),b&&c.splice(f,l,a));else if(f%2)p=c[f],d=c[d],d=(d[0]*p[1]-p[0]*d[1])/(p[1]*d[1]),b&&c.splice(f,l);else return b&&c.splice(f,l,a,e),1;return d/((e[0]*a[1]-a[0]*e[1])/(a[1]*e[1]))};return c}(x);var B=[[-1,0,0,1],[0,-1,1,0],[0,-1,-1,0],[-1,0,0,-1],[1,0,0,-1],[0,1,-1,0],[0,1,1,0],[1,0,0,1]];x=function(d){function c(){return d.apply(this,arguments)||this}_inheritsLoose(c,d);var b=c.prototype;b.compute=function(a,e,b,c){c(a,e,0,1);for(var f= +0;f<B.length;f++)this._renderOctant(a,e,B[f],b,c)};b.compute180=function(a,e,b,c,k){k(a,e,0,1);var f=(c-1+8)%8,l=(c+1+8)%8;this._renderOctant(a,e,B[(c-2+8)%8],b,k);this._renderOctant(a,e,B[f],b,k);this._renderOctant(a,e,B[c],b,k);this._renderOctant(a,e,B[l],b,k)};b.compute90=function(a,e,b,c,k){k(a,e,0,1);var f=(c-1+8)%8;this._renderOctant(a,e,B[c],b,k);this._renderOctant(a,e,B[f],b,k)};b._renderOctant=function(a,e,b,c,k){this._castVisibility(a,e,1,1,0,c+1,b[0],b[1],b[2],b[3],k)};b._castVisibility= +function(a,e,b,c,k,d,m,p,g,y,u){if(!(c<k))for(;b<=d;b++){for(var f=-b-1,l=-b,h=!1,T=0;0>=f;){f+=1;var n=a+f*m+l*p,r=e+f*g+l*y,q=(f-.5)/(l+.5),t=(f+.5)/(l-.5);if(!(t>c)){if(q<k)break;f*f+l*l<d*d&&u(n,r,b,1);h?this._lightPasses(n,r)?(h=!1,c=T):T=t:!this._lightPasses(n,r)&&b<d&&(h=!0,this._castVisibility(a,e,b+1,c,q,d,m,p,g,y,u),T=t)}}if(h)break}};return c}(x);H={DiscreteShadowcasting:H,PreciseShadowcasting:z,RecursiveShadowcasting:x};x=function(){function d(c,b){void 0===c&&(c=80);void 0===b&&(b=25); +this._width=c;this._height=b}d.prototype._fillMap=function(c){for(var b=[],a=0;a<this._width;a++){b.push([]);for(var e=0;e<this._height;e++)b[a].push(c)}return b};return d}();z=function(d){function c(){return d.apply(this,arguments)||this}_inheritsLoose(c,d);c.prototype.create=function(b){for(var a=this._width-1,e=this._height-1,f=0;f<=a;f++)for(var c=0;c<=e;c++)b(f,c,f&&c&&f<a&&c<e?0:1);return this};return c}(x);var F=function(d){function c(a,e){a=d.call(this,a,e)||this;a._rooms=[];a._corridors= +[];return a}_inheritsLoose(c,d);var b=c.prototype;b.getRooms=function(){return this._rooms};b.getCorridors=function(){return this._corridors};return c}(x),C=function(){},L=function(d){function c(a,e,b,c,k,h){var f=d.call(this)||this;f._x1=a;f._y1=e;f._x2=b;f._y2=c;f._doors={};void 0!==k&&void 0!==h&&f.addDoor(k,h);return f}_inheritsLoose(c,d);c.createRandomAt=function(a,e,b,c,d){var f=d.roomWidth[0],l=d.roomWidth[1],k=r.getUniformInt(f,l);f=d.roomHeight[0];l=d.roomHeight[1];d=r.getUniformInt(f,l); +if(1==b)return b=e-Math.floor(r.getUniform()*d),new this(a+1,b,a+k,b+d-1,a,e);if(-1==b)return b=e-Math.floor(r.getUniform()*d),new this(a-k,b,a-1,b+d-1,a,e);if(1==c)return b=a-Math.floor(r.getUniform()*k),new this(b,e+1,b+k-1,e+d,a,e);if(-1==c)return b=a-Math.floor(r.getUniform()*k),new this(b,e-d,b+k-1,e-1,a,e);throw Error("dx or dy must be 1 or -1");};c.createRandomCenter=function(a,e,b){var f=b.roomWidth[0],c=b.roomWidth[1],d=r.getUniformInt(f,c);f=b.roomHeight[0];c=b.roomHeight[1];b=r.getUniformInt(f, +c);a-=Math.floor(r.getUniform()*d);e-=Math.floor(r.getUniform()*b);return new this(a,e,a+d-1,e+b-1)};c.createRandom=function(a,e,b){var f=b.roomWidth[0],c=b.roomWidth[1],d=r.getUniformInt(f,c);f=b.roomHeight[0];c=b.roomHeight[1];b=r.getUniformInt(f,c);a=a-d-1;e=e-b-1;a=1+Math.floor(r.getUniform()*a);e=1+Math.floor(r.getUniform()*e);return new this(a,e,a+d-1,e+b-1)};var b=c.prototype;b.addDoor=function(a,e){this._doors[a+","+e]=1;return this};b.getDoors=function(a){for(var e in this._doors){var b= +e.split(",");a(parseInt(b[0]),parseInt(b[1]))}return this};b.clearDoors=function(){this._doors={};return this};b.addDoors=function(a){for(var b=this._x1-1,f=this._x2+1,c=this._y1-1,d=this._y2+1,h=b;h<=f;h++)for(var m=c;m<=d;m++)if(h==b||h==f||m==c||m==d)a(h,m)||this.addDoor(h,m);return this};b.debug=function(){console.log("room",this._x1,this._y1,this._x2,this._y2)};b.isValid=function(a,b){for(var e=this._x1-1,c=this._x2+1,d=this._y1-1,h=this._y2+1,m=e;m<=c;m++)for(var p=d;p<=h;p++)if(m==e||m==c|| +p==d||p==h){if(!a(m,p))return!1}else if(!b(m,p))return!1;return!0};b.create=function(a){for(var b=this._x1-1,f=this._x2+1,c=this._y1-1,d=this._y2+1,h,m=b;m<=f;m++)for(var p=c;p<=d;p++)h=m+","+p in this._doors?2:m==b||m==f||p==c||p==d?1:0,a(m,p,h)};b.getCenter=function(){return[Math.round((this._x1+this._x2)/2),Math.round((this._y1+this._y2)/2)]};b.getLeft=function(){return this._x1};b.getRight=function(){return this._x2};b.getTop=function(){return this._y1};b.getBottom=function(){return this._y2}; +return c}(C),V=function(d){function c(a,b,f,c){var e=d.call(this)||this;e._startX=a;e._startY=b;e._endX=f;e._endY=c;e._endsWithAWall=!0;return e}_inheritsLoose(c,d);c.createRandomAt=function(a,b,f,c,d){d=r.getUniformInt(d.corridorLength[0],d.corridorLength[1]);return new this(a,b,a+f*d,b+c*d)};var b=c.prototype;b.debug=function(){console.log("corridor",this._startX,this._startY,this._endX,this._endY)};b.isValid=function(a,b){var e=this._startX,c=this._startY,d=this._endX-e,h=this._endY-c,m=1+Math.max(Math.abs(d), +Math.abs(h));d&&(d/=Math.abs(d));h&&(h/=Math.abs(h));for(var p=h,g=-d,y=!0,n=0;n<m;n++){var r=e+n*d,q=c+n*h;b(r,q)||(y=!1);a(r+p,q+g)||(y=!1);a(r-p,q-g)||(y=!1);if(!y){m=n;this._endX=r-d;this._endY=q-h;break}}if(0==m||1==m&&a(this._endX+d,this._endY+h))return!1;b=!a(this._endX+d+p,this._endY+h+g);p=!a(this._endX+d-p,this._endY+h-g);this._endsWithAWall=a(this._endX+d,this._endY+h);return(b||p)&&this._endsWithAWall?!1:!0};b.create=function(a){var b=this._startX,f=this._startY,c=this._endX-b,d=this._endY- +f,h=1+Math.max(Math.abs(c),Math.abs(d));c&&(c/=Math.abs(c));d&&(d/=Math.abs(d));for(var m=0;m<h;m++)a(b+m*c,f+m*d,0);return!0};b.createPriorityWalls=function(a){if(this._endsWithAWall){var b=this._endX-this._startX,f=this._endY-this._startY;b&&(b/=Math.abs(b));f&&(f/=Math.abs(f));var c=f,d=-b;a(this._endX+b,this._endY+f);a(this._endX+c,this._endY+d);a(this._endX-c,this._endY-d)}};return c}(C);C=function(d){function c(a,b,f){a=d.call(this,a,b)||this;a._options={roomWidth:[3,9],roomHeight:[3,5],roomDugPercentage:.1, +timeLimit:1E3};Object.assign(a._options,f);a._map=[];a._dug=0;a._roomAttempts=20;a._corridorAttempts=20;a._connected=[];a._unconnected=[];a._digCallback=a._digCallback.bind(_assertThisInitialized(_assertThisInitialized(a)));a._canBeDugCallback=a._canBeDugCallback.bind(_assertThisInitialized(_assertThisInitialized(a)));a._isWallCallback=a._isWallCallback.bind(_assertThisInitialized(_assertThisInitialized(a)));return a}_inheritsLoose(c,d);var b=c.prototype;b.create=function(a){for(var b=Date.now();;){if(Date.now()- +b>this._options.timeLimit)return null;this._map=this._fillMap(1);this._dug=0;this._rooms=[];this._unconnected=[];this._generateRooms();if(!(2>this._rooms.length)&&this._generateCorridors())break}if(a)for(b=0;b<this._width;b++)for(var f=0;f<this._height;f++)a(b,f,this._map[b][f]);return this};b._generateRooms=function(){var a=this._width-2,b=this._height-2;do{var f=this._generateRoom();if(this._dug/(a*b)>this._options.roomDugPercentage)break}while(f)};b._generateRoom=function(){for(var a=0;a<this._roomAttempts;){a++; +var b=L.createRandom(this._width,this._height,this._options);if(b.isValid(this._isWallCallback,this._canBeDugCallback))return b.create(this._digCallback),this._rooms.push(b),b}return null};b._generateCorridors=function(){for(var a=0;a<this._corridorAttempts;){a++;this._corridors=[];this._map=this._fillMap(1);for(var b=0;b<this._rooms.length;b++){var f=this._rooms[b];f.clearDoors();f.create(this._digCallback)}this._unconnected=r.shuffle(this._rooms.slice());this._connected=[];for(this._unconnected.length&& +this._connected.push(this._unconnected.pop());;){b=r.getItem(this._connected);if(!b)break;b=this._closestRoom(this._unconnected,b);if(!b)break;f=this._closestRoom(this._connected,b);if(!f)break;if(!this._connectRooms(b,f))break;if(!this._unconnected.length)return!0}}return!1};b._closestRoom=function(a,b){var e=Infinity;b=b.getCenter();for(var c=null,d=0;d<a.length;d++){var h=a[d],m=h.getCenter(),g=m[0]-b[0];m=m[1]-b[1];g=g*g+m*m;g<e&&(e=g,c=h)}return c};b._connectRooms=function(a,b){var e=a.getCenter(), +c=b.getCenter(),d=c[0]-e[0];e=c[1]-e[1];if(Math.abs(d)<Math.abs(e)){d=0<e?2:0;var h=(d+2)%4;var m=b.getLeft();var g=b.getRight();e=0}else d=0<d?1:3,h=(d+2)%4,m=b.getTop(),g=b.getBottom(),e=1;d=this._placeInWall(a,d);if(!d)return!1;if(d[e]>=m&&d[e]<=g){c=d.slice();m=0;switch(h){case 0:m=b.getTop()-1;break;case 1:m=b.getRight()+1;break;case 2:m=b.getBottom()+1;break;case 3:m=b.getLeft()-1}c[(e+1)%2]=m;this._digLine([d,c])}else if(d[e]<m-1||d[e]>g+1){c=d[e]-c[e];m=0;switch(h){case 0:case 1:m=0>c?3:1; +break;case 2:case 3:m=0>c?1:3}c=this._placeInWall(b,(h+m)%4);if(!c)return!1;h=[0,0];h[e]=d[e];e=(e+1)%2;h[e]=c[e];this._digLine([d,h,c])}else{m=(e+1)%2;c=this._placeInWall(b,h);if(!c)return!1;h=Math.round((c[m]+d[m])/2);g=[0,0];var n=[0,0];g[e]=d[e];g[m]=h;n[e]=c[e];n[m]=h;this._digLine([d,g,n,c])}a.addDoor(d[0],d[1]);b.addDoor(c[0],c[1]);e=this._unconnected.indexOf(a);-1!=e&&(this._unconnected.splice(e,1),this._connected.push(a));e=this._unconnected.indexOf(b);-1!=e&&(this._unconnected.splice(e, +1),this._connected.push(b));return!0};b._placeInWall=function(a,b){var e=[0,0],c=[0,0],d=0;switch(b){case 0:c=[1,0];e=[a.getLeft(),a.getTop()-1];d=a.getRight()-a.getLeft()+1;break;case 1:c=[0,1];e=[a.getRight()+1,a.getTop()];d=a.getBottom()-a.getTop()+1;break;case 2:c=[1,0];e=[a.getLeft(),a.getBottom()+1];d=a.getRight()-a.getLeft()+1;break;case 3:c=[0,1],e=[a.getLeft()-1,a.getTop()],d=a.getBottom()-a.getTop()+1}a=[];b=-2;for(var h=0;h<d;h++){var m=e[0]+h*c[0],g=e[1]+h*c[1];a.push(null);1==this._map[m][g]? +b!=h-1&&(a[h]=[m,g]):(b=h)&&(a[h-1]=null)}for(e=a.length-1;0<=e;e--)a[e]||a.splice(e,1);return a.length?r.getItem(a):null};b._digLine=function(a){for(var b=1;b<a.length;b++){var f=a[b-1],c=a[b];f=new V(f[0],f[1],c[0],c[1]);f.create(this._digCallback);this._corridors.push(f)}};b._digCallback=function(a,b,f){this._map[a][b]=f;0==f&&this._dug++};b._isWallCallback=function(a,b){return 0>a||0>b||a>=this._width||b>=this._height?!1:1==this._map[a][b]};b._canBeDugCallback=function(a,b){return 1>a||1>b||a+ +1>=this._width||b+1>=this._height?!1:1==this._map[a][b]};return c}(F);var D=function(d){function c(a,b,f){void 0===f&&(f={});a=d.call(this,a,b)||this;a._options={born:[5,6,7,8],survive:[4,5,6,7,8],topology:8};a.setOptions(f);a._dirs=w[a._options.topology];a._map=a._fillMap(0);return a}_inheritsLoose(c,d);var b=c.prototype;b.randomize=function(a){for(var b=0;b<this._width;b++)for(var f=0;f<this._height;f++)this._map[b][f]=r.getUniform()<a?1:0;return this};b.setOptions=function(a){Object.assign(this._options, +a)};b.set=function(a,b,f){this._map[a][b]=f};b.create=function(a){for(var b=this._fillMap(0),f=this._options.born,c=this._options.survive,d=0;d<this._height;d++){var h=1,m=0;6==this._options.topology&&(h=2,m=d%2);for(;m<this._width;m+=h){var g=this._map[m][d],n=this._getNeighbors(m,d);g&&-1!=c.indexOf(n)?b[m][d]=1:g||-1==f.indexOf(n)||(b[m][d]=1)}}this._map=b;a&&this._serviceCallback(a)};b._serviceCallback=function(a){for(var b=0;b<this._height;b++){var f=1,c=0;6==this._options.topology&&(f=2,c=b% +2);for(;c<this._width;c+=f)a(c,b,this._map[c][b])}};b._getNeighbors=function(a,b){for(var e=0,c=0;c<this._dirs.length;c++){var d=this._dirs[c],h=a+d[0];d=b+d[1];0>h||h>=this._width||0>d||d>=this._height||(e+=1==this._map[h][d]?1:0)}return e};b.connect=function(a,b,f){b||(b=0);var e=[],c={},d=1,m=[0,0];6==this._options.topology&&(d=2,m=[0,1]);for(var g=0;g<this._height;g++)for(var n=m[g%2];n<this._width;n+=d)if(this._freeSpace(n,g,b)){var y=[n,g];c[this._pointKey(y)]=y;e.push([n,g])}d=e[r.getUniformInt(0, +e.length-1)];m=this._pointKey(d);e={};e[m]=d;delete c[m];for(this._findConnected(e,c,[d],!1,b);0<Object.keys(c).length;){m=this._getFromTo(e,c);d=m[0];g=m[1];m={};m[this._pointKey(d)]=d;this._findConnected(m,c,[d],!0,b);(6==this._options.topology?this._tunnelToConnected6:this._tunnelToConnected).call(this,g,d,e,c,b,f);for(var q in m)d=m[q],this._map[d[0]][d[1]]=b,e[q]=d,delete c[q]}a&&this._serviceCallback(a)};b._getFromTo=function(a,b){for(var e=[0,0],c=[0,0],d,h=Object.keys(a),g=Object.keys(b), +p=0;5>p&&!(h.length<g.length?(e=h,c=a[e[r.getUniformInt(0,e.length-1)]],e=this._getClosest(c,b)):(e=g,e=b[e[r.getUniformInt(0,e.length-1)]],c=this._getClosest(e,a)),d=(e[0]-c[0])*(e[0]-c[0])+(e[1]-c[1])*(e[1]-c[1]),64>d);p++);return[e,c]};b._getClosest=function(a,b){var e=null,c=null,d;for(d in b){var h=b[d],g=(h[0]-a[0])*(h[0]-a[0])+(h[1]-a[1])*(h[1]-a[1]);if(null==c||g<c)c=g,e=h}return e};b._findConnected=function(a,b,f,c,d){for(;0<f.length;){var e=f.splice(0,1)[0];e=6==this._options.topology?[[e[0]+ +2,e[1]],[e[0]+1,e[1]-1],[e[0]-1,e[1]-1],[e[0]-2,e[1]],[e[0]-1,e[1]+1],[e[0]+1,e[1]+1]]:[[e[0]+1,e[1]],[e[0]-1,e[1]],[e[0],e[1]+1],[e[0],e[1]-1]];for(var l=0;l<e.length;l++){var k=this._pointKey(e[l]);null==a[k]&&this._freeSpace(e[l][0],e[l][1],d)&&(a[k]=e[l],c||delete b[k],f.push(e[l]))}}};b._tunnelToConnected=function(a,b,f,c,d,h){if(b[0]<a[0]){var e=b;var l=a}else e=a,l=b;for(var k=e[0];k<=l[0];k++){this._map[k][e[1]]=d;var g=[k,e[1]],n=this._pointKey(g);f[n]=g;delete c[n]}h&&e[0]<l[0]&&h(e,[l[0], +e[1]]);k=l[0];b[1]<a[1]?(e=b,l=a):(e=a,l=b);for(a=e[1];a<l[1];a++)this._map[k][a]=d,b=[k,a],g=this._pointKey(b),f[g]=b,delete c[g];h&&e[1]<l[1]&&h([l[0],e[1]],[l[0],l[1]])};b._tunnelToConnected6=function(a,b,f,c,d,h){if(b[0]<a[0]){var e=b;var l=a}else e=a,l=b;var k=e[0];for(e=e[1];k!=l[0]||e!=l[1];){var g=2;e<l[1]?(e++,g=1):e>l[1]&&(e--,g=1);k=k<l[0]?k+g:k>l[0]?k-g:l[1]%2?k-g:k+g;this._map[k][e]=d;g=[k,e];var n=this._pointKey(g);f[n]=g;delete c[n]}h&&h(b,a)};b._freeSpace=function(a,b,f){return 0<= +a&&a<this._width&&0<=b&&b<this._height&&this._map[a][b]==f};b._pointKey=function(a){return a[0]+"."+a[1]};return c}(x),xa={room:L,corridor:V};F=function(d){function c(a,b,f){void 0===f&&(f={});a=d.call(this,a,b)||this;a._options=Object.assign({roomWidth:[3,9],roomHeight:[3,5],corridorLength:[3,10],dugPercentage:.2,timeLimit:1E3},f);a._features={room:4,corridor:4};a._map=[];a._featureAttempts=20;a._walls={};a._dug=0;a._digCallback=a._digCallback.bind(_assertThisInitialized(_assertThisInitialized(a))); +a._canBeDugCallback=a._canBeDugCallback.bind(_assertThisInitialized(_assertThisInitialized(a)));a._isWallCallback=a._isWallCallback.bind(_assertThisInitialized(_assertThisInitialized(a)));a._priorityWallCallback=a._priorityWallCallback.bind(_assertThisInitialized(_assertThisInitialized(a)));return a}_inheritsLoose(c,d);var b=c.prototype;b.create=function(a){this._rooms=[];this._corridors=[];this._map=this._fillMap(1);this._walls={};this._dug=0;var b=(this._width-2)*(this._height-2);this._firstRoom(); +var f=Date.now();do{var c=0;if(Date.now()-f>this._options.timeLimit)break;var d=this._findWall();if(!d)break;var h=d.split(",");d=parseInt(h[0]);h=parseInt(h[1]);var g=this._getDiggingDirection(d,h);if(g){var p=0;do if(p++,this._tryFeature(d,h,g[0],g[1])){this._removeSurroundingWalls(d,h);this._removeSurroundingWalls(d-g[0],h-g[1]);break}while(p<this._featureAttempts);for(var n in this._walls)1<this._walls[n]&&c++}}while(this._dug/b<this._options.dugPercentage||c);this._addDoors();if(a)for(b=0;b< +this._width;b++)for(f=0;f<this._height;f++)a(b,f,this._map[b][f]);this._walls={};this._map=[];return this};b._digCallback=function(a,b,f){0==f||2==f?(this._map[a][b]=0,this._dug++):this._walls[a+","+b]=1};b._isWallCallback=function(a,b){return 0>a||0>b||a>=this._width||b>=this._height?!1:1==this._map[a][b]};b._canBeDugCallback=function(a,b){return 1>a||1>b||a+1>=this._width||b+1>=this._height?!1:1==this._map[a][b]};b._priorityWallCallback=function(a,b){this._walls[a+","+b]=2};b._firstRoom=function(){var a= +L.createRandomCenter(Math.floor(this._width/2),Math.floor(this._height/2),this._options);this._rooms.push(a);a.create(this._digCallback)};b._findWall=function(){var a=[],b=[],f;for(f in this._walls)2==this._walls[f]?b.push(f):a.push(f);a=b.length?b:a;if(!a.length)return null;a=r.getItem(a.sort());delete this._walls[a];return a};b._tryFeature=function(a,b,f,c){var e=r.getWeightedValue(this._features);a=xa[e].createRandomAt(a,b,f,c,this._options);if(!a.isValid(this._isWallCallback,this._canBeDugCallback))return!1; +a.create(this._digCallback);a instanceof L&&this._rooms.push(a);a instanceof V&&(a.createPriorityWalls(this._priorityWallCallback),this._corridors.push(a));return!0};b._removeSurroundingWalls=function(a,b){for(var e=w[4],c=0;c<e.length;c++){var d=e[c],h=a+d[0],g=b+d[1];delete this._walls[h+","+g];h=a+2*d[0];g=b+2*d[1];delete this._walls[h+","+g]}};b._getDiggingDirection=function(a,b){if(0>=a||0>=b||a>=this._width-1||b>=this._height-1)return null;for(var e=null,c=w[4],d=0;d<c.length;d++){var h=c[d]; +if(!this._map[a+h[0]][b+h[1]]){if(e)return null;e=h}}return e?[-e[0],-e[1]]:null};b._addDoors=function(){function a(a,e){return 1==b[a][e]}for(var b=this._map,c=0;c<this._rooms.length;c++){var d=this._rooms[c];d.clearDoors();d.addDoors(a)}};return c}(F);var ya=function(d){function c(){return d.apply(this,arguments)||this}_inheritsLoose(c,d);c.prototype.create=function(b){for(var a=this._fillMap(1),e=Math.ceil((this._width-2)/2),c=[],d=[],k=0;k<e;k++)c.push(k),d.push(k);c.push(e-1);for(k=1;k+3<this._height;k+= +2)for(var h=0;h<e;h++){var g=2*h+1,p=k;a[g][p]=0;h!=c[h+1]&&.375<r.getUniform()&&(aa(h,c,d),a[g+1][p]=0);h!=c[h]&&.375<r.getUniform()?ba(h,c,d):a[g][p+1]=0}for(h=0;h<e;h++)g=2*h+1,p=k,a[g][p]=0,h!=c[h+1]&&(h==c[h]||.375<r.getUniform())&&(aa(h,c,d),a[g+1][p]=0),ba(h,c,d);for(e=0;e<this._width;e++)for(c=0;c<this._height;c++)b(e,c,a[e][c]);return this};return c}(x),za=function(d){function c(){var a=d.apply(this,arguments)||this;a._stack=[];a._map=[];return a}_inheritsLoose(c,d);var b=c.prototype;b.create= +function(a){var b=this._width,c=this._height;this._map=[];for(var d=0;d<b;d++){this._map.push([]);for(var k=0;k<c;k++)this._map[d].push(0==d||0==k||d+1==b||k+1==c?1:0)}this._stack=[[1,1,b-2,c-2]];this._process();for(d=0;d<b;d++)for(k=0;k<c;k++)a(d,k,this._map[d][k]);this._map=[];return this};b._process=function(){for(;this._stack.length;){var a=this._stack.shift();this._partitionRoom(a)}};b._partitionRoom=function(a){for(var b=[],c=[],d=a[0]+1;d<a[2];d++){var k=this._map[d][a[3]+1];!this._map[d][a[1]- +1]||!k||d%2||b.push(d)}for(d=a[1]+1;d<a[3];d++)k=this._map[a[2]+1][d],!this._map[a[0]-1][d]||!k||d%2||c.push(d);if(b.length&&c.length){b=r.getItem(b);c=r.getItem(c);this._map[b][c]=1;d=[];k=[];d.push(k);for(var h=a[0];h<b;h++)this._map[h][c]=1,h%2&&k.push([h,c]);k=[];d.push(k);for(h=b+1;h<=a[2];h++)this._map[h][c]=1,h%2&&k.push([h,c]);k=[];d.push(k);for(h=a[1];h<c;h++)this._map[b][h]=1,h%2&&k.push([b,h]);k=[];d.push(k);for(h=c+1;h<=a[3];h++)this._map[b][h]=1,h%2&&k.push([b,h]);k=r.getItem(d);for(h= +0;h<d.length;h++){var g=d[h];g!=k&&(g=r.getItem(g),this._map[g[0]][g[1]]=0)}this._stack.push([a[0],a[1],b-1,c-1]);this._stack.push([b+1,a[1],a[2],c-1]);this._stack.push([a[0],c+1,b-1,a[3]]);this._stack.push([b+1,c+1,a[2],a[3]])}};return c}(x),Aa=function(d){function c(a,b,c){void 0===c&&(c=0);a=d.call(this,a,b)||this;a._regularity=c;a._map=[];return a}_inheritsLoose(c,d);var b=c.prototype;b.create=function(a){var b=this._width,c=this._height,d=this._fillMap(1);b-=b%2?1:2;c-=c%2?1:2;var g=0,h=[[0, +0],[0,0],[0,0],[0,0]];do{var m=1+2*Math.floor(r.getUniform()*(b-1)/2);var p=1+2*Math.floor(r.getUniform()*(c-1)/2);g||(d[m][p]=0);if(!d[m][p]){this._randomize(h);do{0==Math.floor(r.getUniform()*(this._regularity+1))&&this._randomize(h);var n=!0;for(var q=0;4>q;q++){var u=m+2*h[q][0];var t=p+2*h[q][1];if(this._isFree(d,u,t,b,c)){d[u][t]=0;d[m+h[q][0]][p+h[q][1]]=0;m=u;p=t;n=!1;g++;break}}}while(!n)}}while(g+1<b*c/4);for(b=0;b<this._width;b++)for(c=0;c<this._height;c++)a(b,c,d[b][c]);this._map=[];return this}; +b._randomize=function(a){for(var b=0;4>b;b++)a[b][0]=0,a[b][1]=0;switch(Math.floor(4*r.getUniform())){case 0:a[0][0]=-1;a[1][0]=1;a[2][1]=-1;a[3][1]=1;break;case 1:a[3][0]=-1;a[2][0]=1;a[1][1]=-1;a[0][1]=1;break;case 2:a[2][0]=-1;a[3][0]=1;a[0][1]=-1;a[1][1]=1;break;case 3:a[1][0]=-1,a[0][0]=1,a[3][1]=-1,a[2][1]=1}};b._isFree=function(a,b,c,d,g){return 1>b||1>c||b>=d||c>=g?!1:a[b][c]};return c}(x);x=function(d){function c(a,b,c){a=d.call(this,a,b)||this;a.map=[];a.rooms=[];a.connectedCells=[];c=Object.assign({cellWidth:3, +cellHeight:3},c);c.hasOwnProperty("roomWidth")||(c.roomWidth=a._calculateRoomSize(a._width,c.cellWidth));c.hasOwnProperty("roomHeight")||(c.roomHeight=a._calculateRoomSize(a._height,c.cellHeight));a._options=c;return a}_inheritsLoose(c,d);var b=c.prototype;b.create=function(a){this.map=this._fillMap(1);this.rooms=[];this.connectedCells=[];this._initRooms();this._connectRooms();this._connectUnconnectedRooms();this._createRandomRoomConnections();this._createRooms();this._createCorridors();if(a)for(var b= +0;b<this._width;b++)for(var c=0;c<this._height;c++)a(b,c,this.map[b][c]);return this};b._calculateRoomSize=function(a,b){var e=Math.floor(a/b*.8);a=Math.floor(a/b*.25);2>a&&(a=2);2>e&&(e=2);return[a,e]};b._initRooms=function(){for(var a=0;a<this._options.cellWidth;a++){this.rooms.push([]);for(var b=0;b<this._options.cellHeight;b++)this.rooms[a].push({x:0,y:0,width:0,height:0,connections:[],cellx:a,celly:b})}};b._connectRooms=function(){var a=r.getUniformInt(0,this._options.cellWidth-1),b=r.getUniformInt(0, +this._options.cellHeight-1);do{var c=[0,2,4,6];c=r.shuffle(c);do{var d=!1;var g=c.pop();var h=a+w[8][g][0];g=b+w[8][g][1];if(!(0>h||h>=this._options.cellWidth||0>g||g>=this._options.cellHeight)){var m=this.rooms[a][b];if(0<m.connections.length&&m.connections[0][0]==h&&m.connections[0][1]==g)break;m=this.rooms[h][g];0==m.connections.length&&(m.connections.push([a,b]),this.connectedCells.push([h,g]),a=h,b=g,d=!0)}}while(0<c.length&&0==d)}while(0<c.length)};b._connectUnconnectedRooms=function(){var a= +this._options.cellWidth,b=this._options.cellHeight;this.connectedCells=r.shuffle(this.connectedCells);for(var c,d,g,h=0;h<this._options.cellWidth;h++)for(var m=0;m<this._options.cellHeight;m++)if(c=this.rooms[h][m],0==c.connections.length){var p=[0,2,4,6];p=r.shuffle(p);g=!1;do{var n=p.pop(),q=h+w[8][n][0];n=m+w[8][n][1];if(!(0>q||q>=a||0>n||n>=b)){d=this.rooms[q][n];g=!0;if(0==d.connections.length)break;for(q=0;q<d.connections.length;q++)if(d.connections[q][0]==h&&d.connections[q][1]==m){g=!1;break}if(g)break}}while(p.length); +g?c.connections.push([d.cellx,d.celly]):console.log("-- Unable to connect room.")}};b._createRandomRoomConnections=function(){};b._createRooms=function(){for(var a=this._width,b=this._height,c=this._options.cellWidth,d=this._options.cellHeight,g=Math.floor(this._width/c),h=Math.floor(this._height/d),m,p,n=this._options.roomWidth,q=this._options.roomHeight,u,t,v,w=0;w<c;w++)for(var x=0;x<d;x++){u=g*w;t=h*x;0==u&&(u=1);0==t&&(t=1);m=r.getUniformInt(n[0],n[1]);p=r.getUniformInt(q[0],q[1]);if(0<x)for(v= +this.rooms[w][x-1];3>t-(v.y+v.height);)t++;if(0<w)for(v=this.rooms[w-1][x];3>u-(v.x+v.width);)u++;v=Math.round(r.getUniformInt(0,g-m)/2);for(var A=Math.round(r.getUniformInt(0,h-p)/2);u+v+m>=a;)v?v--:m--;for(;t+A+p>=b;)A?A--:p--;u+=v;t+=A;this.rooms[w][x].x=u;this.rooms[w][x].y=t;this.rooms[w][x].width=m;this.rooms[w][x].height=p;for(v=u;v<u+m;v++)for(A=t;A<t+p;A++)this.map[v][A]=0}};b._getWallPosition=function(a,b){if(1==b||3==b){var c=r.getUniformInt(a.x+1,a.x+a.width-2);if(1==b){var e=a.y-2;a= +e+1}else e=a.y+a.height+1,a=e-1;this.map[c][a]=0}else e=r.getUniformInt(a.y+1,a.y+a.height-2),2==b?(c=a.x+a.width+1,a=c-1):(c=a.x-2,a=c+1),this.map[a][e]=0;return[c,e]};b._drawCorridor=function(a,b){var c=b[0]-a[0],e=b[1]-a[1];b=a[0];a=a[1];var d=[];var g=Math.abs(c);var m=Math.abs(e);var p=r.getUniform();var n=1-p;c=0<c?2:6;e=0<e?4:0;g<m?(p=Math.ceil(m*p),d.push([e,p]),d.push([c,g]),p=Math.floor(m*n),d.push([e,p])):(p=Math.ceil(g*p),d.push([c,p]),d.push([e,m]),p=Math.floor(g*n),d.push([c,p]));for(this.map[b][a]= +0;0<d.length;)for(g=d.pop();0<g[1];)b+=w[8][g[0]][0],a+=w[8][g[0]][1],this.map[b][a]=0,--g[1]};b._createCorridors=function(){for(var a=this._options.cellWidth,b=this._options.cellHeight,c,d,g,h,m=0;m<a;m++)for(var p=0;p<b;p++){c=this.rooms[m][p];for(var n=0;n<c.connections.length;n++)d=c.connections[n],d=this.rooms[d[0]][d[1]],d.cellx>c.cellx?(g=2,h=4):d.cellx<c.cellx?(g=4,h=2):d.celly>c.celly?(g=3,h=1):(g=1,h=3),this._drawCorridor(this._getWallPosition(c,g),this._getWallPosition(d,h))}};return c}(x); +z={Arena:z,Uniform:C,Cellular:D,Digger:F,EllerMaze:ya,DividedMaze:za,IceyMaze:Aa,Rogue:x};var Ba=.5*(Math.sqrt(3)-1),I=(3-Math.sqrt(3))/6;x={Simplex:function(d){function c(b){void 0===b&&(b=256);var a=d.call(this)||this;a._gradients=[[0,-1],[1,-1],[1,0],[1,1],[0,1],[-1,1],[-1,0],[-1,-1]];for(var c=[],f=0;f<b;f++)c.push(f);c=r.shuffle(c);a._perms=[];a._indexes=[];for(f=0;f<2*b;f++)a._perms.push(c[f%b]),a._indexes.push(a._perms[f]%a._gradients.length);return a}_inheritsLoose(c,d);c.prototype.get=function(b, +a){var c=this._perms,d=this._indexes,g=c.length/2,k=0,h=0,m=0,p=(b+a)*Ba,q=Math.floor(b+p);var r=Math.floor(a+p);var t=(q+r)*I;p=b-(q-t);var v=a-(r-t);if(p>v){var w=1;var x=0}else w=0,x=1;t=p-w+I;var z=v-x+I;a=p-1+2*I;b=v-1+2*I;q=n(q,g);g=n(r,g);var A=.5-p*p-v*v;0<=A&&(A*=A,r=d[q+c[g]],k=this._gradients[r],k=A*A*(k[0]*p+k[1]*v));p=.5-t*t-z*z;0<=p&&(p*=p,r=d[q+w+c[g+x]],h=this._gradients[r],h=p*p*(h[0]*t+h[1]*z));p=.5-a*a-b*b;0<=p&&(p*=p,r=d[q+1+c[g+1]],c=this._gradients[r],m=p*p*(c[0]*a+c[1]*b)); +return 70*(k+h+m)};return c}(function(){})};D=function(){function d(c,b,a,e){void 0===e&&(e={});this._toX=c;this._toY=b;this._passableCallback=a;this._options=Object.assign({topology:8},e);this._dirs=w[this._options.topology];8==this._options.topology&&(this._dirs=[this._dirs[0],this._dirs[2],this._dirs[4],this._dirs[6],this._dirs[1],this._dirs[3],this._dirs[5],this._dirs[7]])}d.prototype._getNeighbors=function(c,b){for(var a=[],e=0;e<this._dirs.length;e++){var d=this._dirs[e],g=c+d[0];d=b+d[1];this._passableCallback(g, +d)&&a.push([g,d])}return a};return d}();C=function(d){function c(a,b,c,g){c=d.call(this,a,b,c,g)||this;c._computed={};c._todo=[];c._add(a,b,null);return c}_inheritsLoose(c,d);var b=c.prototype;b.compute=function(a,b,c){var d=a+","+b;d in this._computed||this._compute(a,b);if(d in this._computed)for(a=this._computed[d];a;)c(a.x,a.y),a=a.prev};b._compute=function(a,b){for(;this._todo.length;){var c=this._todo.shift();if(c.x==a&&c.y==b)break;for(var d=this._getNeighbors(c.x,c.y),e=0;e<d.length;e++){var g= +d[e],m=g[0];g=g[1];m+","+g in this._computed||this._add(m,g,c)}}};b._add=function(a,b,c){c={x:a,y:b,prev:c};this._computed[a+","+b]=c;this._todo.push(c)};return c}(D);D=function(d){function c(a,b,c,g){void 0===g&&(g={});a=d.call(this,a,b,c,g)||this;a._todo=[];a._done={};return a}_inheritsLoose(c,d);var b=c.prototype;b.compute=function(a,b,c){this._todo=[];this._done={};this._fromX=a;this._fromY=b;for(this._add(this._toX,this._toY,null);this._todo.length;){var d=this._todo.shift(),e=d.x+","+d.y;if(!(e in +this._done)){this._done[e]=d;if(d.x==a&&d.y==b)break;e=this._getNeighbors(d.x,d.y);for(var f=0;f<e.length;f++){var g=e[f],n=g[0];g=g[1];n+","+g in this._done||this._add(n,g,d)}}}if(a=this._done[a+","+b])for(;a;)c(a.x,a.y),a=a.prev};b._add=function(a,b,c){var d=this._distance(a,b);a={x:a,y:b,prev:c,g:c?c.g+1:0,h:d};b=a.g+a.h;for(c=0;c<this._todo.length;c++){var e=this._todo[c],f=e.g+e.h;if(b<f||b==f&&d<e.h){this._todo.splice(c,0,a);return}}this._todo.push(a)};b._distance=function(a,b){switch(this._options.topology){case 4:return Math.abs(a- +this._fromX)+Math.abs(b-this._fromY);case 6:return b=Math.abs(b-this._fromY),b+Math.max(0,(Math.abs(a-this._fromX)-b)/2);case 8:return Math.max(Math.abs(a-this._fromX),Math.abs(b-this._fromY))}};return c}(D);C={Dijkstra:C,AStar:D};D=function(){function d(b){this._scheduler=b;this._lock=1}var c=d.prototype;c.start=function(){return this.unlock()};c.lock=function(){this._lock++;return this};c.unlock=function(){if(!this._lock)throw Error("Cannot unlock unlocked engine");for(this._lock--;!this._lock;){var b= +this._scheduler.next();if(!b)return this.lock();(b=b.act())&&b.then&&(this.lock(),b.then(this.unlock.bind(this)))}return this};return d}();F=function(){function d(b,a){void 0===a&&(a={});this._reflectivityCallback=b;this._options={};a=Object.assign({passes:1,emissionThreshold:100,range:10},a);this._lights={};this._reflectivityCache={};this._fovCache={};this.setOptions(a)}var c=d.prototype;c.setOptions=function(b){Object.assign(this._options,b);b&&b.range&&this.reset();return this};c.setFOV=function(b){this._fov= +b;this._fovCache={};return this};c.setLight=function(b,a,c){b=b+","+a;c?this._lights[b]="string"==typeof c?E(c):c:delete this._lights[b];return this};c.clearLights=function(){this._lights={}};c.reset=function(){this._reflectivityCache={};this._fovCache={};return this};c.compute=function(b){var a={},c={},d={},g;for(g in this._lights){var k=this._lights[g];c[g]=[0,0,0];W(c[g],k)}for(g=0;g<this._options.passes;g++)this._emitLight(c,d,a),g+1!=this._options.passes&&(c=this._computeEmitters(d,a));for(var h in d)c= +h.split(","),a=parseInt(c[0]),c=parseInt(c[1]),b(a,c,d[h]);return this};c._emitLight=function(b,a,c){for(var d in b){var e=d.split(","),g=parseInt(e[0]);e=parseInt(e[1]);this._emitLightFromCell(g,e,b[d],a);c[d]=1}return this};c._computeEmitters=function(b,a){var c={},d;for(d in b)if(!(d in a)){var g=b[d];if(d in this._reflectivityCache)var k=this._reflectivityCache[d];else{var h=d.split(",");k=parseInt(h[0]);h=parseInt(h[1]);k=this._reflectivityCallback(k,h);this._reflectivityCache[d]=k}if(0!=k){h= +[0,0,0];for(var m=0,n=0;3>n;n++){var q=Math.round(g[n]*k);h[n]=q;m+=q}m>this._options.emissionThreshold&&(c[d]=h)}}return c};c._emitLightFromCell=function(b,a,c,d){var e=b+","+a;b=e in this._fovCache?this._fovCache[e]:this._updateFOV(b,a);for(var f in b){a=b[f];f in d?e=d[f]:(e=[0,0,0],d[f]=e);for(var g=0;3>g;g++)e[g]+=Math.round(c[g]*a)}return this};c._updateFOV=function(b,a){var c={};this._fovCache[b+","+a]=c;var d=this._options.range;this._fov.compute(b,a,d,function(a,b,e,f){e=f*(1-e/d);0!=e&& +(c[a+","+b]=e)}.bind(this));return c};return d}();g.Util=oa;g.Color=pa;g.Text=G;g.RNG=r;g.Display=va;g.StringGenerator=wa;g.EventQueue=ja;g.Scheduler=U;g.FOV=H;g.Map=z;g.Noise=x;g.Path=C;g.Engine=D;g.Lighting=F;g.DEFAULT_WIDTH=80;g.DEFAULT_HEIGHT=25;g.DIRS=w;g.KEYS={VK_CANCEL:3,VK_HELP:6,VK_BACK_SPACE:8,VK_TAB:9,VK_CLEAR:12,VK_RETURN:13,VK_ENTER:14,VK_SHIFT:16,VK_CONTROL:17,VK_ALT:18,VK_PAUSE:19,VK_CAPS_LOCK:20,VK_ESCAPE:27,VK_SPACE:32,VK_PAGE_UP:33,VK_PAGE_DOWN:34,VK_END:35,VK_HOME:36,VK_LEFT:37, +VK_UP:38,VK_RIGHT:39,VK_DOWN:40,VK_PRINTSCREEN:44,VK_INSERT:45,VK_DELETE:46,VK_0:48,VK_1:49,VK_2:50,VK_3:51,VK_4:52,VK_5:53,VK_6:54,VK_7:55,VK_8:56,VK_9:57,VK_COLON:58,VK_SEMICOLON:59,VK_LESS_THAN:60,VK_EQUALS:61,VK_GREATER_THAN:62,VK_QUESTION_MARK:63,VK_AT:64,VK_A:65,VK_B:66,VK_C:67,VK_D:68,VK_E:69,VK_F:70,VK_G:71,VK_H:72,VK_I:73,VK_J:74,VK_K:75,VK_L:76,VK_M:77,VK_N:78,VK_O:79,VK_P:80,VK_Q:81,VK_R:82,VK_S:83,VK_T:84,VK_U:85,VK_V:86,VK_W:87,VK_X:88,VK_Y:89,VK_Z:90,VK_CONTEXT_MENU:93,VK_NUMPAD0:96, +VK_NUMPAD1:97,VK_NUMPAD2:98,VK_NUMPAD3:99,VK_NUMPAD4:100,VK_NUMPAD5:101,VK_NUMPAD6:102,VK_NUMPAD7:103,VK_NUMPAD8:104,VK_NUMPAD9:105,VK_MULTIPLY:106,VK_ADD:107,VK_SEPARATOR:108,VK_SUBTRACT:109,VK_DECIMAL:110,VK_DIVIDE:111,VK_F1:112,VK_F2:113,VK_F3:114,VK_F4:115,VK_F5:116,VK_F6:117,VK_F7:118,VK_F8:119,VK_F9:120,VK_F10:121,VK_F11:122,VK_F12:123,VK_F13:124,VK_F14:125,VK_F15:126,VK_F16:127,VK_F17:128,VK_F18:129,VK_F19:130,VK_F20:131,VK_F21:132,VK_F22:133,VK_F23:134,VK_F24:135,VK_NUM_LOCK:144,VK_SCROLL_LOCK:145, +VK_CIRCUMFLEX:160,VK_EXCLAMATION:161,VK_DOUBLE_QUOTE:162,VK_HASH:163,VK_DOLLAR:164,VK_PERCENT:165,VK_AMPERSAND:166,VK_UNDERSCORE:167,VK_OPEN_PAREN:168,VK_CLOSE_PAREN:169,VK_ASTERISK:170,VK_PLUS:171,VK_PIPE:172,VK_HYPHEN_MINUS:173,VK_OPEN_CURLY_BRACKET:174,VK_CLOSE_CURLY_BRACKET:175,VK_TILDE:176,VK_COMMA:188,VK_PERIOD:190,VK_SLASH:191,VK_BACK_QUOTE:192,VK_OPEN_BRACKET:219,VK_BACK_SLASH:220,VK_CLOSE_BRACKET:221,VK_QUOTE:222,VK_META:224,VK_ALTGR:225,VK_WIN:91,VK_KANA:21,VK_HANGUL:21,VK_EISU:22,VK_JUNJA:23, +VK_FINAL:24,VK_HANJA:25,VK_KANJI:25,VK_CONVERT:28,VK_NONCONVERT:29,VK_ACCEPT:30,VK_MODECHANGE:31,VK_SELECT:41,VK_PRINT:42,VK_EXECUTE:43,VK_SLEEP:95};Object.defineProperty(g,"__esModule",{value:!0})}); \ No newline at end of file |