chess-rules
Advanced tools
Comparing version 0.11.5 to 1.0.0
@@ -1,2 +0,1 @@ | ||
!function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;b="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,b.chessRules=a()}}(function(){var a;return function b(a,c,d){function e(g,h){if(!c[g]){if(!a[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};a[g][0].call(k.exports,function(b){var c=a[g][1][b];return e(c?c:b)},k,k.exports,b,a,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){function d(a){var b=function c(){return e.apply(c,arguments)};return b._styles=a,b.__proto__=n,b}function e(){var a=arguments,b=a.length,c=0!==b&&String(arguments[0]);if(b>1)for(var d=1;b>d;d++)c+=" "+a[d];if(!h.enabled||!c)return c;for(var e=this._styles,f=e.length;f--;){var g=i[e[f]];c=g.open+c.replace(g.closeRe,g.open)+g.close}return c}function f(a){for(var b in a)!function(b){h[b]=function(c){if("object"==typeof a[b]){var d=c;for(var e in a[b])d=h[a[b][e]](d);return d}return h[a[b]](c)}}(b)}function g(){var a={};return Object.keys(m).forEach(function(b){a[b]={get:function(){return d([b])}}}),a}var h={};b.exports=h,h.themes={};var i=h.styles=a("./styles"),j=Object.defineProperties;h.supportsColor=a("./system/supports-colors"),"undefined"==typeof h.enabled&&(h.enabled=h.supportsColor),h.stripColors=h.strip=function(a){return(""+a).replace(/\x1B\[\d+m/g,"")};var k=(h.stylize=function(a,b){return h.enabled?i[b].open+a+i[b].close:a+""},/[|\\{}()[\]^$+*?.]/g),l=function(a){if("string"!=typeof a)throw new TypeError("Expected a string");return a.replace(k,"\\$&")},m=function(){var a={};return i.grey=i.gray,Object.keys(i).forEach(function(b){i[b].closeRe=new RegExp(l(i[b].close),"g"),a[b]={get:function(){return d(this._styles.concat(b))}}}),a}(),n=j(function(){},m);h.setTheme=function(b){if("string"==typeof b)try{return h.themes[b]=a(b),f(h.themes[b]),h.themes[b]}catch(c){return console.log(c),c}else f(b)};var o=function(a,b){var c=b.split("");return c=c.map(a),c.join("")};h.trap=a("./custom/trap"),h.zalgo=a("./custom/zalgo"),h.maps={},h.maps.america=a("./maps/america"),h.maps.zebra=a("./maps/zebra"),h.maps.rainbow=a("./maps/rainbow"),h.maps.random=a("./maps/random");for(var p in h.maps)!function(a){h[a]=function(b){return o(h.maps[a],b)}}(p);j(h,g())},{"./custom/trap":2,"./custom/zalgo":3,"./maps/america":6,"./maps/rainbow":7,"./maps/random":8,"./maps/zebra":9,"./styles":10,"./system/supports-colors":11}],2:[function(a,b,c){b.exports=function(a,b){var c="";a=a||"Run the trap, drop the bass",a=a.split("");var d={a:["@","Ą","Ⱥ","Ʌ","Δ","Λ","Д"],b:["ß","Ɓ","Ƀ","ɮ","β","฿"],c:["©","Ȼ","Ͼ"],d:["Ð","Ɗ","Ԁ","ԁ","Ԃ","ԃ"],e:["Ë","ĕ","Ǝ","ɘ","Σ","ξ","Ҽ","੬"],f:["Ӻ"],g:["ɢ"],h:["Ħ","ƕ","Ң","Һ","Ӈ","Ԋ"],i:["༏"],j:["Ĵ"],k:["ĸ","Ҡ","Ӄ","Ԟ"],l:["Ĺ"],m:["ʍ","Ӎ","ӎ","Ԡ","ԡ","൩"],n:["Ñ","ŋ","Ɲ","Ͷ","Π","Ҋ"],o:["Ø","õ","ø","Ǿ","ʘ","Ѻ","ם","","๏"],p:["Ƿ","Ҏ"],q:["্"],r:["®","Ʀ","Ȑ","Ɍ","ʀ","Я"],s:["§","Ϟ","ϟ","Ϩ"],t:["Ł","Ŧ","ͳ"],u:["Ʊ","Ս"],v:["ט"],w:["Ш","Ѡ","Ѽ","൰"],x:["Ҳ","Ӿ","Ӽ","ӽ"],y:["¥","Ұ","Ӌ"],z:["Ƶ","ɀ"]};return a.forEach(function(a){a=a.toLowerCase();var b=d[a]||[" "],e=Math.floor(Math.random()*b.length);c+="undefined"!=typeof d[a]?d[a][e]:a}),c}},{}],3:[function(a,b,c){b.exports=function(a,b){function c(a){var b=Math.floor(Math.random()*a);return b}function d(a){var b=!1;return g.filter(function(c){b=c===a}),b}function e(a,b){var e,g,h="";b=b||{},b.up="undefined"!=typeof b.up?b.up:!0,b.mid="undefined"!=typeof b.mid?b.mid:!0,b.down="undefined"!=typeof b.down?b.down:!0,b.size="undefined"!=typeof b.size?b.size:"maxi",a=a.split("");for(g in a)if(!d(g)){switch(h+=a[g],e={up:0,down:0,mid:0},b.size){case"mini":e.up=c(8),e.mid=c(2),e.down=c(8);break;case"maxi":e.up=c(16)+3,e.mid=c(4)+1,e.down=c(64)+3;break;default:e.up=c(8)+1,e.mid=c(6)/2,e.down=c(8)+1}var i=["up","mid","down"];for(var j in i)for(var k=i[j],l=0;l<=e[k];l++)b[k]&&(h+=f[k][c(f[k].length)])}return h}a=a||" he is here ";var f={up:["̍","̎","̄","̅","̿","̑","̆","̐","͒","͗","͑","̇","̈","̊","͂","̓","̈","͊","͋","͌","̃","̂","̌","͐","̀","́","̋","̏","̒","̓","̔","̽","̉","ͣ","ͤ","ͥ","ͦ","ͧ","ͨ","ͩ","ͪ","ͫ","ͬ","ͭ","ͮ","ͯ","̾","͛","͆","̚"],down:["̖","̗","̘","̙","̜","̝","̞","̟","̠","̤","̥","̦","̩","̪","̫","̬","̭","̮","̯","̰","̱","̲","̳","̹","̺","̻","̼","ͅ","͇","͈","͉","͍","͎","͓","͔","͕","͖","͙","͚","̣"],mid:["̕","̛","̀","́","͘","̡","̢","̧","̨","̴","̵","̶","͜","͝","͞","͟","͠","͢","̸","̷","͡"," ҉"]},g=[].concat(f.up,f.down,f.mid);return e(a,b)}},{}],4:[function(a,b,c){var d=a("./colors");b.exports=function(){function b(a){var b=["__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__","charAt","constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf","charCodeAt","indexOf","lastIndexof","length","localeCompare","match","replace","search","slice","split","substring","toLocaleLowerCase","toLocaleUpperCase","toLowerCase","toUpperCase","trim","trimLeft","trimRight"];Object.keys(a).forEach(function(e){-1!==b.indexOf(e)?console.log("warn: ".red+("String.prototype"+e).magenta+" is probably something you don't want to override. Ignoring style name"):"string"==typeof a[e]?(d[e]=d[a[e]],c(e,function(){return d[a[e]](this)})):c(e,function(){for(var b=this,c=0;c<a[e].length;c++)b=d[a[e][c]](b);return b})})}var c=function(a,b){String.prototype.__defineGetter__(a,b)};c("strip",function(){return d.strip(this)}),c("stripColors",function(){return d.strip(this)}),c("trap",function(){return d.trap(this)}),c("zalgo",function(){return d.zalgo(this)}),c("zebra",function(){return d.zebra(this)}),c("rainbow",function(){return d.rainbow(this)}),c("random",function(){return d.random(this)}),c("america",function(){return d.america(this)});var e=Object.keys(d.styles);e.forEach(function(a){c(a,function(){return d.stylize(this,a)})}),d.setTheme=function(c){if("string"==typeof c)try{return d.themes[c]=a(c),b(d.themes[c]),d.themes[c]}catch(e){return console.log(e),e}else b(c)}}},{"./colors":1}],5:[function(a,b,c){var d=a("./colors");b.exports=d,a("./extendStringPrototype")()},{"./colors":1,"./extendStringPrototype":4}],6:[function(a,b,c){var d=a("../colors");b.exports=function(){return function(a,b,c){if(" "===a)return a;switch(b%3){case 0:return d.red(a);case 1:return d.white(a);case 2:return d.blue(a)}}}()},{"../colors":1}],7:[function(a,b,c){var d=a("../colors");b.exports=function(){var a=["red","yellow","green","blue","magenta"];return function(b,c,e){return" "===b?b:d[a[c++%a.length]](b)}}()},{"../colors":1}],8:[function(a,b,c){var d=a("../colors");b.exports=function(){var a=["underline","inverse","grey","yellow","red","green","blue","white","cyan","magenta"];return function(b,c,e){return" "===b?b:d[a[Math.round(Math.random()*(a.length-1))]](b)}}()},{"../colors":1}],9:[function(a,b,c){var d=a("../colors");b.exports=function(a,b,c){return b%2===0?a:d.inverse(a)}},{"../colors":1}],10:[function(a,b,c){var d={};b.exports=d;var e={reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29],black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39],grey:[90,39],bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],blackBG:[40,49],redBG:[41,49],greenBG:[42,49],yellowBG:[43,49],blueBG:[44,49],magentaBG:[45,49],cyanBG:[46,49],whiteBG:[47,49]};Object.keys(e).forEach(function(a){var b=e[a],c=d[a]=[];c.open="["+b[0]+"m",c.close="["+b[1]+"m"})},{}],11:[function(a,b,c){(function(a){var c=a.argv;b.exports=function(){return-1!==c.indexOf("--no-color")||-1!==c.indexOf("--color=false")?!1:-1!==c.indexOf("--color")||-1!==c.indexOf("--color=true")||-1!==c.indexOf("--color=always")?!0:a.stdout&&!a.stdout.isTTY?!1:"win32"===a.platform?!0:"COLORTERM"in a.env?!0:"dumb"===a.env.TERM?!1:!!/^screen|^xterm|^vt100|color|ansi|cygwin|linux/i.test(a.env.TERM)}()}).call(this,a("_process"))},{_process:12}],12:[function(a,b,c){function d(){k=!1,h.length?j=h.concat(j):l=-1,j.length&&e()}function e(){if(!k){var a=setTimeout(d);k=!0;for(var b=j.length;b;){for(h=j,j=[];++l<b;)h&&h[l].run();l=-1,b=j.length}h=null,k=!1,clearTimeout(a)}}function f(a,b){this.fun=a,this.array=b}function g(){}var h,i=b.exports={},j=[],k=!1,l=-1;i.nextTick=function(a){var b=new Array(arguments.length-1);if(arguments.length>1)for(var c=1;c<arguments.length;c++)b[c-1]=arguments[c];j.push(new f(a,b)),1!==j.length||k||setTimeout(e,0)},f.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=g,i.addListener=g,i.once=g,i.off=g,i.removeListener=g,i.removeAllListeners=g,i.emit=g,i.binding=function(a){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(a){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},{}],13:[function(a,b,c){(function(c){(function(){var d,e,f,g,h,i,j,k,l=[].slice;k=a("underscore"),f={cmd:"⌘",ctrl:"⌃",alt:"⌥",option:"⌥",shift:"⇧",enter:"⏎",left:"←",right:"→",up:"↑",down:"↓"},g={cmd:"Cmd",ctrl:"Ctrl",alt:"Alt",option:"Alt",shift:"Shift",enter:"Enter",left:"Left",right:"Right",up:"Up",down:"Down"},i={"~":"`",_:"-","+":"=","|":"\\","{":"[","}":"]",":":";",'"':"'","<":",",">":".","?":"/"},j=function(a){var b,c,d,e,f,g;if(e=0,d=[],null==a)return d;for(c=f=0,g=a.length;g>f;c=++f)b=a[c],"."!==b||0!==c&&"\\"===a[c-1]||(d.push(a.substring(e,c)),e=c+1);return d.push(a.substr(e,a.length)),d},e=function(a){return k.isObject(a)&&!k.isArray(a)},h={adviseBefore:function(a,b,c){var d;return d=a[b],a[b]=function(){var a;return a=1<=arguments.length?l.call(arguments,0):[],c.apply(this,a)!==!1?d.apply(this,a):void 0}},camelize:function(a){return a?a.replace(/[_-]+(\w)/g,function(a){return a[1].toUpperCase()}):""},capitalize:function(a){return a?"github"===a.toLowerCase()?"GitHub":a[0].toUpperCase()+a.slice(1):""},compactObject:function(a){var b,c,d;c={};for(b in a)d=a[b],null!=d&&(c[b]=d);return c},dasherize:function(a){return a?(a=a[0].toLowerCase()+a.slice(1),a.replace(/([A-Z])|(_)/g,function(a,b){return b?"-"+b.toLowerCase():"-"})):""},deepClone:function(a){return k.isArray(a)?a.map(function(a){return h.deepClone(a)}):k.isObject(a)&&!k.isFunction(a)?h.mapObject(a,function(a){return function(a,b){return[a,h.deepClone(b)]}}(this)):a},deepExtend:function(a){var b,c,d,f,g,i,j;for(f=a,b=0;++b<arguments.length;)if(d=arguments[b],e(f)&&e(d))for(j=Object.keys(d),g=0,i=j.length;i>g;g++)c=j[g],f[c]=h.deepExtend(f[c],d[c]);else f=h.deepClone(d);return f},deepContains:function(a,b){var c,d,e;if(null==a)return!1;for(d=0,e=a.length;e>d;d++)if(c=a[d],k.isEqual(c,b))return!0;return!1},endsWith:function(a,b){return null==b&&(b=""),a?-1!==a.indexOf(b,a.length-b.length):!1},escapeAttribute:function(a){return a?a.replace(/"/g,""").replace(/\n/g,"").replace(/\\/g,"-"):""},escapeRegExp:function(a){return a?a.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"):""},humanizeEventName:function(a,b){var c,d,e,f;return f=a.split(":"),d=f[0],c=f[1],null==c?h.undasherize(d):(e=h.undasherize(d),null==b&&(b=h.undasherize(c)),""+e+": "+b)},humanizeKey:function(a,b){var d;return null==b&&(b=c.platform),a?(d="darwin"===b?f:g,d[a]?d[a]:1===a.length&&null!=i[a]?[d.shift,i[a]]:1===a.length&&a===a.toUpperCase()&&a.toUpperCase()!==a.toLowerCase()?[d.shift,a.toUpperCase()]:1===a.length||/f[0-9]{1,2}/.test(a)?a.toUpperCase():"darwin"===b?a:h.capitalize(a)):a},humanizeKeystroke:function(a,b){var d,e,f,g,i,j,l,m,n,o;if(null==b&&(b=c.platform),!a)return a;for(i=a.split(" "),d=[],l=0,n=i.length;n>l;l++){for(a=i[l],g=[],j=a.split("-"),e=m=0,o=j.length;o>m;e=++m)f=j[e],""===f&&""===j[e-1]&&(f="-"),f&&g.push(h.humanizeKey(f,b));g=k.uniq(k.flatten(g)),g="darwin"===b?g.join(""):g.join("+"),d.push(g)}return d.join(" ")},isSubset:function(a,b){return k.every(a,function(a){return k.include(b,a)})},losslessInvert:function(a){var b,c,d;b={};for(c in a)d=a[c],null==b[d]&&(b[d]=[]),b[d].push(c);return b},mapObject:function(a,b){var c,d,e,f,g,h,i;for(d={},h=Object.keys(a),f=0,g=h.length;g>f;f++)c=h[f],i=b(c,a[c]),c=i[0],e=i[1],d[c]=e;return d},multiplyString:function(a,b){var c,d;for(c="",d=0;b>d;)c+=a,d++;return c},pluralize:function(a,b,c){return null==a&&(a=0),null==c&&(c=b+"s"),1===a?""+a+" "+b:""+a+" "+c},remove:function(a,b){var c;return c=a.indexOf(b),c>=0&&a.splice(c,1),a},setValueForKeyPath:function(a,b,c){var d,e;for(e=j(b);e.length>1;)d=e.shift(),null==a[d]&&(a[d]={}),a=a[d];return null!=c?a[e.shift()]=c:delete a[e.shift()]},hasKeyPath:function(a,b){var c,d,e,f;for(d=j(b),e=0,f=d.length;f>e;e++){if(c=d[e],!a.hasOwnProperty(c))return!1;a=a[c]}return!0},spliceWithArray:function(a,b,c,d,e){var f,g,h,i;if(null==e&&(e=1e5),d.length<e)return a.splice.apply(a,[b,c].concat(l.call(d)));for(a.splice(b,c),i=[],f=g=0,h=d.length;e>0?h>=g:g>=h;f=g+=e)i.push(a.splice.apply(a,[b+f,0].concat(l.call(d.slice(f,f+e)))));return i},sum:function(a){var b,c,d,e;for(c=0,d=0,e=a.length;e>d;d++)b=a[d],c+=b;return c},uncamelcase:function(a){var b;return a?(b=a.replace(/([A-Z])|_+/g,function(a,b){return null==b&&(b="")," "+b}),h.capitalize(b.trim())):""},undasherize:function(a){return a?a.split("-").map(h.capitalize).join(" "):""},underscore:function(a){return a?(a=a[0].toLowerCase()+a.slice(1),a.replace(/([A-Z])|-+/g,function(a,b){return null==b&&(b=""),"_"+b.toLowerCase()})):""},valueForKeyPath:function(a,b){var c,d,e,f;for(d=j(b),e=0,f=d.length;f>e;e++)if(c=d[e],a=a[c],null==a)return;return a},isEqual:function(a,b,c,e){return k.isArray(c)&&k.isArray(e)?d(a,b,c,e):d(a,b)},isEqualForProperties:function(){var a,b,c,d,e,f;for(a=arguments[0],b=arguments[1],c=3<=arguments.length?l.call(arguments,2):[],e=0,f=c.length;f>e;e++)if(d=c[e],!k.isEqual(a[d],b[d]))return!1;return!0}},d=function(a,b,c,e){var f,g,h,i,j,l,m,n,o,p,q,r,s,t,u;if(null==c&&(c=[]),null==e&&(e=[]),a===b)return k.isEqual(a,b);if(k.isFunction(a)||k.isFunction(b))return k.isEqual(a,b);for(s=c.length;s--;)if(c[s]===a)return e[s]===b;if(c.push(a),e.push(b),p=!1,k.isFunction(null!=a?a.isEqual:void 0))p=a.isEqual(b,c,e);else if(k.isFunction(null!=b?b.isEqual:void 0))p=b.isEqual(a,e,c);else if(k.isArray(a)&&k.isArray(b)&&a.length===b.length){for(p=!0,q=t=0,u=a.length;u>t;q=++t)if(h=a[q],!d(h,b[q],c,e)){p=!1;break}}else if(k.isRegExp(a)&&k.isRegExp(b))p=k.isEqual(a,b);else if(k.isElement(a)&&k.isElement(b))p=a===b;else if(k.isObject(a)&&k.isObject(b))if(f=a.constructor,l=b.constructor,g=k.isFunction(f)&&f instanceof f,m=k.isFunction(l)&&l instanceof l,f===l||g&&m){i=0,p=!0;for(r in a)if(j=a[r],k.has(a,r)&&(i++,!k.has(b,r)||!d(j,b[r],c,e))){p=!1;break}if(p){n=0;for(r in b)o=b[r],k.has(b,r)&&n++;p=i===n}}else p=!1;else p=k.isEqual(a,b);return c.pop(),e.pop(),p},b.exports=k.extend({},k,h)}).call(this)}).call(this,a("_process"))},{_process:12,underscore:14}],14:[function(b,c,d){(function(){var b=this,e=b._,f={},g=Array.prototype,h=Object.prototype,i=Function.prototype,j=g.push,k=g.slice,l=g.concat,m=h.toString,n=h.hasOwnProperty,o=g.forEach,p=g.map,q=g.reduce,r=g.reduceRight,s=g.filter,t=g.every,u=g.some,v=g.indexOf,w=g.lastIndexOf,x=Array.isArray,y=Object.keys,z=i.bind,A=function(a){return a instanceof A?a:this instanceof A?void(this._wrapped=a):new A(a)};"undefined"!=typeof d?("undefined"!=typeof c&&c.exports&&(d=c.exports=A),d._=A):b._=A,A.VERSION="1.6.0";var B=A.each=A.forEach=function(a,b,c){if(null==a)return a;if(o&&a.forEach===o)a.forEach(b,c);else if(a.length===+a.length){for(var d=0,e=a.length;e>d;d++)if(b.call(c,a[d],d,a)===f)return}else for(var g=A.keys(a),d=0,e=g.length;e>d;d++)if(b.call(c,a[g[d]],g[d],a)===f)return;return a};A.map=A.collect=function(a,b,c){var d=[];return null==a?d:p&&a.map===p?a.map(b,c):(B(a,function(a,e,f){d.push(b.call(c,a,e,f))}),d)};var C="Reduce of empty array with no initial value";A.reduce=A.foldl=A.inject=function(a,b,c,d){var e=arguments.length>2;if(null==a&&(a=[]),q&&a.reduce===q)return d&&(b=A.bind(b,d)),e?a.reduce(b,c):a.reduce(b);if(B(a,function(a,f,g){e?c=b.call(d,c,a,f,g):(c=a,e=!0)}),!e)throw new TypeError(C);return c},A.reduceRight=A.foldr=function(a,b,c,d){var e=arguments.length>2;if(null==a&&(a=[]),r&&a.reduceRight===r)return d&&(b=A.bind(b,d)),e?a.reduceRight(b,c):a.reduceRight(b);var f=a.length;if(f!==+f){var g=A.keys(a);f=g.length}if(B(a,function(h,i,j){i=g?g[--f]:--f,e?c=b.call(d,c,a[i],i,j):(c=a[i],e=!0)}),!e)throw new TypeError(C);return c},A.find=A.detect=function(a,b,c){var d;return D(a,function(a,e,f){return b.call(c,a,e,f)?(d=a,!0):void 0}),d},A.filter=A.select=function(a,b,c){var d=[];return null==a?d:s&&a.filter===s?a.filter(b,c):(B(a,function(a,e,f){b.call(c,a,e,f)&&d.push(a)}),d)},A.reject=function(a,b,c){return A.filter(a,function(a,d,e){return!b.call(c,a,d,e)},c)},A.every=A.all=function(a,b,c){b||(b=A.identity);var d=!0;return null==a?d:t&&a.every===t?a.every(b,c):(B(a,function(a,e,g){return(d=d&&b.call(c,a,e,g))?void 0:f}),!!d)};var D=A.some=A.any=function(a,b,c){b||(b=A.identity);var d=!1;return null==a?d:u&&a.some===u?a.some(b,c):(B(a,function(a,e,g){return d||(d=b.call(c,a,e,g))?f:void 0}),!!d)};A.contains=A.include=function(a,b){return null==a?!1:v&&a.indexOf===v?-1!=a.indexOf(b):D(a,function(a){return a===b})},A.invoke=function(a,b){var c=k.call(arguments,2),d=A.isFunction(b);return A.map(a,function(a){return(d?b:a[b]).apply(a,c)})},A.pluck=function(a,b){return A.map(a,A.property(b))},A.where=function(a,b){return A.filter(a,A.matches(b))},A.findWhere=function(a,b){return A.find(a,A.matches(b))},A.max=function(a,b,c){if(!b&&A.isArray(a)&&a[0]===+a[0]&&a.length<65535)return Math.max.apply(Math,a);var d=-(1/0),e=-(1/0);return B(a,function(a,f,g){var h=b?b.call(c,a,f,g):a;h>e&&(d=a,e=h)}),d},A.min=function(a,b,c){if(!b&&A.isArray(a)&&a[0]===+a[0]&&a.length<65535)return Math.min.apply(Math,a);var d=1/0,e=1/0;return B(a,function(a,f,g){var h=b?b.call(c,a,f,g):a;e>h&&(d=a,e=h)}),d},A.shuffle=function(a){var b,c=0,d=[];return B(a,function(a){b=A.random(c++),d[c-1]=d[b],d[b]=a}),d},A.sample=function(a,b,c){return null==b||c?(a.length!==+a.length&&(a=A.values(a)),a[A.random(a.length-1)]):A.shuffle(a).slice(0,Math.max(0,b))};var E=function(a){return null==a?A.identity:A.isFunction(a)?a:A.property(a)};A.sortBy=function(a,b,c){return b=E(b),A.pluck(A.map(a,function(a,d,e){return{value:a,index:d,criteria:b.call(c,a,d,e)}}).sort(function(a,b){var c=a.criteria,d=b.criteria;if(c!==d){if(c>d||void 0===c)return 1;if(d>c||void 0===d)return-1}return a.index-b.index}),"value")};var F=function(a){return function(b,c,d){var e={};return c=E(c),B(b,function(f,g){var h=c.call(d,f,g,b);a(e,h,f)}),e}};A.groupBy=F(function(a,b,c){A.has(a,b)?a[b].push(c):a[b]=[c]}),A.indexBy=F(function(a,b,c){a[b]=c}),A.countBy=F(function(a,b){A.has(a,b)?a[b]++:a[b]=1}),A.sortedIndex=function(a,b,c,d){c=E(c);for(var e=c.call(d,b),f=0,g=a.length;g>f;){var h=f+g>>>1;c.call(d,a[h])<e?f=h+1:g=h}return f},A.toArray=function(a){return a?A.isArray(a)?k.call(a):a.length===+a.length?A.map(a,A.identity):A.values(a):[]},A.size=function(a){return null==a?0:a.length===+a.length?a.length:A.keys(a).length},A.first=A.head=A.take=function(a,b,c){return null!=a?null==b||c?a[0]:0>b?[]:k.call(a,0,b):void 0},A.initial=function(a,b,c){return k.call(a,0,a.length-(null==b||c?1:b))},A.last=function(a,b,c){return null!=a?null==b||c?a[a.length-1]:k.call(a,Math.max(a.length-b,0)):void 0},A.rest=A.tail=A.drop=function(a,b,c){return k.call(a,null==b||c?1:b)},A.compact=function(a){return A.filter(a,A.identity)};var G=function(a,b,c){return b&&A.every(a,A.isArray)?l.apply(c,a):(B(a,function(a){A.isArray(a)||A.isArguments(a)?b?j.apply(c,a):G(a,b,c):c.push(a)}),c)};A.flatten=function(a,b){return G(a,b,[])},A.without=function(a){return A.difference(a,k.call(arguments,1))},A.partition=function(a,b){var c=[],d=[];return B(a,function(a){(b(a)?c:d).push(a)}),[c,d]},A.uniq=A.unique=function(a,b,c,d){A.isFunction(b)&&(d=c,c=b,b=!1);var e=c?A.map(a,c,d):a,f=[],g=[];return B(e,function(c,d){(b?d&&g[g.length-1]===c:A.contains(g,c))||(g.push(c),f.push(a[d]))}),f},A.union=function(){return A.uniq(A.flatten(arguments,!0))},A.intersection=function(a){var b=k.call(arguments,1);return A.filter(A.uniq(a),function(a){return A.every(b,function(b){return A.contains(b,a)})})},A.difference=function(a){var b=l.apply(g,k.call(arguments,1));return A.filter(a,function(a){return!A.contains(b,a)})},A.zip=function(){for(var a=A.max(A.pluck(arguments,"length").concat(0)),b=new Array(a),c=0;a>c;c++)b[c]=A.pluck(arguments,""+c);return b},A.object=function(a,b){if(null==a)return{};for(var c={},d=0,e=a.length;e>d;d++)b?c[a[d]]=b[d]:c[a[d][0]]=a[d][1];return c},A.indexOf=function(a,b,c){if(null==a)return-1;var d=0,e=a.length;if(c){if("number"!=typeof c)return d=A.sortedIndex(a,b),a[d]===b?d:-1;d=0>c?Math.max(0,e+c):c}if(v&&a.indexOf===v)return a.indexOf(b,c);for(;e>d;d++)if(a[d]===b)return d;return-1},A.lastIndexOf=function(a,b,c){if(null==a)return-1;var d=null!=c;if(w&&a.lastIndexOf===w)return d?a.lastIndexOf(b,c):a.lastIndexOf(b);for(var e=d?c:a.length;e--;)if(a[e]===b)return e;return-1},A.range=function(a,b,c){arguments.length<=1&&(b=a||0,a=0),c=arguments[2]||1;for(var d=Math.max(Math.ceil((b-a)/c),0),e=0,f=new Array(d);d>e;)f[e++]=a,a+=c;return f};var H=function(){};A.bind=function(a,b){var c,d;if(z&&a.bind===z)return z.apply(a,k.call(arguments,1));if(!A.isFunction(a))throw new TypeError;return c=k.call(arguments,2),d=function(){if(!(this instanceof d))return a.apply(b,c.concat(k.call(arguments)));H.prototype=a.prototype;var e=new H;H.prototype=null;var f=a.apply(e,c.concat(k.call(arguments)));return Object(f)===f?f:e}},A.partial=function(a){var b=k.call(arguments,1);return function(){for(var c=0,d=b.slice(),e=0,f=d.length;f>e;e++)d[e]===A&&(d[e]=arguments[c++]);for(;c<arguments.length;)d.push(arguments[c++]);return a.apply(this,d)}},A.bindAll=function(a){var b=k.call(arguments,1);if(0===b.length)throw new Error("bindAll must be passed function names");return B(b,function(b){a[b]=A.bind(a[b],a)}),a},A.memoize=function(a,b){var c={};return b||(b=A.identity),function(){var d=b.apply(this,arguments);return A.has(c,d)?c[d]:c[d]=a.apply(this,arguments)}},A.delay=function(a,b){var c=k.call(arguments,2);return setTimeout(function(){return a.apply(null,c)},b)},A.defer=function(a){return A.delay.apply(A,[a,1].concat(k.call(arguments,1)))},A.throttle=function(a,b,c){var d,e,f,g=null,h=0;c||(c={});var i=function(){h=c.leading===!1?0:A.now(),g=null,f=a.apply(d,e),d=e=null};return function(){var j=A.now();h||c.leading!==!1||(h=j);var k=b-(j-h);return d=this,e=arguments,0>=k?(clearTimeout(g),g=null,h=j,f=a.apply(d,e),d=e=null):g||c.trailing===!1||(g=setTimeout(i,k)),f}},A.debounce=function(a,b,c){var d,e,f,g,h,i=function(){var j=A.now()-g;b>j?d=setTimeout(i,b-j):(d=null,c||(h=a.apply(f,e),f=e=null))};return function(){f=this,e=arguments,g=A.now();var j=c&&!d;return d||(d=setTimeout(i,b)),j&&(h=a.apply(f,e),f=e=null),h}},A.once=function(a){var b,c=!1;return function(){return c?b:(c=!0,b=a.apply(this,arguments),a=null,b)}},A.wrap=function(a,b){return A.partial(b,a)},A.compose=function(){var a=arguments;return function(){for(var b=arguments,c=a.length-1;c>=0;c--)b=[a[c].apply(this,b)];return b[0]}},A.after=function(a,b){return function(){return--a<1?b.apply(this,arguments):void 0}},A.keys=function(a){if(!A.isObject(a))return[];if(y)return y(a);var b=[];for(var c in a)A.has(a,c)&&b.push(c);return b},A.values=function(a){for(var b=A.keys(a),c=b.length,d=new Array(c),e=0;c>e;e++)d[e]=a[b[e]];return d},A.pairs=function(a){for(var b=A.keys(a),c=b.length,d=new Array(c),e=0;c>e;e++)d[e]=[b[e],a[b[e]]];return d},A.invert=function(a){for(var b={},c=A.keys(a),d=0,e=c.length;e>d;d++)b[a[c[d]]]=c[d];return b},A.functions=A.methods=function(a){var b=[];for(var c in a)A.isFunction(a[c])&&b.push(c);return b.sort()},A.extend=function(a){return B(k.call(arguments,1),function(b){if(b)for(var c in b)a[c]=b[c]}),a},A.pick=function(a){var b={},c=l.apply(g,k.call(arguments,1));return B(c,function(c){c in a&&(b[c]=a[c])}),b},A.omit=function(a){var b={},c=l.apply(g,k.call(arguments,1));for(var d in a)A.contains(c,d)||(b[d]=a[d]);return b},A.defaults=function(a){return B(k.call(arguments,1),function(b){if(b)for(var c in b)void 0===a[c]&&(a[c]=b[c])}),a},A.clone=function(a){return A.isObject(a)?A.isArray(a)?a.slice():A.extend({},a):a},A.tap=function(a,b){return b(a),a};var I=function(a,b,c,d){if(a===b)return 0!==a||1/a==1/b;if(null==a||null==b)return a===b;a instanceof A&&(a=a._wrapped),b instanceof A&&(b=b._wrapped);var e=m.call(a);if(e!=m.call(b))return!1;switch(e){case"[object String]":return a==String(b);case"[object Number]":return a!=+a?b!=+b:0==a?1/a==1/b:a==+b;case"[object Date]":case"[object Boolean]":return+a==+b;case"[object RegExp]":return a.source==b.source&&a.global==b.global&&a.multiline==b.multiline&&a.ignoreCase==b.ignoreCase}if("object"!=typeof a||"object"!=typeof b)return!1;for(var f=c.length;f--;)if(c[f]==a)return d[f]==b;var g=a.constructor,h=b.constructor;if(g!==h&&!(A.isFunction(g)&&g instanceof g&&A.isFunction(h)&&h instanceof h)&&"constructor"in a&&"constructor"in b)return!1;c.push(a),d.push(b);var i=0,j=!0;if("[object Array]"==e){if(i=a.length,j=i==b.length)for(;i--&&(j=I(a[i],b[i],c,d)););}else{for(var k in a)if(A.has(a,k)&&(i++,!(j=A.has(b,k)&&I(a[k],b[k],c,d))))break;if(j){for(k in b)if(A.has(b,k)&&!i--)break;j=!i}}return c.pop(),d.pop(),j};A.isEqual=function(a,b){return I(a,b,[],[])},A.isEmpty=function(a){if(null==a)return!0;if(A.isArray(a)||A.isString(a))return 0===a.length;for(var b in a)if(A.has(a,b))return!1;return!0},A.isElement=function(a){return!(!a||1!==a.nodeType)},A.isArray=x||function(a){return"[object Array]"==m.call(a)},A.isObject=function(a){return a===Object(a)},B(["Arguments","Function","String","Number","Date","RegExp"],function(a){A["is"+a]=function(b){return m.call(b)=="[object "+a+"]"}}),A.isArguments(arguments)||(A.isArguments=function(a){return!(!a||!A.has(a,"callee"))}),"function"!=typeof/./&&(A.isFunction=function(a){return"function"==typeof a}),A.isFinite=function(a){return isFinite(a)&&!isNaN(parseFloat(a))},A.isNaN=function(a){return A.isNumber(a)&&a!=+a},A.isBoolean=function(a){return a===!0||a===!1||"[object Boolean]"==m.call(a)},A.isNull=function(a){return null===a},A.isUndefined=function(a){return void 0===a},A.has=function(a,b){return n.call(a,b)},A.noConflict=function(){return b._=e,this},A.identity=function(a){return a},A.constant=function(a){return function(){return a}},A.property=function(a){return function(b){return b[a]}},A.matches=function(a){return function(b){if(b===a)return!0;for(var c in a)if(a[c]!==b[c])return!1;return!0}},A.times=function(a,b,c){for(var d=Array(Math.max(0,a)),e=0;a>e;e++)d[e]=b.call(c,e);return d},A.random=function(a,b){return null==b&&(b=a,a=0),a+Math.floor(Math.random()*(b-a+1))},A.now=Date.now||function(){return(new Date).getTime()};var J={escape:{"&":"&","<":"<",">":">",'"':""","'":"'"}};J.unescape=A.invert(J.escape);var K={escape:new RegExp("["+A.keys(J.escape).join("")+"]","g"),unescape:new RegExp("("+A.keys(J.unescape).join("|")+")","g")};A.each(["escape","unescape"],function(a){A[a]=function(b){return null==b?"":(""+b).replace(K[a],function(b){return J[a][b]})}}),A.result=function(a,b){if(null!=a){var c=a[b];return A.isFunction(c)?c.call(a):c}},A.mixin=function(a){B(A.functions(a),function(b){var c=A[b]=a[b];A.prototype[b]=function(){var a=[this._wrapped];return j.apply(a,arguments),P.call(this,c.apply(A,a))}})};var L=0;A.uniqueId=function(a){var b=++L+"";return a?a+b:b},A.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var M=/(.)^/,N={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},O=/\\|'|\r|\n|\t|\u2028|\u2029/g;A.template=function(a,b,c){var d;c=A.defaults({},c,A.templateSettings);var e=new RegExp([(c.escape||M).source,(c.interpolate||M).source,(c.evaluate||M).source].join("|")+"|$","g"),f=0,g="__p+='";a.replace(e,function(b,c,d,e,h){return g+=a.slice(f,h).replace(O,function(a){return"\\"+N[a]}),c&&(g+="'+\n((__t=("+c+"))==null?'':_.escape(__t))+\n'"),d&&(g+="'+\n((__t=("+d+"))==null?'':__t)+\n'"),e&&(g+="';\n"+e+"\n__p+='"),f=h+b.length,b}),g+="';\n",c.variable||(g="with(obj||{}){\n"+g+"}\n"),g="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+g+"return __p;\n";try{d=new Function(c.variable||"obj","_",g)}catch(h){throw h.source=g,h}if(b)return d(b,A);var i=function(a){return d.call(this,a,A)};return i.source="function("+(c.variable||"obj")+"){\n"+g+"}",i},A.chain=function(a){return A(a).chain()};var P=function(a){return this._chain?A(a).chain():a};A.mixin(A),B(["pop","push","reverse","shift","sort","splice","unshift"],function(a){var b=g[a];A.prototype[a]=function(){var c=this._wrapped;return b.apply(c,arguments),"shift"!=a&&"splice"!=a||0!==c.length||delete c[0],P.call(this,c)}}),B(["concat","join","slice"],function(a){var b=g[a];A.prototype[a]=function(){return P.call(this,b.apply(this._wrapped,arguments))}}),A.extend(A.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}}),"function"==typeof a&&a.amd&&a("underscore",[],function(){return A})}).call(this)},{}],15:[function(a,b,c){"use strict";function d(a,b){void 0===b?(this.offset=a,this.x=this.offset%8,this.y=Math.floor(this.offset/8)):(this.offset=a+8*b,this.x=a,this.y=b)}d.prototype.add=function(a){return new d(this.x+a.x,this.y+a.y)},d.prototype.sub=function(a){return new d(this.x-a.x,this.y-a.y)},d.prototype.isValid=function(){return this.x>=0&&this.x<8&&this.y>=0&&this.y<8},b.exports={BoardCoordinates:d}},{}],16:[function(a,b,c){"use strict";function d(a,b,c){for(var d=c?c:a.turn,e=[],g=0;64>g;g++){var h=a.board[g];null!=h&&h.type===b&&h.side===d&&e.push(g)}var i=[];return e.forEach(function(a){i.push(new f(a))}),i}var e=a("./coordinates"),f=e.BoardCoordinates;b.exports={findPiece:d}},{"./coordinates":15}],17:[function(a,b,c){"use strict";function d(a,b){return b.isValid()&&null==a.board[b.offset]}function e(a,b){if(!b.isValid())return!1;var c=a.board[b.offset];return null!=c&&a.turn!==c.side}function f(a,b){if(!b.isValid())return!1;var c=a.board[b.offset];return null==c||a.turn!==c.side}function g(a,b,c,f){for(var g=b;;){if(g=g.add(c),!g.isValid())break;if(!d(a,g)){e(a,g)&&f.push(g);break}f.push(g)}}function h(a){for(var b=[],c=0;64>=c;c++){var d=a.board[c],e=new i(c);if(null!=d&&d.side===a.turn){var f=j[d.type](a,e);f.forEach(function(a){b.push({src:e.offset,dst:a.offset})})}}return b}var i=a("./coordinates").BoardCoordinates,j=[];j.P=function(a,b){var c="W"==a.turn?1:-1,f="W"==a.turn?1:6,g=b.add(new i(0,c)),h=g.add(new i(0,c)),j=b.add(new i(1,c)),k=b.add(new i(-1,c)),l=[];return d(a,g)&&l.push(g),e(a,k)?l.push(k):a.lastPawnMoveColumn==b.x-1&&(b.y-f)/c==3&&l.push(k),e(a,j)?l.push(j):a.lastPawnMoveColumn==b.x+1&&(b.y-f)/c==3&&l.push(j),b.y==f&&d(a,g)&&d(a,h)&&l.push(h),l},j.N=function(a,b){var c=[];return[b.add(new i(-1,2)),b.add(new i(1,2)),b.add(new i(2,-1)),b.add(new i(2,1)),b.add(new i(1,-2)),b.add(new i(-1,-2)),b.add(new i(-2,1)),b.add(new i(-2,-1))].forEach(function(b){f(a,b)&&c.push(b)}),c},j.B=function(a,b){var c=[];return[new i(-1,-1),new i(-1,1),new i(1,-1),new i(1,1)].forEach(function(d){g(a,b,d,c)}),c},j.R=function(a,b){var c=[];return[new i(-1,0),new i(1,0),new i(0,-1),new i(0,1)].forEach(function(d){g(a,b,d,c)}),c},j.K=function(a,b){for(var c=[],e=-1;2>e;e++)for(var g=-1;2>g;g++)if(0!=e||0!=g){var h=new i(e,g),j=b.add(h);f(a,j)&&c.push(j)}if(a.castlingFlags[a.turn].K){var k=b.add(new i(1,0)),l=b.add(new i(2,0));d(a,k)&&d(a,l)&&c.push(l)}if(a.castlingFlags[a.turn].Q){var k=b.add(new i(-1,0)),l=b.add(new i(-2,0));d(a,k)&&d(a,l)&&c.push(l); | ||
}return c},j.Q=function(a,b){var c=[];return[new i(-1,0),new i(1,0),new i(0,-1),new i(0,1),new i(-1,-1),new i(-1,1),new i(1,-1),new i(1,1)].forEach(function(d){g(a,b,d,c)}),c},b.exports={computeAllMoves:h,pieceDestinationsEvaluator:j}},{"./coordinates":15}],18:[function(a,b,c){"use strict";function d(a,b,c){for(var d=null,e=0;64>e;e++){var f=a.board[e];if(null!=f&&f.type===b&&f.side===c){d=e;break}}return d}function e(a,b){if(1!=b){var c=0;if(a.board.forEach(function(a){null!=a&&(c+=1)}),2==c)return[]}var e=i.computeAllMoves(a),f=[],g=function(b,c,e){var f=h.applyMove(a,b),g=i.computeAllMoves(f),j=d(f,c,e),k=!1;return g.forEach(function(a){a.dst==j&&(k=!0)}),k};return e.forEach(function(b){var c=new j(b.src),d=new j(b.dst),e=d.sub(c),h=g(b,"K",a.turn);"K"==a.board[b.src].type&&2==e.x&&(h=h||a.check||g({src:b.src,dst:b.src+1},"K",a.turn)),"K"==a.board[b.src].type&&-2==e.x&&(h=h||a.check||g({src:b.src,dst:b.src-1},"K",a.turn)),h||f.push(b)}),f}function f(a){var b=!1,c=a.turn;a.turn="W"===c?"B":"W";for(var d=0;64>=d;d++){var e=a.board[d],f=new j(d);if(null!=e&&e.side===a.turn){var g=i.pieceDestinationsEvaluator[e.type](a,f);g.forEach(function(c){var d=a.board[c.offset];d&&"K"===d.type&&d.side!==a.turn&&(b=!0)})}}return a.turn=c,b}var g=a("./coordinates"),h=a("./updates"),i=a("./moves-pieces"),j=g.BoardCoordinates;b.exports={getAvailableMoves:e,isCurrentPlayerInCheck:f}},{"./coordinates":15,"./moves-pieces":17,"./updates":24}],19:[function(a,b,c){"use strict";function d(a){var b="";return b+=String.fromCharCode("a".charCodeAt(0)+a%8),b+=String.fromCharCode("1".charCodeAt(0)+Math.floor(a/8))}function e(a,b){var c=null,d=j[b];if(d)c=d[a.turn];else{var e=i.parsePgnMove(b);if(e){var f=g.getAvailableMoves(a);f.forEach(function(b){null!=e.srcCol&&b.src%8!=e.srcCol||null!=e.srcRow&&Math.floor(b.src/8)!=e.srcRow||b.dst==e.dst&&a.board[b.src].type==e.type&&(e.src=b.src)}),null!=e.src&&null!=e.dst&&(c={src:e.src,dst:e.dst},e.promotion&&(c.promotionType=e.promotion))}}return c}function f(a,b){var c="",e=a.board[b.src];if("P"!=e.type&&(c+=e.type),"K"===e.type&&b.dst-b.src==2)return"O-O";if("K"===e.type&&b.dst-b.src==-2)return"O-O-O";var f=g.getAvailableMoves(a),i=[];f.forEach(function(c){c.dst==b.dst&&e.type==a.board[c.src].type&&i.push(c.src)});var j=d(b.src);if(i.length>1){var k=0,l=0;i.forEach(function(a){var b=d(a);j[0]==b[0]&&(k+=1),j[1]==b[1]&&(l+=1)}),c+=1==k?j[0]:1==l?j[1]:j}var m=b.dst%8-b.src%8;(null!=a.board[b.dst]||"P"==e.type&&0!=m)&&(""==c&&"P"==e.type&&(c+=j[0]),c+="x"),c+=d(b.dst);var n=h.applyMove(a,b);if("P"==e.type&&(b.dst<8||b.dst>56)){var o=b.promotionType?b.promotionType:"Q";c+="="+o}return g.isCurrentPlayerInCheck(n)&&(c+=0==g.getAvailableMoves(n).length?"#":"+"),c}var g=a("./moves"),h=a("./updates"),i=a("./pgnParser"),j={"O-O":{W:{src:4,dst:6},B:{src:60,dst:62}},"O-O-O":{W:{src:4,dst:2},B:{src:60,dst:58}}};b.exports={pgnToMove:e,moveToPgn:f}},{"./moves":18,"./pgnParser":20,"./updates":24}],20:[function(a,b,c){"use strict";function d(a,b){var c=null,d=a.charCodeAt(b)-f,e=a.charCodeAt(b+1)-g;return d>=0&&8>d&&e>=0&&8>e&&(c+=d,c+=8*e),c}function e(a){var b={type:null,srcCol:null,srcRow:null,dst:null,promotion:null,capture:!1,checking:!1,mate:!1},c=0,e=a.length;-1!=["P","R","N","B","K","Q"].indexOf(a[c])?(b.type=a[c],c++):b.type="P";var h=a.indexOf("+"),i=a.indexOf("#"),j=a.indexOf("=");j>=0&&(b.promotion=a.substring(j+1,j+2),e=Math.min(j,e)),h>=0&&(b.checking=!0,e=Math.min(h,e)),i>=0&&(b.mate=!0,e=Math.min(i,e));var k=d(a,e-2);if(null==k)return null;b.dst=k,e-=2,"x"===a[e-1]&&(e-=1,b.capture=!0);for(var l=c;e>l;l++){var m=a.charCodeAt(c),n=m-g,o=m-f;n>=0&&8>n&&(b.srcRow=n),o>=0&&8>o&&(b.srcCol=o)}return b}var f="a".charCodeAt(0),g="1".charCodeAt(0);b.exports={parsePgnMove:e}},{}],21:[function(a,b,c){"use strict";function d(a,b){return{type:a,side:b}}function e(a){return f[a.type.concat(a.side)]}var f={PW:"♙",PB:"♟",NW:"♘",NB:"♞",BW:"♗",BB:"♝",RW:"♖",RB:"♜",QW:"♕",QB:"♛",KW:"♔",KB:"♚"};b.exports={pieceFactory:d,pieceToUTF8:e}},{}],22:[function(a,b,c){"use strict";function d(a){return j.deepClone(a)}function e(){return{turn:"W",castlingFlags:{W:{K:!0,Q:!0},B:{K:!0,Q:!0}},lastPawnMoveColumn:null,check:!1,board:[h.pieceFactory("R","W"),h.pieceFactory("N","W"),h.pieceFactory("B","W"),h.pieceFactory("Q","W"),h.pieceFactory("K","W"),h.pieceFactory("B","W"),h.pieceFactory("N","W"),h.pieceFactory("R","W"),h.pieceFactory("P","W"),h.pieceFactory("P","W"),h.pieceFactory("P","W"),h.pieceFactory("P","W"),h.pieceFactory("P","W"),h.pieceFactory("P","W"),h.pieceFactory("P","W"),h.pieceFactory("P","W"),null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,h.pieceFactory("P","B"),h.pieceFactory("P","B"),h.pieceFactory("P","B"),h.pieceFactory("P","B"),h.pieceFactory("P","B"),h.pieceFactory("P","B"),h.pieceFactory("P","B"),h.pieceFactory("P","B"),h.pieceFactory("R","B"),h.pieceFactory("N","B"),h.pieceFactory("B","B"),h.pieceFactory("Q","B"),h.pieceFactory("K","B"),h.pieceFactory("B","B"),h.pieceFactory("N","B"),h.pieceFactory("R","B")]}}function f(a,b,c,d){var e;return e=(a+b)%2==0?"W"===c?d.WB:d.BB:"W"===c?d.WW:d.BW}function g(a,b){var c=[];c.push("W"==a.turn?"WHITE":"BLACK"),c.push(" "),c.push(a.castlingFlags.W.K?"K":""),c.push(a.castlingFlags.W.Q?"Q":""),c.push(a.castlingFlags.B.K?"k":""),c.push(a.castlingFlags.B.Q?"q":"");var d,e;for(d=7;d>=0;d--)for(c.push("\n"),c.push(d+1),c.push(" "),e=0;8>e;e++){var g=a.board[8*d+e];b?null==g?c.push(f(d,e,"W"," ")):c.push(f(d,e,g.side,h.pieceToUTF8(g)+" ")):null==g?c.push(". "):"W"==g.side?c.push(g.type.toUpperCase()+" "):c.push(g.type.toLowerCase()+" ")}return c.push("\n a b c d e f g h "),c.join("")}var h=a("./piece"),i=a("colors");i.setTheme({BW:["black","bgWhite"],BB:["black","bgMagenta"],WW:["white","bgWhite"],WB:["white","bgMagenta"]});var j=a("underscore-plus");b.exports={getInitialPosition:e,positionToString:g,clone:d}},{"./piece":21,colors:5,"underscore-plus":13}],23:[function(a,b,c){"use strict";function d(a){var b=e.getAvailableMoves(a),c="OPEN";return 0==b.length&&(c=a.check?"W"==a.turn?"BLACKWON":"WHITEWON":"PAT"),c}var e=a("./moves");b.exports={getGameStatus:d}},{"./moves":18}],24:[function(a,b,c){"use strict";function d(a,b){var c=[],d=new j(b.src),f=new j(b.dst),g=f.sub(d),h=a.board[b.dst];if(null!=h&&c.push({action:"remove",src:b.dst}),c.push({action:"move",src:b.src,dst:b.dst}),null==h&&"P"==a.board[b.src].type&&Math.abs(g.x)){var k=d.add(new j(g.x,0));c.push({action:"remove",src:k.offset})}if("P"==a.board[b.src].type&&2==Math.abs(g.y)?c.push({action:"pawnColumn",col:b.src%8}):c.push({action:"pawnColumn",col:null}),"P"==a.board[b.src].type&&(0==f.y||7==f.y)){var l=b.promotionType?b.promotionType:"Q";c.push({action:"promote",src:b.dst,promotionType:l})}"K"==a.board[b.src].type&&(c.push({action:"resetCastling",sides:["K","Q"]}),4==d.x&&6==f.x&&c.push({action:"move",src:f.add(new j(1,0)).offset,dst:f.add(new j(-1,0)).offset}),4==d.x&&2==f.x&&c.push({action:"move",src:f.add(new j(-2,0)).offset,dst:f.add(new j(1,0)).offset})),"R"==a.board[b.src].type&&0==d.x&&c.push({action:"resetCastling",sides:["Q"]}),"R"==a.board[b.src].type&&7==d.x&&c.push({action:"resetCastling",sides:["K"]});var m=e(a,c);m.turn=a.turn;var n=!1;return i.computeAllMoves(m).forEach(function(b){var c=a.board[b.dst];c&&"K"==c.type&&c.side!=a.turn&&(n=!0)}),c.push({action:"updateCheckFlag",value:n}),c}function e(a,b){var c=g.clone(a);return b.forEach(function(b){if("remove"===b.action){var d=b.src;c.board[d]=null}else"move"===b.action?(c.board[b.dst]=c.board[b.src],c.board[b.src]=null):"pawnColumn"===b.action?c.lastPawnMoveColumn=b.col:"resetCastling"===b.action?b.sides.forEach(function(b){c.castlingFlags[a.turn][b]=!1}):"updateCheckFlag"===b.action?c.check=b.value:"promote"===b.action&&(c.board[b.src].type=b.promotionType)}),c.turn="W"===a.turn?"B":"W",c}function f(a,b){var c=d(a,b);return e(a,c)}var g=a("./position"),h=a("./coordinates"),i=a("./moves-pieces"),j=h.BoardCoordinates;b.exports={computeDiffs:d,applyDiffs:e,applyMove:f}},{"./coordinates":15,"./moves-pieces":17,"./position":22}],25:[function(a,b,c){"use strict";var d=a("./chess/position"),e=a("./chess/moves"),f=a("./chess/updates"),g=a("./chess/pgn"),h=a("./chess/status"),i=a("./chess/locator"),j={getInitialPosition:d.getInitialPosition,positionToString:d.positionToString,getAvailableMoves:e.getAvailableMoves,applyMove:f.applyMove,computeDiffs:f.computeDiffs,applyDiffs:f.applyDiffs,pgnToMove:g.pgnToMove,moveToPgn:g.moveToPgn,getGameStatus:h.getGameStatus,findPiece:i.findPiece};b.exports=j},{"./chess/locator":16,"./chess/moves":18,"./chess/pgn":19,"./chess/position":22,"./chess/status":23,"./chess/updates":24}]},{},[25])(25)}); | ||
!function(n){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=n();else if("function"==typeof define&&define.amd)define([],n);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).chessRules=n()}}(function(){return function n(t,e,r){function o(u,a){if(!e[u]){if(!t[u]){var c="function"==typeof require&&require;if(!a&&c)return c(u,!0);if(i)return i(u,!0);var s=new Error("Cannot find module '"+u+"'");throw s.code="MODULE_NOT_FOUND",s}var l=e[u]={exports:{}};t[u][0].call(l.exports,function(n){var e=t[u][1][n];return o(e||n)},l,l.exports,n,t,e,r)}return e[u].exports}for(var i="function"==typeof require&&require,u=0;u<r.length;u++)o(r[u]);return o}({1:[function(n,t,e){function r(n){var t=function n(){return o.apply(n,arguments)};return t._styles=n,t.__proto__=p,t}function o(){var n=arguments,t=n.length,e=0!==t&&String(arguments[0]);if(t>1)for(var r=1;r<t;r++)e+=" "+n[r];if(!u.enabled||!e)return e;for(var o=this._styles,i=o.length;i--;){var c=a[o[i]];e=c.open+e.replace(c.closeRe,c.open)+c.close}return e}function i(n){for(var t in n)!function(t){u[t]=function(e){if("object"==typeof n[t]){var r=e;for(var o in n[t])r=u[n[t][o]](r);return r}return u[n[t]](e)}}(t)}var u={};t.exports=u,u.themes={};var a=u.styles=n("./styles"),c=Object.defineProperties;u.supportsColor=n("./system/supports-colors"),void 0===u.enabled&&(u.enabled=u.supportsColor),u.stripColors=u.strip=function(n){return(""+n).replace(/\x1B\[\d+m/g,"")};u.stylize=function(n,t){return u.enabled?a[t].open+n+a[t].close:n+""};var s=/[|\\{}()[\]^$+*?.]/g,l=function(n){if("string"!=typeof n)throw new TypeError("Expected a string");return n.replace(s,"\\$&")},f=function(){var n={};return a.grey=a.gray,Object.keys(a).forEach(function(t){a[t].closeRe=new RegExp(l(a[t].close),"g"),n[t]={get:function(){return r(this._styles.concat(t))}}}),n}(),p=c(function(){},f);u.setTheme=function(t){if("string"==typeof t)try{return u.themes[t]=n(t),i(u.themes[t]),u.themes[t]}catch(n){return console.log(n),n}else i(t)};var h=function(n,t){var e=t.split("");return(e=e.map(n)).join("")};u.trap=n("./custom/trap"),u.zalgo=n("./custom/zalgo"),u.maps={},u.maps.america=n("./maps/america"),u.maps.zebra=n("./maps/zebra"),u.maps.rainbow=n("./maps/rainbow"),u.maps.random=n("./maps/random");for(var d in u.maps)!function(n){u[n]=function(t){return h(u.maps[n],t)}}(d);c(u,function(){var n={};return Object.keys(f).forEach(function(t){n[t]={get:function(){return r([t])}}}),n}())},{"./custom/trap":2,"./custom/zalgo":3,"./maps/america":6,"./maps/rainbow":7,"./maps/random":8,"./maps/zebra":9,"./styles":10,"./system/supports-colors":11}],2:[function(n,t,e){t.exports=function(n,t){var e="",r={a:["@","Ą","Ⱥ","Ʌ","Δ","Λ","Д"],b:["ß","Ɓ","Ƀ","ɮ","β","฿"],c:["©","Ȼ","Ͼ"],d:["Ð","Ɗ","Ԁ","ԁ","Ԃ","ԃ"],e:["Ë","ĕ","Ǝ","ɘ","Σ","ξ","Ҽ","੬"],f:["Ӻ"],g:["ɢ"],h:["Ħ","ƕ","Ң","Һ","Ӈ","Ԋ"],i:["༏"],j:["Ĵ"],k:["ĸ","Ҡ","Ӄ","Ԟ"],l:["Ĺ"],m:["ʍ","Ӎ","ӎ","Ԡ","ԡ","൩"],n:["Ñ","ŋ","Ɲ","Ͷ","Π","Ҋ"],o:["Ø","õ","ø","Ǿ","ʘ","Ѻ","ם","","๏"],p:["Ƿ","Ҏ"],q:["্"],r:["®","Ʀ","Ȑ","Ɍ","ʀ","Я"],s:["§","Ϟ","ϟ","Ϩ"],t:["Ł","Ŧ","ͳ"],u:["Ʊ","Ս"],v:["ט"],w:["Ш","Ѡ","Ѽ","൰"],x:["Ҳ","Ӿ","Ӽ","ӽ"],y:["¥","Ұ","Ӌ"],z:["Ƶ","ɀ"]};return(n=(n=n||"Run the trap, drop the bass").split("")).forEach(function(n){n=n.toLowerCase();var t=r[n]||[" "],o=Math.floor(Math.random()*t.length);e+=void 0!==r[n]?r[n][o]:n}),e}},{}],3:[function(n,t,e){t.exports=function(n,t){function e(n){return Math.floor(Math.random()*n)}function r(n){var t=!1;return i.filter(function(e){t=e===n}),t}n=n||" he is here ";var o={up:["̍","̎","̄","̅","̿","̑","̆","̐","͒","͗","͑","̇","̈","̊","͂","̓","̈","͊","͋","͌","̃","̂","̌","͐","̀","́","̋","̏","̒","̓","̔","̽","̉","ͣ","ͤ","ͥ","ͦ","ͧ","ͨ","ͩ","ͪ","ͫ","ͬ","ͭ","ͮ","ͯ","̾","͛","͆","̚"],down:["̖","̗","̘","̙","̜","̝","̞","̟","̠","̤","̥","̦","̩","̪","̫","̬","̭","̮","̯","̰","̱","̲","̳","̹","̺","̻","̼","ͅ","͇","͈","͉","͍","͎","͓","͔","͕","͖","͙","͚","̣"],mid:["̕","̛","̀","́","͘","̡","̢","̧","̨","̴","̵","̶","͜","͝","͞","͟","͠","͢","̸","̷","͡"," ҉"]},i=[].concat(o.up,o.down,o.mid);return function(n,t){var i,u,a="";(t=t||{}).up=void 0===t.up||t.up,t.mid=void 0===t.mid||t.mid,t.down=void 0===t.down||t.down,t.size=void 0!==t.size?t.size:"maxi",n=n.split("");for(u in n)if(!r(u)){switch(a+=n[u],i={up:0,down:0,mid:0},t.size){case"mini":i.up=e(8),i.mid=e(2),i.down=e(8);break;case"maxi":i.up=e(16)+3,i.mid=e(4)+1,i.down=e(64)+3;break;default:i.up=e(8)+1,i.mid=e(6)/2,i.down=e(8)+1}var c=["up","mid","down"];for(var s in c)for(var l=c[s],f=0;f<=i[l];f++)t[l]&&(a+=o[l][e(o[l].length)])}return a}(n,t)}},{}],4:[function(n,t,e){var r=n("./colors");t.exports=function(){function t(n){var t=["__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__","charAt","constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf","charCodeAt","indexOf","lastIndexof","length","localeCompare","match","replace","search","slice","split","substring","toLocaleLowerCase","toLocaleUpperCase","toLowerCase","toUpperCase","trim","trimLeft","trimRight"];Object.keys(n).forEach(function(o){-1!==t.indexOf(o)?console.log("warn: ".red+("String.prototype"+o).magenta+" is probably something you don't want to override. Ignoring style name"):"string"==typeof n[o]?(r[o]=r[n[o]],e(o,function(){return r[n[o]](this)})):e(o,function(){for(var t=this,e=0;e<n[o].length;e++)t=r[n[o][e]](t);return t})})}var e=function(n,t){String.prototype.__defineGetter__(n,t)};e("strip",function(){return r.strip(this)}),e("stripColors",function(){return r.strip(this)}),e("trap",function(){return r.trap(this)}),e("zalgo",function(){return r.zalgo(this)}),e("zebra",function(){return r.zebra(this)}),e("rainbow",function(){return r.rainbow(this)}),e("random",function(){return r.random(this)}),e("america",function(){return r.america(this)}),Object.keys(r.styles).forEach(function(n){e(n,function(){return r.stylize(this,n)})}),r.setTheme=function(e){if("string"==typeof e)try{return r.themes[e]=n(e),t(r.themes[e]),r.themes[e]}catch(n){return console.log(n),n}else t(e)}}},{"./colors":1}],5:[function(n,t,e){var r=n("./colors");t.exports=r,n("./extendStringPrototype")()},{"./colors":1,"./extendStringPrototype":4}],6:[function(n,t,e){var r=n("../colors");t.exports=function(n,t,e){if(" "===n)return n;switch(t%3){case 0:return r.red(n);case 1:return r.white(n);case 2:return r.blue(n)}}},{"../colors":1}],7:[function(n,t,e){var r=n("../colors");t.exports=function(){var n=["red","yellow","green","blue","magenta"];return function(t,e,o){return" "===t?t:r[n[e++%n.length]](t)}}()},{"../colors":1}],8:[function(n,t,e){var r=n("../colors");t.exports=function(){var n=["underline","inverse","grey","yellow","red","green","blue","white","cyan","magenta"];return function(t,e,o){return" "===t?t:r[n[Math.round(Math.random()*(n.length-1))]](t)}}()},{"../colors":1}],9:[function(n,t,e){var r=n("../colors");t.exports=function(n,t,e){return t%2==0?n:r.inverse(n)}},{"../colors":1}],10:[function(n,t,e){var r={};t.exports=r;var o={reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29],black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39],grey:[90,39],bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],blackBG:[40,49],redBG:[41,49],greenBG:[42,49],yellowBG:[43,49],blueBG:[44,49],magentaBG:[45,49],cyanBG:[46,49],whiteBG:[47,49]};Object.keys(o).forEach(function(n){var t=o[n],e=r[n]=[];e.open="["+t[0]+"m",e.close="["+t[1]+"m"})},{}],11:[function(n,t,e){(function(n){var e=n.argv;t.exports=-1===e.indexOf("--no-color")&&-1===e.indexOf("--color=false")&&(-1!==e.indexOf("--color")||-1!==e.indexOf("--color=true")||-1!==e.indexOf("--color=always")||!(n.stdout&&!n.stdout.isTTY)&&("win32"===n.platform||("COLORTERM"in n.env||"dumb"!==n.env.TERM&&!!/^screen|^xterm|^vt100|color|ansi|cygwin|linux/i.test(n.env.TERM))))}).call(this,n("_process"))},{_process:12}],12:[function(n,t,e){function r(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function i(n){if(f===setTimeout)return setTimeout(n,0);if((f===r||!f)&&setTimeout)return f=setTimeout,setTimeout(n,0);try{return f(n,0)}catch(t){try{return f.call(null,n,0)}catch(t){return f.call(this,n,0)}}}function u(n){if(p===clearTimeout)return clearTimeout(n);if((p===o||!p)&&clearTimeout)return p=clearTimeout,clearTimeout(n);try{return p(n)}catch(t){try{return p.call(null,n)}catch(t){return p.call(this,n)}}}function a(){y&&d&&(y=!1,d.length?v=d.concat(v):g=-1,v.length&&c())}function c(){if(!y){var n=i(a);y=!0;for(var t=v.length;t;){for(d=v,v=[];++g<t;)d&&d[g].run();g=-1,t=v.length}d=null,y=!1,u(n)}}function s(n,t){this.fun=n,this.array=t}function l(){}var f,p,h=t.exports={};!function(){try{f="function"==typeof setTimeout?setTimeout:r}catch(n){f=r}try{p="function"==typeof clearTimeout?clearTimeout:o}catch(n){p=o}}();var d,v=[],y=!1,g=-1;h.nextTick=function(n){var t=new Array(arguments.length-1);if(arguments.length>1)for(var e=1;e<arguments.length;e++)t[e-1]=arguments[e];v.push(new s(n,t)),1!==v.length||y||i(c)},s.prototype.run=function(){this.fun.apply(null,this.array)},h.title="browser",h.browser=!0,h.env={},h.argv=[],h.version="",h.versions={},h.on=l,h.addListener=l,h.once=l,h.off=l,h.removeListener=l,h.removeAllListeners=l,h.emit=l,h.prependListener=l,h.prependOnceListener=l,h.listeners=function(n){return[]},h.binding=function(n){throw new Error("process.binding is not supported")},h.cwd=function(){return"/"},h.chdir=function(n){throw new Error("process.chdir is not supported")},h.umask=function(){return 0}},{}],13:[function(n,t,e){(function(e){(function(){var r,o,i,u,a,c,s,l,f=[].slice;l=n("underscore"),i={cmd:"⌘",ctrl:"⌃",alt:"⌥",option:"⌥",shift:"⇧",enter:"⏎",left:"←",right:"→",up:"↑",down:"↓"},u={cmd:"Cmd",ctrl:"Ctrl",alt:"Alt",option:"Alt",shift:"Shift",enter:"Enter",left:"Left",right:"Right",up:"Up",down:"Down"},c={"~":"`",_:"-","+":"=","|":"\\","{":"[","}":"]",":":";",'"':"'","<":",",">":".","?":"/"},s=function(n){var t,e,r,o,i;if(r=0,e=[],null==n)return e;for(t=o=0,i=n.length;o<i;t=++o)"."!==n[t]||0!==t&&"\\"===n[t-1]||(e.push(n.substring(r,t)),r=t+1);return e.push(n.substr(r,n.length)),e},o=function(n){return l.isObject(n)&&!l.isArray(n)},a={adviseBefore:function(n,t,e){var r;return r=n[t],n[t]=function(){var n;if(n=1<=arguments.length?f.call(arguments,0):[],!1!==e.apply(this,n))return r.apply(this,n)}},camelize:function(n){return n?n.replace(/[_-]+(\w)/g,function(n){return n[1].toUpperCase()}):""},capitalize:function(n){return n?"github"===n.toLowerCase()?"GitHub":n[0].toUpperCase()+n.slice(1):""},compactObject:function(n){var t,e,r;e={};for(t in n)null!=(r=n[t])&&(e[t]=r);return e},dasherize:function(n){return n?(n=n[0].toLowerCase()+n.slice(1)).replace(/([A-Z])|(_)/g,function(n,t){return t?"-"+t.toLowerCase():"-"}):""},deepClone:function(n){return l.isArray(n)?n.map(function(n){return a.deepClone(n)}):l.isObject(n)&&!l.isFunction(n)?a.mapObject(n,function(n,t){return[n,a.deepClone(t)]}):n},deepExtend:function(n){var t,e,r,i,u,c,s;for(i=n,t=0;++t<arguments.length;)if(r=arguments[t],o(i)&&o(r))for(u=0,c=(s=Object.keys(r)).length;u<c;u++)i[e=s[u]]=a.deepExtend(i[e],r[e]);else i=a.deepClone(r);return i},deepContains:function(n,t){var e,r,o;if(null==n)return!1;for(r=0,o=n.length;r<o;r++)if(e=n[r],l.isEqual(e,t))return!0;return!1},endsWith:function(n,t){return null==t&&(t=""),!!n&&-1!==n.indexOf(t,n.length-t.length)},escapeAttribute:function(n){return n?n.replace(/"/g,""").replace(/\n/g,"").replace(/\\/g,"-"):""},escapeRegExp:function(n){return n?n.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"):""},humanizeEventName:function(n,t){var e,r,o,i;return i=n.split(":"),r=i[0],null==(e=i[1])?a.undasherize(r):(o=a.undasherize(r),null==t&&(t=a.undasherize(e)),o+": "+t)},humanizeKey:function(n,t){var r;return null==t&&(t=e.platform),n?(r="darwin"===t?i:u)[n]?r[n]:1===n.length&&null!=c[n]?[r.shift,c[n]]:1===n.length&&n===n.toUpperCase()&&n.toUpperCase()!==n.toLowerCase()?[r.shift,n.toUpperCase()]:1===n.length||/f[0-9]{1,2}/.test(n)?n.toUpperCase():"darwin"===t?n:a.capitalize(n):n},humanizeKeystroke:function(n,t){var r,o,i,u,c,s,f,p,h,d;if(null==t&&(t=e.platform),!n)return n;for(r=[],f=0,h=(c=n.split(" ")).length;f<h;f++){for(u=[],o=p=0,d=(s=(n=c[f]).split("-")).length;p<d;o=++p)""===(i=s[o])&&""===s[o-1]&&(i="-"),i&&u.push(a.humanizeKey(i,t));u=l.uniq(l.flatten(u)),u="darwin"===t?u.join(""):u.join("+"),r.push(u)}return r.join(" ")},isSubset:function(n,t){return l.every(n,function(n){return l.include(t,n)})},losslessInvert:function(n){var t,e,r;t={};for(e in n)null==t[r=n[e]]&&(t[r]=[]),t[r].push(e);return t},mapObject:function(n,t){var e,r,o,i,u,a,c;for(r={},i=0,u=(a=Object.keys(n)).length;i<u;i++)e=(c=t(e=a[i],n[e]))[0],o=c[1],r[e]=o;return r},multiplyString:function(n,t){var e,r;for(e="",r=0;r<t;)e+=n,r++;return e},pluralize:function(n,t,e){return null==n&&(n=0),null==e&&(e=t+"s"),1===n?n+" "+t:n+" "+e},remove:function(n,t){var e;return(e=n.indexOf(t))>=0&&n.splice(e,1),n},setValueForKeyPath:function(n,t,e){var r,o;for(o=s(t);o.length>1;)null==n[r=o.shift()]&&(n[r]={}),n=n[r];return null!=e?n[o.shift()]=e:delete n[o.shift()]},hasKeyPath:function(n,t){var e,r,o,i;for(o=0,i=(r=s(t)).length;o<i;o++){if(e=r[o],!n.hasOwnProperty(e))return!1;n=n[e]}return!0},spliceWithArray:function(n,t,e,r,o){var i,u,a,c;if(null==o&&(o=1e5),r.length<o)return n.splice.apply(n,[t,e].concat(f.call(r)));for(n.splice(t,e),c=[],i=u=0,a=r.length;o>0?u<=a:u>=a;i=u+=o)c.push(n.splice.apply(n,[t+i,0].concat(f.call(r.slice(i,i+o)))));return c},sum:function(n){var t,e,r;for(t=0,e=0,r=n.length;e<r;e++)t+=n[e];return t},uncamelcase:function(n){var t;return n?(t=n.replace(/([A-Z])|_+/g,function(n,t){return null==t&&(t="")," "+t}),a.capitalize(t.trim())):""},undasherize:function(n){return n?n.split("-").map(a.capitalize).join(" "):""},underscore:function(n){return n?(n=n[0].toLowerCase()+n.slice(1)).replace(/([A-Z])|-+/g,function(n,t){return null==t&&(t=""),"_"+t.toLowerCase()}):""},valueForKeyPath:function(n,t){var e,r,o,i;for(o=0,i=(r=s(t)).length;o<i;o++)if(e=r[o],null==(n=n[e]))return;return n},isEqual:function(n,t,e,o){return l.isArray(e)&&l.isArray(o)?r(n,t,e,o):r(n,t)},isEqualForProperties:function(){var n,t,e,r,o,i;for(n=arguments[0],t=arguments[1],o=0,i=(e=3<=arguments.length?f.call(arguments,2):[]).length;o<i;o++)if(r=e[o],!l.isEqual(n[r],t[r]))return!1;return!0}},r=function(n,t,e,o){var i,u,a,c,s,f,p,h,d,v,y,g,m,w;if(null==e&&(e=[]),null==o&&(o=[]),n===t)return l.isEqual(n,t);if(l.isFunction(n)||l.isFunction(t))return l.isEqual(n,t);for(g=e.length;g--;)if(e[g]===n)return o[g]===t;if(e.push(n),o.push(t),d=!1,l.isFunction(null!=n?n.isEqual:void 0))d=n.isEqual(t,e,o);else if(l.isFunction(null!=t?t.isEqual:void 0))d=t.isEqual(n,o,e);else if(l.isArray(n)&&l.isArray(t)&&n.length===t.length){for(d=!0,v=m=0,w=n.length;m<w;v=++m)if(a=n[v],!r(a,t[v],e,o)){d=!1;break}}else if(l.isRegExp(n)&&l.isRegExp(t))d=l.isEqual(n,t);else if(l.isElement(n)&&l.isElement(t))d=n===t;else if(l.isObject(n)&&l.isObject(t))if(i=n.constructor,f=t.constructor,u=l.isFunction(i)&&i instanceof i,p=l.isFunction(f)&&f instanceof f,i===f||u&&p){c=0,d=!0;for(y in n)if(s=n[y],l.has(n,y)&&(c++,!l.has(t,y)||!r(s,t[y],e,o))){d=!1;break}if(d){h=0;for(y in t)t[y],l.has(t,y)&&h++;d=c===h}}else d=!1;else d=l.isEqual(n,t);return e.pop(),o.pop(),d},t.exports=l.extend({},l,a)}).call(this)}).call(this,n("_process"))},{_process:12,underscore:14}],14:[function(n,t,e){(function(){var n=this,r=n._,o={},i=Array.prototype,u=Object.prototype,a=Function.prototype,c=i.push,s=i.slice,l=i.concat,f=u.toString,p=u.hasOwnProperty,h=i.forEach,d=i.map,v=i.reduce,y=i.reduceRight,g=i.filter,m=i.every,w=i.some,b=i.indexOf,x=i.lastIndexOf,C=Array.isArray,E=Object.keys,_=a.bind,B=function(n){return n instanceof B?n:this instanceof B?void(this._wrapped=n):new B(n)};void 0!==e?(void 0!==t&&t.exports&&(e=t.exports=B),e._=B):n._=B,B.VERSION="1.6.0";var F=B.each=B.forEach=function(n,t,e){if(null==n)return n;if(h&&n.forEach===h)n.forEach(t,e);else if(n.length===+n.length){for(var r=0,i=n.length;r<i;r++)if(t.call(e,n[r],r,n)===o)return}else for(var u=B.keys(n),r=0,i=u.length;r<i;r++)if(t.call(e,n[u[r]],u[r],n)===o)return;return n};B.map=B.collect=function(n,t,e){var r=[];return null==n?r:d&&n.map===d?n.map(t,e):(F(n,function(n,o,i){r.push(t.call(e,n,o,i))}),r)};var O="Reduce of empty array with no initial value";B.reduce=B.foldl=B.inject=function(n,t,e,r){var o=arguments.length>2;if(null==n&&(n=[]),v&&n.reduce===v)return r&&(t=B.bind(t,r)),o?n.reduce(t,e):n.reduce(t);if(F(n,function(n,i,u){o?e=t.call(r,e,n,i,u):(e=n,o=!0)}),!o)throw new TypeError(O);return e},B.reduceRight=B.foldr=function(n,t,e,r){var o=arguments.length>2;if(null==n&&(n=[]),y&&n.reduceRight===y)return r&&(t=B.bind(t,r)),o?n.reduceRight(t,e):n.reduceRight(t);var i=n.length;if(i!==+i){var u=B.keys(n);i=u.length}if(F(n,function(a,c,s){c=u?u[--i]:--i,o?e=t.call(r,e,n[c],c,s):(e=n[c],o=!0)}),!o)throw new TypeError(O);return e},B.find=B.detect=function(n,t,e){var r;return A(n,function(n,o,i){if(t.call(e,n,o,i))return r=n,!0}),r},B.filter=B.select=function(n,t,e){var r=[];return null==n?r:g&&n.filter===g?n.filter(t,e):(F(n,function(n,o,i){t.call(e,n,o,i)&&r.push(n)}),r)},B.reject=function(n,t,e){return B.filter(n,function(n,r,o){return!t.call(e,n,r,o)},e)},B.every=B.all=function(n,t,e){t||(t=B.identity);var r=!0;return null==n?r:m&&n.every===m?n.every(t,e):(F(n,function(n,i,u){if(!(r=r&&t.call(e,n,i,u)))return o}),!!r)};var A=B.some=B.any=function(n,t,e){t||(t=B.identity);var r=!1;return null==n?r:w&&n.some===w?n.some(t,e):(F(n,function(n,i,u){if(r||(r=t.call(e,n,i,u)))return o}),!!r)};B.contains=B.include=function(n,t){return null!=n&&(b&&n.indexOf===b?-1!=n.indexOf(t):A(n,function(n){return n===t}))},B.invoke=function(n,t){var e=s.call(arguments,2),r=B.isFunction(t);return B.map(n,function(n){return(r?t:n[t]).apply(n,e)})},B.pluck=function(n,t){return B.map(n,B.property(t))},B.where=function(n,t){return B.filter(n,B.matches(t))},B.findWhere=function(n,t){return B.find(n,B.matches(t))},B.max=function(n,t,e){if(!t&&B.isArray(n)&&n[0]===+n[0]&&n.length<65535)return Math.max.apply(Math,n);var r=-1/0,o=-1/0;return F(n,function(n,i,u){var a=t?t.call(e,n,i,u):n;a>o&&(r=n,o=a)}),r},B.min=function(n,t,e){if(!t&&B.isArray(n)&&n[0]===+n[0]&&n.length<65535)return Math.min.apply(Math,n);var r=1/0,o=1/0;return F(n,function(n,i,u){var a=t?t.call(e,n,i,u):n;a<o&&(r=n,o=a)}),r},B.shuffle=function(n){var t,e=0,r=[];return F(n,function(n){t=B.random(e++),r[e-1]=r[t],r[t]=n}),r},B.sample=function(n,t,e){return null==t||e?(n.length!==+n.length&&(n=B.values(n)),n[B.random(n.length-1)]):B.shuffle(n).slice(0,Math.max(0,t))};var P=function(n){return null==n?B.identity:B.isFunction(n)?n:B.property(n)};B.sortBy=function(n,t,e){return t=P(t),B.pluck(B.map(n,function(n,r,o){return{value:n,index:r,criteria:t.call(e,n,r,o)}}).sort(function(n,t){var e=n.criteria,r=t.criteria;if(e!==r){if(e>r||void 0===e)return 1;if(e<r||void 0===r)return-1}return n.index-t.index}),"value")};var T=function(n){return function(t,e,r){var o={};return e=P(e),F(t,function(i,u){var a=e.call(r,i,u,t);n(o,a,i)}),o}};B.groupBy=T(function(n,t,e){B.has(n,t)?n[t].push(e):n[t]=[e]}),B.indexBy=T(function(n,t,e){n[t]=e}),B.countBy=T(function(n,t){B.has(n,t)?n[t]++:n[t]=1}),B.sortedIndex=function(n,t,e,r){for(var o=(e=P(e)).call(r,t),i=0,u=n.length;i<u;){var a=i+u>>>1;e.call(r,n[a])<o?i=a+1:u=a}return i},B.toArray=function(n){return n?B.isArray(n)?s.call(n):n.length===+n.length?B.map(n,B.identity):B.values(n):[]},B.size=function(n){return null==n?0:n.length===+n.length?n.length:B.keys(n).length},B.first=B.head=B.take=function(n,t,e){if(null!=n)return null==t||e?n[0]:t<0?[]:s.call(n,0,t)},B.initial=function(n,t,e){return s.call(n,0,n.length-(null==t||e?1:t))},B.last=function(n,t,e){if(null!=n)return null==t||e?n[n.length-1]:s.call(n,Math.max(n.length-t,0))},B.rest=B.tail=B.drop=function(n,t,e){return s.call(n,null==t||e?1:t)},B.compact=function(n){return B.filter(n,B.identity)};var M=function(n,t,e){return t&&B.every(n,B.isArray)?l.apply(e,n):(F(n,function(n){B.isArray(n)||B.isArguments(n)?t?c.apply(e,n):M(n,t,e):e.push(n)}),e)};B.flatten=function(n,t){return M(n,t,[])},B.without=function(n){return B.difference(n,s.call(arguments,1))},B.partition=function(n,t){var e=[],r=[];return F(n,function(n){(t(n)?e:r).push(n)}),[e,r]},B.uniq=B.unique=function(n,t,e,r){B.isFunction(t)&&(r=e,e=t,t=!1);var o=e?B.map(n,e,r):n,i=[],u=[];return F(o,function(e,r){(t?r&&u[u.length-1]===e:B.contains(u,e))||(u.push(e),i.push(n[r]))}),i},B.union=function(){return B.uniq(B.flatten(arguments,!0))},B.intersection=function(n){var t=s.call(arguments,1);return B.filter(B.uniq(n),function(n){return B.every(t,function(t){return B.contains(t,n)})})},B.difference=function(n){var t=l.apply(i,s.call(arguments,1));return B.filter(n,function(n){return!B.contains(t,n)})},B.zip=function(){for(var n=B.max(B.pluck(arguments,"length").concat(0)),t=new Array(n),e=0;e<n;e++)t[e]=B.pluck(arguments,""+e);return t},B.object=function(n,t){if(null==n)return{};for(var e={},r=0,o=n.length;r<o;r++)t?e[n[r]]=t[r]:e[n[r][0]]=n[r][1];return e},B.indexOf=function(n,t,e){if(null==n)return-1;var r=0,o=n.length;if(e){if("number"!=typeof e)return r=B.sortedIndex(n,t),n[r]===t?r:-1;r=e<0?Math.max(0,o+e):e}if(b&&n.indexOf===b)return n.indexOf(t,e);for(;r<o;r++)if(n[r]===t)return r;return-1},B.lastIndexOf=function(n,t,e){if(null==n)return-1;var r=null!=e;if(x&&n.lastIndexOf===x)return r?n.lastIndexOf(t,e):n.lastIndexOf(t);for(var o=r?e:n.length;o--;)if(n[o]===t)return o;return-1},B.range=function(n,t,e){arguments.length<=1&&(t=n||0,n=0),e=arguments[2]||1;for(var r=Math.max(Math.ceil((t-n)/e),0),o=0,i=new Array(r);o<r;)i[o++]=n,n+=e;return i};var W=function(){};B.bind=function(n,t){var e,r;if(_&&n.bind===_)return _.apply(n,s.call(arguments,1));if(!B.isFunction(n))throw new TypeError;return e=s.call(arguments,2),r=function(){if(!(this instanceof r))return n.apply(t,e.concat(s.call(arguments)));W.prototype=n.prototype;var o=new W;W.prototype=null;var i=n.apply(o,e.concat(s.call(arguments)));return Object(i)===i?i:o}},B.partial=function(n){var t=s.call(arguments,1);return function(){for(var e=0,r=t.slice(),o=0,i=r.length;o<i;o++)r[o]===B&&(r[o]=arguments[e++]);for(;e<arguments.length;)r.push(arguments[e++]);return n.apply(this,r)}},B.bindAll=function(n){var t=s.call(arguments,1);if(0===t.length)throw new Error("bindAll must be passed function names");return F(t,function(t){n[t]=B.bind(n[t],n)}),n},B.memoize=function(n,t){var e={};return t||(t=B.identity),function(){var r=t.apply(this,arguments);return B.has(e,r)?e[r]:e[r]=n.apply(this,arguments)}},B.delay=function(n,t){var e=s.call(arguments,2);return setTimeout(function(){return n.apply(null,e)},t)},B.defer=function(n){return B.delay.apply(B,[n,1].concat(s.call(arguments,1)))},B.throttle=function(n,t,e){var r,o,i,u=null,a=0;e||(e={});var c=function(){a=!1===e.leading?0:B.now(),u=null,i=n.apply(r,o),r=o=null};return function(){var s=B.now();a||!1!==e.leading||(a=s);var l=t-(s-a);return r=this,o=arguments,l<=0?(clearTimeout(u),u=null,a=s,i=n.apply(r,o),r=o=null):u||!1===e.trailing||(u=setTimeout(c,l)),i}},B.debounce=function(n,t,e){var r,o,i,u,a,c=function(){var s=B.now()-u;s<t?r=setTimeout(c,t-s):(r=null,e||(a=n.apply(i,o),i=o=null))};return function(){i=this,o=arguments,u=B.now();var s=e&&!r;return r||(r=setTimeout(c,t)),s&&(a=n.apply(i,o),i=o=null),a}},B.once=function(n){var t,e=!1;return function(){return e?t:(e=!0,t=n.apply(this,arguments),n=null,t)}},B.wrap=function(n,t){return B.partial(t,n)},B.compose=function(){var n=arguments;return function(){for(var t=arguments,e=n.length-1;e>=0;e--)t=[n[e].apply(this,t)];return t[0]}},B.after=function(n,t){return function(){if(--n<1)return t.apply(this,arguments)}},B.keys=function(n){if(!B.isObject(n))return[];if(E)return E(n);var t=[];for(var e in n)B.has(n,e)&&t.push(e);return t},B.values=function(n){for(var t=B.keys(n),e=t.length,r=new Array(e),o=0;o<e;o++)r[o]=n[t[o]];return r},B.pairs=function(n){for(var t=B.keys(n),e=t.length,r=new Array(e),o=0;o<e;o++)r[o]=[t[o],n[t[o]]];return r},B.invert=function(n){for(var t={},e=B.keys(n),r=0,o=e.length;r<o;r++)t[n[e[r]]]=e[r];return t},B.functions=B.methods=function(n){var t=[];for(var e in n)B.isFunction(n[e])&&t.push(e);return t.sort()},B.extend=function(n){return F(s.call(arguments,1),function(t){if(t)for(var e in t)n[e]=t[e]}),n},B.pick=function(n){var t={},e=l.apply(i,s.call(arguments,1));return F(e,function(e){e in n&&(t[e]=n[e])}),t},B.omit=function(n){var t={},e=l.apply(i,s.call(arguments,1));for(var r in n)B.contains(e,r)||(t[r]=n[r]);return t},B.defaults=function(n){return F(s.call(arguments,1),function(t){if(t)for(var e in t)void 0===n[e]&&(n[e]=t[e])}),n},B.clone=function(n){return B.isObject(n)?B.isArray(n)?n.slice():B.extend({},n):n},B.tap=function(n,t){return t(n),n};var k=function(n,t,e,r){if(n===t)return 0!==n||1/n==1/t;if(null==n||null==t)return n===t;n instanceof B&&(n=n._wrapped),t instanceof B&&(t=t._wrapped);var o=f.call(n);if(o!=f.call(t))return!1;switch(o){case"[object String]":return n==String(t);case"[object Number]":return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case"[object Date]":case"[object Boolean]":return+n==+t;case"[object RegExp]":return n.source==t.source&&n.global==t.global&&n.multiline==t.multiline&&n.ignoreCase==t.ignoreCase}if("object"!=typeof n||"object"!=typeof t)return!1;for(var i=e.length;i--;)if(e[i]==n)return r[i]==t;var u=n.constructor,a=t.constructor;if(u!==a&&!(B.isFunction(u)&&u instanceof u&&B.isFunction(a)&&a instanceof a)&&"constructor"in n&&"constructor"in t)return!1;e.push(n),r.push(t);var c=0,s=!0;if("[object Array]"==o){if(c=n.length,s=c==t.length)for(;c--&&(s=k(n[c],t[c],e,r)););}else{for(var l in n)if(B.has(n,l)&&(c++,!(s=B.has(t,l)&&k(n[l],t[l],e,r))))break;if(s){for(l in t)if(B.has(t,l)&&!c--)break;s=!c}}return e.pop(),r.pop(),s};B.isEqual=function(n,t){return k(n,t,[],[])},B.isEmpty=function(n){if(null==n)return!0;if(B.isArray(n)||B.isString(n))return 0===n.length;for(var t in n)if(B.has(n,t))return!1;return!0},B.isElement=function(n){return!(!n||1!==n.nodeType)},B.isArray=C||function(n){return"[object Array]"==f.call(n)},B.isObject=function(n){return n===Object(n)},F(["Arguments","Function","String","Number","Date","RegExp"],function(n){B["is"+n]=function(t){return f.call(t)=="[object "+n+"]"}}),B.isArguments(arguments)||(B.isArguments=function(n){return!(!n||!B.has(n,"callee"))}),"function"!=typeof/./&&(B.isFunction=function(n){return"function"==typeof n}),B.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},B.isNaN=function(n){return B.isNumber(n)&&n!=+n},B.isBoolean=function(n){return!0===n||!1===n||"[object Boolean]"==f.call(n)},B.isNull=function(n){return null===n},B.isUndefined=function(n){return void 0===n},B.has=function(n,t){return p.call(n,t)},B.noConflict=function(){return n._=r,this},B.identity=function(n){return n},B.constant=function(n){return function(){return n}},B.property=function(n){return function(t){return t[n]}},B.matches=function(n){return function(t){if(t===n)return!0;for(var e in n)if(n[e]!==t[e])return!1;return!0}},B.times=function(n,t,e){for(var r=Array(Math.max(0,n)),o=0;o<n;o++)r[o]=t.call(e,o);return r},B.random=function(n,t){return null==t&&(t=n,n=0),n+Math.floor(Math.random()*(t-n+1))},B.now=Date.now||function(){return(new Date).getTime()};var j={escape:{"&":"&","<":"<",">":">",'"':""","'":"'"}};j.unescape=B.invert(j.escape);var R={escape:new RegExp("["+B.keys(j.escape).join("")+"]","g"),unescape:new RegExp("("+B.keys(j.unescape).join("|")+")","g")};B.each(["escape","unescape"],function(n){B[n]=function(t){return null==t?"":(""+t).replace(R[n],function(t){return j[n][t]})}}),B.result=function(n,t){if(null!=n){var e=n[t];return B.isFunction(e)?e.call(n):e}},B.mixin=function(n){F(B.functions(n),function(t){var e=B[t]=n[t];B.prototype[t]=function(){var n=[this._wrapped];return c.apply(n,arguments),L.call(this,e.apply(B,n))}})};var z=0;B.uniqueId=function(n){var t=++z+"";return n?n+t:t},B.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var K=/(.)^/,S={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},q=/\\|'|\r|\n|\t|\u2028|\u2029/g;B.template=function(n,t,e){var r;e=B.defaults({},e,B.templateSettings);var o=new RegExp([(e.escape||K).source,(e.interpolate||K).source,(e.evaluate||K).source].join("|")+"|$","g"),i=0,u="__p+='";n.replace(o,function(t,e,r,o,a){return u+=n.slice(i,a).replace(q,function(n){return"\\"+S[n]}),e&&(u+="'+\n((__t=("+e+"))==null?'':_.escape(__t))+\n'"),r&&(u+="'+\n((__t=("+r+"))==null?'':__t)+\n'"),o&&(u+="';\n"+o+"\n__p+='"),i=a+t.length,t}),u+="';\n",e.variable||(u="with(obj||{}){\n"+u+"}\n"),u="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+u+"return __p;\n";try{r=new Function(e.variable||"obj","_",u)}catch(n){throw n.source=u,n}if(t)return r(t,B);var a=function(n){return r.call(this,n,B)};return a.source="function("+(e.variable||"obj")+"){\n"+u+"}",a},B.chain=function(n){return B(n).chain()};var L=function(n){return this._chain?B(n).chain():n};B.mixin(B),F(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=i[n];B.prototype[n]=function(){var e=this._wrapped;return t.apply(e,arguments),"shift"!=n&&"splice"!=n||0!==e.length||delete e[0],L.call(this,e)}}),F(["concat","join","slice"],function(n){var t=i[n];B.prototype[n]=function(){return L.call(this,t.apply(this._wrapped,arguments))}}),B.extend(B.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}})}).call(this)},{}],15:[function(n,t,e){"use strict";function r(n,t){void 0===t?(this.offset=n,this.x=this.offset%8,this.y=Math.floor(this.offset/8)):(this.offset=n+8*t,this.x=n,this.y=t)}r.prototype.add=function(n){return new r(this.x+n.x,this.y+n.y)},r.prototype.sub=function(n){return new r(this.x-n.x,this.y-n.y)},r.prototype.isValid=function(){return this.x>=0&&this.x<8&&this.y>=0&&this.y<8},t.exports={BoardCoordinates:r}},{}],16:[function(n,t,e){"use strict";var r=n("./coordinates").BoardCoordinates;t.exports={findPiece:function(n,t,e){for(var o=e||n.turn,i=[],u=0;u<64;u++){var a=n.board[u];null!=a&&a.type===t&&a.side===o&&i.push(u)}var c=[];return i.forEach(function(n){c.push(new r(n))}),c}}},{"./coordinates":15}],17:[function(n,t,e){"use strict";function r(n,t){return t.isValid()&&null==n.board[t.offset]}function o(n,t){if(!t.isValid())return!1;var e=n.board[t.offset];return null!=e&&n.turn!==e.side}function i(n,t){if(!t.isValid())return!1;var e=n.board[t.offset];return null==e||n.turn!==e.side}function u(n,t,e,i){for(var u=t;;){if(!(u=u.add(e)).isValid())break;if(!r(n,u)){o(n,u)&&i.push(u);break}i.push(u)}}var a=n("./coordinates").BoardCoordinates,c=[];c.P=function(n,t){var e="W"==n.turn?1:-1,i="W"==n.turn?1:6,u=t.add(new a(0,e)),c=u.add(new a(0,e)),s=t.add(new a(1,e)),l=t.add(new a(-1,e)),f=[];return r(n,u)&&f.push(u),o(n,l)?f.push(l):n.lastPawnMoveColumn==t.x-1&&(t.y-i)/e==3&&f.push(l),o(n,s)?f.push(s):n.lastPawnMoveColumn==t.x+1&&(t.y-i)/e==3&&f.push(s),t.y==i&&r(n,u)&&r(n,c)&&f.push(c),f},c.N=function(n,t){var e=[];return[t.add(new a(-1,2)),t.add(new a(1,2)),t.add(new a(2,-1)),t.add(new a(2,1)),t.add(new a(1,-2)),t.add(new a(-1,-2)),t.add(new a(-2,1)),t.add(new a(-2,-1))].forEach(function(t){i(n,t)&&e.push(t)}),e},c.B=function(n,t){var e=[];return[new a(-1,-1),new a(-1,1),new a(1,-1),new a(1,1)].forEach(function(r){u(n,t,r,e)}),e},c.R=function(n,t){var e=[];return[new a(-1,0),new a(1,0),new a(0,-1),new a(0,1)].forEach(function(r){u(n,t,r,e)}),e},c.K=function(n,t){for(var e=[],o=-1;o<2;o++)for(var u=-1;u<2;u++)if(0!=o||0!=u){var c=new a(o,u),s=t.add(c);i(n,s)&&e.push(s)}if(n.castlingFlags[n.turn].K){var l=t.add(new a(1,0)),f=t.add(new a(2,0));r(n,l)&&r(n,f)&&e.push(f)}if(n.castlingFlags[n.turn].Q){var l=t.add(new a(-1,0)),f=t.add(new a(-2,0));r(n,l)&&r(n,f)&&e.push(f)}return e},c.Q=function(n,t){var e=[];return[new a(-1,0),new a(1,0),new a(0,-1),new a(0,1),new a(-1,-1),new a(-1,1),new a(1,-1),new a(1,1)].forEach(function(r){u(n,t,r,e)}),e},t.exports={computeAllMoves:function(n){for(var t=[],e=0;e<=64;e++){var r=n.board[e],o=new a(e);null!=r&&r.side===n.turn&&c[r.type](n,o).forEach(function(n){t.push({src:o.offset,dst:n.offset})})}return t},pieceDestinationsEvaluator:c}},{"./coordinates":15}],18:[function(n,t,e){"use strict";function r(n,t,e){for(var r=null,o=0;o<64;o++){var i=n.board[o];if(null!=i&&i.type===t&&i.side===e){r=o;break}}return r}var o=n("./coordinates"),i=n("./updates"),u=n("./moves-pieces"),a=o.BoardCoordinates;t.exports={getAvailableMoves:function(n,t){if(1!=t){var e=0;if(n.board.forEach(function(n){null!=n&&(e+=1)}),2==e)return[]}var o=[],c=function(t,e,o){var a=i.applyMove(n,t),c=u.computeAllMoves(a),s=r(a,e,o),l=!1;return c.forEach(function(n){n.dst==s&&(l=!0)}),l};return u.computeAllMoves(n).forEach(function(t){var e=new a(t.src),r=new a(t.dst).sub(e),i=c(t,"K",n.turn);"K"==n.board[t.src].type&&2==r.x&&(i=i||n.check||c({src:t.src,dst:t.src+1},"K",n.turn)),"K"==n.board[t.src].type&&-2==r.x&&(i=i||n.check||c({src:t.src,dst:t.src-1},"K",n.turn)),i||o.push(t)}),o},isCurrentPlayerInCheck:function(n){var t=!1,e=n.turn;n.turn="W"===e?"B":"W";for(var r=0;r<=64;r++){var o=n.board[r],i=new a(r);null!=o&&o.side===n.turn&&u.pieceDestinationsEvaluator[o.type](n,i).forEach(function(e){var r=n.board[e.offset];r&&"K"===r.type&&r.side!==n.turn&&(t=!0)})}return n.turn=e,t}}},{"./coordinates":15,"./moves-pieces":17,"./updates":24}],19:[function(n,t,e){"use strict";function r(n){var t="";return t+=String.fromCharCode("a".charCodeAt(0)+n%8),t+=String.fromCharCode("1".charCodeAt(0)+Math.floor(n/8))}var o=n("./moves"),i=n("./updates"),u=n("./pgnParser"),a={"O-O":{W:{src:4,dst:6},B:{src:60,dst:62}},"O-O-O":{W:{src:4,dst:2},B:{src:60,dst:58}}};t.exports={pgnToMove:function(n,t){var e=null,r=a[t];if(r)e=r[n.turn];else{var i=u.parsePgnMove(t);i&&(o.getAvailableMoves(n).forEach(function(t){null!=i.srcCol&&t.src%8!=i.srcCol||null!=i.srcRow&&Math.floor(t.src/8)!=i.srcRow||t.dst==i.dst&&n.board[t.src].type==i.type&&(i.src=t.src)}),null!=i.src&&null!=i.dst&&(e={src:i.src,dst:i.dst},i.promotion&&(e.promotionType=i.promotion)))}return e},moveToPgn:function(n,t){var e="",u=n.board[t.src];if("P"!=u.type&&(e+=u.type),"K"===u.type&&t.dst-t.src==2)return"O-O";if("K"===u.type&&t.dst-t.src==-2)return"O-O-O";var a=[];o.getAvailableMoves(n).forEach(function(e){e.dst==t.dst&&u.type==n.board[e.src].type&&a.push(e.src)});var c=r(t.src);if(a.length>1){var s=0,l=0;a.forEach(function(n){var t=r(n);c[0]==t[0]&&(s+=1),c[1]==t[1]&&(l+=1)}),e+=1==s?c[0]:1==l?c[1]:c}var f=t.dst%8-t.src%8;(null!=n.board[t.dst]||"P"==u.type&&0!=f)&&(""==e&&"P"==u.type&&(e+=c[0]),e+="x"),e+=r(t.dst);var p=i.applyMove(n,t);return"P"==u.type&&(t.dst<8||t.dst>56)&&(e+="="+(t.promotionType?t.promotionType:"Q")),o.isCurrentPlayerInCheck(p)&&(0==o.getAvailableMoves(p).length?e+="#":e+="+"),e}}},{"./moves":18,"./pgnParser":20,"./updates":24}],20:[function(n,t,e){"use strict";function r(n,t){var e=null,r=n.charCodeAt(t)-o,u=n.charCodeAt(t+1)-i;return r>=0&&r<8&&u>=0&&u<8&&(e+=r,e+=8*u),e}var o="a".charCodeAt(0),i="1".charCodeAt(0);t.exports={parsePgnMove:function(n){var t={type:null,srcCol:null,srcRow:null,dst:null,promotion:null,capture:!1,checking:!1,mate:!1},e=0,u=n.length;-1!=["P","R","N","B","K","Q"].indexOf(n[e])?(t.type=n[e],e++):t.type="P";var a=n.indexOf("+"),c=n.indexOf("#"),s=n.indexOf("=");s>=0&&(t.promotion=n.substring(s+1,s+2),u=Math.min(s,u)),a>=0&&(t.checking=!0,u=Math.min(a,u)),c>=0&&(t.mate=!0,u=Math.min(c,u));var l=r(n,u-2);if(null==l)return null;t.dst=l,"x"===n[(u-=2)-1]&&(u-=1,t.capture=!0);for(var f=e;f<u;f++){var p=n.charCodeAt(e),h=p-i,d=p-o;h>=0&&h<8&&(t.srcRow=h),d>=0&&d<8&&(t.srcCol=d)}return t}}},{}],21:[function(n,t,e){"use strict";var r={PW:"♙",PB:"♟",NW:"♘",NB:"♞",BW:"♗",BB:"♝",RW:"♖",RB:"♜",QW:"♕",QB:"♛",KW:"♔",KB:"♚"};t.exports={pieceFactory:function(n,t){return{type:n,side:t}},pieceToUTF8:function(n){return r[n.type.concat(n.side)]}}},{}],22:[function(n,t,e){"use strict";function r(n,t,e,r){return(n+t)%2==0?"W"===e?r.WB:r.BB:"W"===e?r.WW:r.BW}var o=n("./piece");n("colors").setTheme({BW:["black","bgWhite"],BB:["black","bgMagenta"],WW:["white","bgWhite"],WB:["white","bgMagenta"]});var i=n("underscore-plus");t.exports={getInitialPosition:function(){return{turn:"W",castlingFlags:{W:{K:!0,Q:!0},B:{K:!0,Q:!0}},lastPawnMoveColumn:null,check:!1,board:[o.pieceFactory("R","W"),o.pieceFactory("N","W"),o.pieceFactory("B","W"),o.pieceFactory("Q","W"),o.pieceFactory("K","W"),o.pieceFactory("B","W"),o.pieceFactory("N","W"),o.pieceFactory("R","W"),o.pieceFactory("P","W"),o.pieceFactory("P","W"),o.pieceFactory("P","W"),o.pieceFactory("P","W"),o.pieceFactory("P","W"),o.pieceFactory("P","W"),o.pieceFactory("P","W"),o.pieceFactory("P","W"),null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,o.pieceFactory("P","B"),o.pieceFactory("P","B"),o.pieceFactory("P","B"),o.pieceFactory("P","B"),o.pieceFactory("P","B"),o.pieceFactory("P","B"),o.pieceFactory("P","B"),o.pieceFactory("P","B"),o.pieceFactory("R","B"),o.pieceFactory("N","B"),o.pieceFactory("B","B"),o.pieceFactory("Q","B"),o.pieceFactory("K","B"),o.pieceFactory("B","B"),o.pieceFactory("N","B"),o.pieceFactory("R","B")]}},positionToString:function(n,t){var e=[];e.push("W"==n.turn?"WHITE":"BLACK"),e.push(" "),e.push(n.castlingFlags.W.K?"K":""),e.push(n.castlingFlags.W.Q?"Q":""),e.push(n.castlingFlags.B.K?"k":""),e.push(n.castlingFlags.B.Q?"q":"");var i,u;for(i=7;i>=0;i--)for(e.push("\n"),e.push(i+1),e.push(" "),u=0;u<8;u++){var a=n.board[8*i+u];t?null==a?e.push(r(i,u,"W"," ")):e.push(r(i,u,a.side,o.pieceToUTF8(a)+" ")):null==a?e.push(". "):"W"==a.side?e.push(a.type.toUpperCase()+" "):e.push(a.type.toLowerCase()+" ")}return e.push("\n a b c d e f g h "),e.join("")},clone:function(n){return i.deepClone(n)}}},{"./piece":21,colors:5,"underscore-plus":13}],23:[function(n,t,e){"use strict";var r=n("./moves");t.exports={getGameStatus:function(n){var t="OPEN";return 0==r.getAvailableMoves(n).length&&(t=n.check?"W"==n.turn?"BLACKWON":"WHITEWON":"PAT"),t}}},{"./moves":18}],24:[function(n,t,e){"use strict";function r(n,t){var e=[],r=new c(t.src),i=new c(t.dst),u=i.sub(r),s=n.board[t.dst];if(null!=s&&e.push({action:"remove",src:t.dst}),e.push({action:"move",src:t.src,dst:t.dst}),null==s&&"P"==n.board[t.src].type&&Math.abs(u.x)){var l=r.add(new c(u.x,0));e.push({action:"remove",src:l.offset})}if("P"==n.board[t.src].type&&2==Math.abs(u.y)?e.push({action:"pawnColumn",col:t.src%8}):e.push({action:"pawnColumn",col:null}),"P"==n.board[t.src].type&&(0==i.y||7==i.y)){var f=t.promotionType?t.promotionType:"Q";e.push({action:"promote",src:t.dst,promotionType:f})}"K"==n.board[t.src].type&&(e.push({action:"resetCastling",sides:["K","Q"]}),4==r.x&&6==i.x&&e.push({action:"move",src:i.add(new c(1,0)).offset,dst:i.add(new c(-1,0)).offset}),4==r.x&&2==i.x&&e.push({action:"move",src:i.add(new c(-2,0)).offset,dst:i.add(new c(1,0)).offset})),"R"==n.board[t.src].type&&0==r.x&&e.push({action:"resetCastling",sides:["Q"]}),"R"==n.board[t.src].type&&7==r.x&&e.push({action:"resetCastling",sides:["K"]});var p=o(n,e);p.turn=n.turn;var h=!1;return a.computeAllMoves(p).forEach(function(t){var e=n.board[t.dst];e&&"K"==e.type&&e.side!=n.turn&&(h=!0)}),e.push({action:"updateCheckFlag",value:h}),e}function o(n,t){var e=i.clone(n);return t.forEach(function(t){if("remove"===t.action){var r=t.src;e.board[r]=null}else"move"===t.action?(e.board[t.dst]=e.board[t.src],e.board[t.src]=null):"pawnColumn"===t.action?e.lastPawnMoveColumn=t.col:"resetCastling"===t.action?t.sides.forEach(function(t){e.castlingFlags[n.turn][t]=!1}):"updateCheckFlag"===t.action?e.check=t.value:"promote"===t.action&&(e.board[t.src].type=t.promotionType)}),e.turn="W"===n.turn?"B":"W",e}var i=n("./position"),u=n("./coordinates"),a=n("./moves-pieces"),c=u.BoardCoordinates;t.exports={computeDiffs:r,applyDiffs:o,applyMove:function(n,t){return o(n,r(n,t))}}},{"./coordinates":15,"./moves-pieces":17,"./position":22}],25:[function(n,t,e){"use strict";var r=n("./chess/position"),o=n("./chess/moves"),i=n("./chess/updates"),u=n("./chess/pgn"),a=n("./chess/status"),c=n("./chess/locator"),s={getInitialPosition:r.getInitialPosition,positionToString:r.positionToString,getAvailableMoves:o.getAvailableMoves,applyMove:i.applyMove,computeDiffs:i.computeDiffs,applyDiffs:i.applyDiffs,pgnToMove:u.pgnToMove,moveToPgn:u.moveToPgn,getGameStatus:a.getGameStatus,findPiece:c.findPiece};t.exports=s},{"./chess/locator":16,"./chess/moves":18,"./chess/pgn":19,"./chess/position":22,"./chess/status":23,"./chess/updates":24}]},{},[25])(25)}); |
{ | ||
"name": "chess-rules", | ||
"version": "0.11.5", | ||
"version": "1.0.0", | ||
"description": "Chess Rules implementation as a standalone module.", | ||
@@ -29,15 +29,15 @@ "homepage": "https://github.com/chesscorp/chess-rules", | ||
"devDependencies": { | ||
"grunt": "^0.4.0", | ||
"grunt-browserify": "^4.0.0", | ||
"grunt-cli": "^0.1.13", | ||
"grunt-contrib-clean": "^0.6.0", | ||
"grunt-contrib-concat": "^0.5.0", | ||
"grunt-contrib-jshint": "^0.11.0", | ||
"grunt-contrib-nodeunit": "^0.4.1", | ||
"grunt-contrib-uglify": "^0.9.1", | ||
"grunt-contrib-watch": "^0.6.1", | ||
"grunt": "^1.0.1", | ||
"grunt-browserify": "^5.0.0", | ||
"grunt-cli": "^1.2.0", | ||
"grunt-contrib-clean": "^1.1.0", | ||
"grunt-contrib-concat": "^1.0.1", | ||
"grunt-contrib-jshint": "^1.1.0", | ||
"grunt-contrib-nodeunit": "^1.0.0", | ||
"grunt-contrib-uglify": "^3.0.1", | ||
"grunt-contrib-watch": "^1.0.0", | ||
"grunt-mocha-cov": "^0.4.0", | ||
"jshint-stylish": "^2.0.1", | ||
"load-grunt-tasks": "^3.1.0", | ||
"mocha": "^2.2.5", | ||
"mocha": "^3.5.0", | ||
"time-grunt": "^1.1.0" | ||
@@ -44,0 +44,0 @@ }, |
@@ -26,4 +26,4 @@ [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url] [![Coverage Status](https://coveralls.io/repos/ChessCorp/chess-rules/badge.svg?branch=master&service=github)](https://coveralls.io/github/ChessCorp/chess-rules?branch=master) | ||
bower chess-rules#* extract archive.tar.gz | ||
bower chess-rules#* resolved git://github.com/ChessCorp/chess-rules.git#0.10.1 | ||
bower chess-rules#~0.10.1 install chess-rules#0.10.1 | ||
bower chess-rules#* resolved git://github.com/ChessCorp/chess-rules.git#1.0.0 | ||
bower chess-rules#~0.10.1 install chess-rules#1.0.0 | ||
@@ -30,0 +30,0 @@ chess-rules#0.10.1 bower_components/chess-rules |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
189068
2
4069