Socket
Socket
Sign inDemoInstall

chess.js

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chess.js - npm Package Compare versions

Comparing version 0.10.0 to 0.10.1

21

chess.js

@@ -1362,7 +1362,14 @@ /*

for (var i = 0, len = moves.length; i < len; i++) {
if (move_replaced ===
move_to_san(moves[i], sloppy).replace(/=/,'').replace(/[+#]?[?!]*$/,'')) {
// try the strict parser first, then the sloppy parser if requested
// by the user
if ((move_replaced ===
move_to_san(moves[i]).replace(/=/,'').replace(/[+#]?[?!]*$/,'')) ||
(sloppy &&
move_replaced ===
move_to_san(moves[i], sloppy).replace(/=/,'').replace(/[+#]?[?!]*$/,''))) {
return moves[i];
}
}
return null;

@@ -1528,4 +1535,10 @@ }

for (var i = 0, len = moves.length; i < len; i++) {
if (move_replaced ===
move_to_san(moves[i], sloppy).replace(/=/,'').replace(/[+#]?[?!]*$/,'')) {
// try the strict parser first, then the sloppy parser if requested
// by the user
if ((move_replaced ===
move_to_san(moves[i]).replace(/=/,'').replace(/[+#]?[?!]*$/,'')) ||
(sloppy &&
move_replaced ===
move_to_san(moves[i], sloppy).replace(/=/,'').replace(/[+#]?[?!]*$/,''))) {
move_obj = moves[i];

@@ -1532,0 +1545,0 @@ break;

2

chess.min.js

@@ -6,2 +6,2 @@ /* @license

*/
var Chess=function(r){function e(){fr=new Array(128),ar={w:Q,b:Q},ur=K,lr={w:0,b:0},pr=Q,sr=0,cr=1,vr=[],gr={},a(i())}function n(){t(F)}function t(r){var n=r.split(/\s+/),t=n[0],f=0;if(!o(r).valid)return!1;e();for(var u=0;u<t.length;u++){var p=t.charAt(u);if("/"===p)f+=8;else if(R(p))f+=parseInt(p,10);else{var s="a">p?K:D;l({type:p.toLowerCase(),color:s},w(f)),f++}}return ur=n[1],n[2].indexOf("K")>-1&&(lr.w|=Y.KSIDE_CASTLE),n[2].indexOf("Q")>-1&&(lr.w|=Y.QSIDE_CASTLE),n[2].indexOf("k")>-1&&(lr.b|=Y.KSIDE_CASTLE),n[2].indexOf("q")>-1&&(lr.b|=Y.QSIDE_CASTLE),pr="-"===n[3]?Q:or[n[3]],sr=parseInt(n[4],10),cr=parseInt(n[5],10),a(i()),!0}function o(r){var e={0:"No errors.",1:"FEN string must contain six space-delimited fields.",2:"6th field (move number) must be a positive integer.",3:"5th field (half move counter) must be a non-negative integer.",4:"4th field (en-passant square) is invalid.",5:"3rd field (castling availability) is invalid.",6:"2nd field (side to move) is invalid.",7:"1st field (piece positions) does not contain 8 '/'-delimited rows.",8:"1st field (piece positions) is invalid [consecutive numbers].",9:"1st field (piece positions) is invalid [invalid piece].",10:"1st field (piece positions) is invalid [row too large].",11:"Illegal en-passant square"},n=r.split(/\s+/);if(6!==n.length)return{valid:!1,error_number:1,error:e[1]};if(isNaN(n[5])||parseInt(n[5],10)<=0)return{valid:!1,error_number:2,error:e[2]};if(isNaN(n[4])||parseInt(n[4],10)<0)return{valid:!1,error_number:3,error:e[3]};if(!/^(-|[abcdefgh][36])$/.test(n[3]))return{valid:!1,error_number:4,error:e[4]};if(!/^(KQ?k?q?|Qk?q?|kq?|q|-)$/.test(n[2]))return{valid:!1,error_number:5,error:e[5]};if(!/^(w|b)$/.test(n[1]))return{valid:!1,error_number:6,error:e[6]};var t=n[0].split("/");if(8!==t.length)return{valid:!1,error_number:7,error:e[7]};for(var o=0;o<t.length;o++){for(var i=0,f=!1,a=0;a<t[o].length;a++)if(isNaN(t[o][a])){if(!/^[prnbqkPRNBQK]$/.test(t[o][a]))return{valid:!1,error_number:9,error:e[9]};i+=1,f=!1}else{if(f)return{valid:!1,error_number:8,error:e[8]};i+=parseInt(t[o][a],10),f=!0}if(8!==i)return{valid:!1,error_number:10,error:e[10]}}return"3"==n[3][1]&&"w"==n[1]||"6"==n[3][1]&&"b"==n[1]?{valid:!1,error_number:11,error:e[11]}:{valid:!0,error_number:0,error:e[0]}}function i(){for(var r=0,e="",n=or.a8;n<=or.h1;n++){if(null==fr[n])r++;else{r>0&&(e+=r,r=0);var t=fr[n].color,o=fr[n].type;e+=t===K?o.toUpperCase():o.toLowerCase()}n+1&136&&(r>0&&(e+=r),n!==or.h1&&(e+="/"),r=0,n+=8)}var i="";lr[K]&Y.KSIDE_CASTLE&&(i+="K"),lr[K]&Y.QSIDE_CASTLE&&(i+="Q"),lr[D]&Y.KSIDE_CASTLE&&(i+="k"),lr[D]&Y.QSIDE_CASTLE&&(i+="q"),i=i||"-";var f=pr===Q?"-":w(pr);return[e,ur,i,f,sr,cr].join(" ")}function f(r){for(var e=0;e<r.length;e+=2)"string"==typeof r[e]&&"string"==typeof r[e+1]&&(gr[r[e]]=r[e+1]);return gr}function a(r){vr.length>0||(r!==F?(gr.SetUp="1",gr.FEN=r):(delete gr.SetUp,delete gr.FEN))}function u(r){var e=fr[or[r]];return e?{type:e.type,color:e.color}:null}function l(r,e){if(!("type"in r&&"color"in r))return!1;if(-1===G.indexOf(r.type.toLowerCase()))return!1;if(!(e in or))return!1;var n=or[e];return r.type==M&&ar[r.color]!=Q&&ar[r.color]!=n?!1:(fr[n]={type:r.type,color:r.color},r.type===M&&(ar[r.color]=n),a(i()),!0)}function p(r){var e=u(r);return fr[or[r]]=null,e&&e.type===M&&(ar[e.color]=Q),a(i()),e}function s(r,e,n,t,o){var i={color:ur,from:e,to:n,flags:t,piece:r[e].type};return o&&(i.flags|=Y.PROMOTION,i.promotion=o),r[n]?i.captured=r[n].type:t&Y.EP_CAPTURE&&(i.captured=U),i}function c(r){function e(r,e,n,t,o){if(r[n].type!==U||I(t)!==tr&&I(t)!==rr)e.push(s(r,n,t,o));else for(var i=[B,j,$,x],f=0,a=i.length;a>f;f++)e.push(s(r,n,t,o,i[f]))}var n=[],t=ur,o=L(t),i={b:nr,w:er},f=or.a8,a=or.h1,u=!1,l="undefined"!=typeof r&&"legal"in r?r.legal:!0;if("undefined"!=typeof r&&"square"in r){if(!(r.square in or))return[];f=a=or[r.square],u=!0}for(var p=f;a>=p;p++)if(136&p)p+=7;else{var c=fr[p];if(null!=c&&c.color===t)if(c.type===U){var v=p+H[t][0];if(null==fr[v]){e(fr,n,p,v,Y.NORMAL);var v=p+H[t][1];i[t]===I(p)&&null==fr[v]&&e(fr,n,p,v,Y.BIG_PAWN)}for(d=2;4>d;d++){var v=p+H[t][d];136&v||(null!=fr[v]&&fr[v].color===o?e(fr,n,p,v,Y.CAPTURE):v===pr&&e(fr,n,p,pr,Y.EP_CAPTURE))}}else for(var d=0,E=Z[c.type].length;E>d;d++)for(var b=Z[c.type][d],v=p;;){if(v+=b,136&v)break;if(null!=fr[v]){if(fr[v].color===t)break;e(fr,n,p,v,Y.CAPTURE);break}if(e(fr,n,p,v,Y.NORMAL),"n"===c.type||"k"===c.type)break}}if(!u||a===ar[t]){if(lr[t]&Y.KSIDE_CASTLE){var _=ar[t],y=_+2;null!=fr[_+1]||null!=fr[y]||g(o,ar[t])||g(o,_+1)||g(o,y)||e(fr,n,ar[t],y,Y.KSIDE_CASTLE)}if(lr[t]&Y.QSIDE_CASTLE){var _=ar[t],y=_-2;null!=fr[_-1]||null!=fr[_-2]||null!=fr[_-3]||g(o,ar[t])||g(o,_-1)||g(o,y)||e(fr,n,ar[t],y,Y.QSIDE_CASTLE)}}if(!l)return n;for(var A=[],p=0,E=n.length;E>p;p++)S(n[p]),h(t)||A.push(n[p]),m();return A}function v(r,e){var n="";if(r.flags&Y.KSIDE_CASTLE)n="O-O";else if(r.flags&Y.QSIDE_CASTLE)n="O-O-O";else{var t=C(r,e);r.piece!==U&&(n+=r.piece.toUpperCase()+t),r.flags&(Y.CAPTURE|Y.EP_CAPTURE)&&(r.piece===U&&(n+=w(r.from)[0]),n+="x"),n+=w(r.to),r.flags&Y.PROMOTION&&(n+="="+r.promotion.toUpperCase())}return S(r),d()&&(n+=E()?"#":"+"),m(),n}function g(r,e){for(var n=or.a8;n<=or.h1;n++)if(136&n)n+=7;else if(null!=fr[n]&&fr[n].color===r){var t=fr[n],o=n-e,i=o+119;if(z[i]&1<<V[t.type]){if(t.type===U){if(o>0){if(t.color===K)return!0}else if(t.color===D)return!0;continue}if("n"===t.type||"k"===t.type)return!0;for(var f=J[i],a=n+f,u=!1;a!==e;){if(null!=fr[a]){u=!0;break}a+=f}if(!u)return!0}}return!1}function h(r){return g(L(r),ar[r])}function d(){return h(ur)}function E(){return d()&&0===c().length}function b(){return!d()&&0===c().length}function _(){for(var r={},e=[],n=0,t=0,o=or.a8;o<=or.h1;o++)if(t=(t+1)%2,136&o)o+=7;else{var i=fr[o];i&&(r[i.type]=i.type in r?r[i.type]+1:1,i.type===$&&e.push(t),n++)}if(2===n)return!0;if(3===n&&(1===r[$]||1===r[x]))return!0;if(n===r[$]+2){for(var f=0,a=e.length,o=0;a>o;o++)f+=e[o];if(0===f||f===a)return!0}return!1}function y(){for(var r=[],e={},n=!1;;){var t=m();if(!t)break;r.push(t)}for(;;){var o=i().split(" ").slice(0,4).join(" ");if(e[o]=o in e?e[o]+1:1,e[o]>=3&&(n=!0),!r.length)break;S(r.pop())}return n}function A(r){vr.push({move:r,kings:{b:ar.b,w:ar.w},turn:ur,castling:{b:lr.b,w:lr.w},ep_square:pr,half_moves:sr,move_number:cr})}function S(r){var e=ur,n=L(e);if(A(r),fr[r.to]=fr[r.from],fr[r.from]=null,r.flags&Y.EP_CAPTURE&&(ur===D?fr[r.to-16]=null:fr[r.to+16]=null),r.flags&Y.PROMOTION&&(fr[r.to]={type:r.promotion,color:e}),fr[r.to].type===M){if(ar[fr[r.to].color]=r.to,r.flags&Y.KSIDE_CASTLE){var t=r.to-1,o=r.to+1;fr[t]=fr[o],fr[o]=null}else if(r.flags&Y.QSIDE_CASTLE){var t=r.to+1,o=r.to-2;fr[t]=fr[o],fr[o]=null}lr[e]=""}if(lr[e])for(var i=0,f=ir[e].length;f>i;i++)if(r.from===ir[e][i].square&&lr[e]&ir[e][i].flag){lr[e]^=ir[e][i].flag;break}if(lr[n])for(var i=0,f=ir[n].length;f>i;i++)if(r.to===ir[n][i].square&&lr[n]&ir[n][i].flag){lr[n]^=ir[n][i].flag;break}pr=r.flags&Y.BIG_PAWN?"b"===ur?r.to-16:r.to+16:Q,r.piece===U?sr=0:r.flags&(Y.CAPTURE|Y.EP_CAPTURE)?sr=0:sr++,ur===D&&cr++,ur=L(ur)}function m(){var r=vr.pop();if(null==r)return null;var e=r.move;ar=r.kings,ur=r.turn,lr=r.castling,pr=r.ep_square,sr=r.half_moves,cr=r.move_number;var n=ur,t=L(ur);if(fr[e.from]=fr[e.to],fr[e.from].type=e.piece,fr[e.to]=null,e.flags&Y.CAPTURE)fr[e.to]={type:e.captured,color:t};else if(e.flags&Y.EP_CAPTURE){var o;o=n===D?e.to-16:e.to+16,fr[o]={type:U,color:t}}if(e.flags&(Y.KSIDE_CASTLE|Y.QSIDE_CASTLE)){var i,f;e.flags&Y.KSIDE_CASTLE?(i=e.to+1,f=e.to-1):e.flags&Y.QSIDE_CASTLE&&(i=e.to-2,f=e.to+1),fr[i]=fr[f],fr[f]=null}return e}function C(r,e){for(var n=c({legal:!e}),t=r.from,o=r.to,i=r.piece,f=0,a=0,u=0,l=0,p=n.length;p>l;l++){var s=n[l].from,v=n[l].to,g=n[l].piece;i===g&&t!==s&&o===v&&(f++,I(t)===I(s)&&a++,P(t)===P(s)&&u++)}return f>0?a>0&&u>0?w(t):w(t).charAt(u>0?1:0):""}function T(){for(var r=" +------------------------+\n",e=or.a8;e<=or.h1;e++){if(0===P(e)&&(r+=" "+"87654321"[I(e)]+" |"),null==fr[e])r+=" . ";else{var n=fr[e].type,t=fr[e].color,o=t===K?n.toUpperCase():n.toLowerCase();r+=" "+o+" "}e+1&136&&(r+="|\n",e+=8)}return r+=" +------------------------+\n",r+=" a b c d e f g h\n"}function I(r){return r>>4}function P(r){return 15&r}function w(r){var e=P(r),n=I(r);return"abcdefgh".substring(e,e+1)+"87654321".substring(n,n+1)}function L(r){return r===K?D:K}function R(r){return-1!=="0123456789".indexOf(r)}function O(r){var e=N(r);e.san=v(e,!1),e.to=w(e.to),e.from=w(e.from);var n="";for(var t in Y)Y[t]&e.flags&&(n+=X[t]);return e.flags=n,e}function N(r){var e=r instanceof Array?[]:{};for(var n in r)"object"==typeof n?e[n]=N(r[n]):e[n]=r[n];return e}function k(r){return r.replace(/^\s+|\s+$/g,"")}function q(r){for(var e=c({legal:!1}),n=0,t=ur,o=0,i=e.length;i>o;o++){if(S(e[o]),!h(t))if(r-1>0){var f=q(r-1);n+=f}else n++;m()}return n}var D="b",K="w",Q=-1,U="p",x="n",$="b",j="r",B="q",M="k",G="pnbrqkPNBRQK",F="rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",W=["1-0","0-1","1/2-1/2","*"],H={b:[16,32,17,15],w:[-16,-32,-17,-15]},Z={n:[-18,-33,-31,-14,18,33,31,14],b:[-17,-15,17,15],r:[-16,1,16,-1],q:[-17,-16,-15,1,17,16,15,-1],k:[-17,-16,-15,1,17,16,15,-1]},z=[20,0,0,0,0,0,0,24,0,0,0,0,0,0,20,0,0,20,0,0,0,0,0,24,0,0,0,0,0,20,0,0,0,0,20,0,0,0,0,24,0,0,0,0,20,0,0,0,0,0,0,20,0,0,0,24,0,0,0,20,0,0,0,0,0,0,0,0,20,0,0,24,0,0,20,0,0,0,0,0,0,0,0,0,0,20,2,24,2,20,0,0,0,0,0,0,0,0,0,0,0,2,53,56,53,2,0,0,0,0,0,0,24,24,24,24,24,24,56,0,56,24,24,24,24,24,24,0,0,0,0,0,0,2,53,56,53,2,0,0,0,0,0,0,0,0,0,0,0,20,2,24,2,20,0,0,0,0,0,0,0,0,0,0,20,0,0,24,0,0,20,0,0,0,0,0,0,0,0,20,0,0,0,24,0,0,0,20,0,0,0,0,0,0,20,0,0,0,0,24,0,0,0,0,20,0,0,0,0,20,0,0,0,0,0,24,0,0,0,0,0,20,0,0,20,0,0,0,0,0,0,24,0,0,0,0,0,0,20],J=[17,0,0,0,0,0,0,16,0,0,0,0,0,0,15,0,0,17,0,0,0,0,0,16,0,0,0,0,0,15,0,0,0,0,17,0,0,0,0,16,0,0,0,0,15,0,0,0,0,0,0,17,0,0,0,16,0,0,0,15,0,0,0,0,0,0,0,0,17,0,0,16,0,0,15,0,0,0,0,0,0,0,0,0,0,17,0,16,0,15,0,0,0,0,0,0,0,0,0,0,0,0,17,16,15,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,-1,-1,-1,-1,-1,-1,-1,0,0,0,0,0,0,0,-15,-16,-17,0,0,0,0,0,0,0,0,0,0,0,0,-15,0,-16,0,-17,0,0,0,0,0,0,0,0,0,0,-15,0,0,-16,0,0,-17,0,0,0,0,0,0,0,0,-15,0,0,0,-16,0,0,0,-17,0,0,0,0,0,0,-15,0,0,0,0,-16,0,0,0,0,-17,0,0,0,0,-15,0,0,0,0,0,-16,0,0,0,0,0,-17,0,0,-15,0,0,0,0,0,0,-16,0,0,0,0,0,0,-17],V={p:0,n:1,b:2,r:3,q:4,k:5},X={NORMAL:"n",CAPTURE:"c",BIG_PAWN:"b",EP_CAPTURE:"e",PROMOTION:"p",KSIDE_CASTLE:"k",QSIDE_CASTLE:"q"},Y={NORMAL:1,CAPTURE:2,BIG_PAWN:4,EP_CAPTURE:8,PROMOTION:16,KSIDE_CASTLE:32,QSIDE_CASTLE:64},rr=7,er=6,nr=1,tr=0,or={a8:0,b8:1,c8:2,d8:3,e8:4,f8:5,g8:6,h8:7,a7:16,b7:17,c7:18,d7:19,e7:20,f7:21,g7:22,h7:23,a6:32,b6:33,c6:34,d6:35,e6:36,f6:37,g6:38,h6:39,a5:48,b5:49,c5:50,d5:51,e5:52,f5:53,g5:54,h5:55,a4:64,b4:65,c4:66,d4:67,e4:68,f4:69,g4:70,h4:71,a3:80,b3:81,c3:82,d3:83,e3:84,f3:85,g3:86,h3:87,a2:96,b2:97,c2:98,d2:99,e2:100,f2:101,g2:102,h2:103,a1:112,b1:113,c1:114,d1:115,e1:116,f1:117,g1:118,h1:119},ir={w:[{square:or.a1,flag:Y.QSIDE_CASTLE},{square:or.h1,flag:Y.KSIDE_CASTLE}],b:[{square:or.a8,flag:Y.QSIDE_CASTLE},{square:or.h8,flag:Y.KSIDE_CASTLE}]},fr=new Array(128),ar={w:Q,b:Q},ur=K,lr={w:0,b:0},pr=Q,sr=0,cr=1,vr=[],gr={};return t("undefined"==typeof r?F:r),{WHITE:K,BLACK:D,PAWN:U,KNIGHT:x,BISHOP:$,ROOK:j,QUEEN:B,KING:M,SQUARES:function(){for(var r=[],e=or.a8;e<=or.h1;e++)136&e?e+=7:r.push(w(e));return r}(),FLAGS:X,load:function(r){return t(r)},reset:function(){return n()},moves:function(r){for(var e=c(r),n=[],t=0,o=e.length;o>t;t++)n.push("undefined"!=typeof r&&"verbose"in r&&r.verbose?O(e[t]):v(e[t],!1));return n},in_check:function(){return d()},in_checkmate:function(){return E()},in_stalemate:function(){return b()},in_draw:function(){return sr>=100||b()||_()||y()},insufficient_material:function(){return _()},in_threefold_repetition:function(){return y()},game_over:function(){return sr>=100||E()||b()||_()||y()},validate_fen:function(r){return o(r)},fen:function(){return i()},pgn:function(r){var e="object"==typeof r&&"string"==typeof r.newline_char?r.newline_char:"\n",n="object"==typeof r&&"number"==typeof r.max_width?r.max_width:0,t=[],o=!1;for(var i in gr)t.push("["+i+' "'+gr[i]+'"]'+e),o=!0;o&&vr.length&&t.push(e);for(var f=[];vr.length>0;)f.push(m());for(var a=[],u="";f.length>0;){var l=f.pop();vr.length||"b"!==l.color?"w"===l.color&&(u.length&&a.push(u),u=cr+"."):u=cr+". ...",u=u+" "+v(l,!1),S(l)}if(u.length&&a.push(u),"undefined"!=typeof gr.Result&&a.push(gr.Result),0===n)return t.join("")+a.join(" ");for(var p=0,i=0;i<a.length;i++)p+a[i].length>n&&0!==i?(" "===t[t.length-1]&&t.pop(),t.push(e),p=0):0!==i&&(t.push(" "),p++),t.push(a[i]),p+=a[i].length;return t.join("")},load_pgn:function(r,e){function o(r){return r.replace(/\\/g,"\\")}function i(r){for(var e=r.replace(/=/,"").replace(/[+#]?[?!]*$/,""),n=c(),t=0,o=n.length;o>t;t++)if(e===v(n[t],p).replace(/=/,"").replace(/[+#]?[?!]*$/,""))return n[t];return null}function a(r){return i(k(r))}function u(r){for(var e in r)return!0;return!1}function l(r,e){for(var n="object"==typeof e&&"string"==typeof e.newline_char?e.newline_char:"\r?\n",t={},i=r.split(new RegExp(o(n))),f="",a="",u=0;u<i.length;u++)f=i[u].replace(/^\[([A-Z][A-Za-z]*)\s.*\]$/,"$1"),a=i[u].replace(/^\[[A-Za-z]+\s"(.*)"\]$/,"$1"),k(f).length>0&&(t[f]=a);return t}var p="undefined"!=typeof e&&"sloppy"in e?e.sloppy:!1,s="object"==typeof e&&"string"==typeof e.newline_char?e.newline_char:"\r?\n",g=new RegExp("^(\\[(.|"+o(s)+")*\\])("+o(s)+")*1.("+o(s)+"|.)*$","g"),h=r.replace(g,"$1");"["!==h[0]&&(h=""),n();var d=l(h,e);for(var E in d)f([E,d[E]]);if("1"===d.SetUp&&!("FEN"in d&&t(d.FEN)))return!1;var b=r.replace(h,"").replace(new RegExp(o(s),"g")," ");b=b.replace(/(\{[^}]+\})+?/g,"");for(var _=/(\([^\(\)]+\))+?/g;_.test(b);)b=b.replace(_,"");b=b.replace(/\d+\.(\.\.)?/g,""),b=b.replace(/\.\.\./g,""),b=b.replace(/\$\d+/g,"");var y=k(b).split(new RegExp(/\s+/));y=y.join(",").replace(/,,+/g,",").split(",");for(var A="",m=0;m<y.length-1;m++){if(A=a(y[m]),null==A)return!1;S(A)}if(A=y[y.length-1],W.indexOf(A)>-1)u(gr)&&"undefined"==typeof gr.Result&&f(["Result",A]);else{if(A=a(A),null==A)return!1;S(A)}return!0},header:function(){return f(arguments)},ascii:function(){return T()},turn:function(){return ur},move:function(r,e){var n="undefined"!=typeof e&&"sloppy"in e?e.sloppy:!1,t=null,o=c();if("string"==typeof r){for(var i=r.replace(/=/,"").replace(/[+#]?[?!]*$/,""),f=0,a=o.length;a>f;f++)if(i===v(o[f],n).replace(/=/,"").replace(/[+#]?[?!]*$/,"")){t=o[f];break}}else if("object"==typeof r)for(var f=0,a=o.length;a>f;f++)if(!(r.from!==w(o[f].from)||r.to!==w(o[f].to)||"promotion"in o[f]&&r.promotion!==o[f].promotion)){t=o[f];break}if(!t)return null;var u=O(t);return S(t),u},undo:function(){var r=m();return r?O(r):null},clear:function(){return e()},put:function(r,e){return l(r,e)},get:function(r){return u(r)},remove:function(r){return p(r)},perft:function(r){return q(r)},square_color:function(r){if(r in or){var e=or[r];return(I(e)+P(e))%2===0?"light":"dark"}return null},history:function(r){for(var e=[],n=[],t=("undefined"!=typeof r&&"verbose"in r&&r.verbose);vr.length>0;)e.push(m());for(;e.length>0;){var o=e.pop();n.push(t?O(o):v(o)),S(o)}return n}}};"undefined"!=typeof exports&&(exports.Chess=Chess),"undefined"!=typeof define&&define(function(){return Chess});
var Chess=function(r){function e(){fr=new Array(128),ar={w:Q,b:Q},lr=K,ur={w:0,b:0},pr=Q,sr=0,cr=1,vr=[],gr={},a(i())}function n(){t(F)}function t(r){var n=r.split(/\s+/),t=n[0],f=0;if(!o(r).valid)return!1;e();for(var l=0;l<t.length;l++){var p=t.charAt(l);if("/"===p)f+=8;else if(R(p))f+=parseInt(p,10);else{var s="a">p?K:D;u({type:p.toLowerCase(),color:s},w(f)),f++}}return lr=n[1],n[2].indexOf("K")>-1&&(ur.w|=Y.KSIDE_CASTLE),n[2].indexOf("Q")>-1&&(ur.w|=Y.QSIDE_CASTLE),n[2].indexOf("k")>-1&&(ur.b|=Y.KSIDE_CASTLE),n[2].indexOf("q")>-1&&(ur.b|=Y.QSIDE_CASTLE),pr="-"===n[3]?Q:or[n[3]],sr=parseInt(n[4],10),cr=parseInt(n[5],10),a(i()),!0}function o(r){var e={0:"No errors.",1:"FEN string must contain six space-delimited fields.",2:"6th field (move number) must be a positive integer.",3:"5th field (half move counter) must be a non-negative integer.",4:"4th field (en-passant square) is invalid.",5:"3rd field (castling availability) is invalid.",6:"2nd field (side to move) is invalid.",7:"1st field (piece positions) does not contain 8 '/'-delimited rows.",8:"1st field (piece positions) is invalid [consecutive numbers].",9:"1st field (piece positions) is invalid [invalid piece].",10:"1st field (piece positions) is invalid [row too large].",11:"Illegal en-passant square"},n=r.split(/\s+/);if(6!==n.length)return{valid:!1,error_number:1,error:e[1]};if(isNaN(n[5])||parseInt(n[5],10)<=0)return{valid:!1,error_number:2,error:e[2]};if(isNaN(n[4])||parseInt(n[4],10)<0)return{valid:!1,error_number:3,error:e[3]};if(!/^(-|[abcdefgh][36])$/.test(n[3]))return{valid:!1,error_number:4,error:e[4]};if(!/^(KQ?k?q?|Qk?q?|kq?|q|-)$/.test(n[2]))return{valid:!1,error_number:5,error:e[5]};if(!/^(w|b)$/.test(n[1]))return{valid:!1,error_number:6,error:e[6]};var t=n[0].split("/");if(8!==t.length)return{valid:!1,error_number:7,error:e[7]};for(var o=0;o<t.length;o++){for(var i=0,f=!1,a=0;a<t[o].length;a++)if(isNaN(t[o][a])){if(!/^[prnbqkPRNBQK]$/.test(t[o][a]))return{valid:!1,error_number:9,error:e[9]};i+=1,f=!1}else{if(f)return{valid:!1,error_number:8,error:e[8]};i+=parseInt(t[o][a],10),f=!0}if(8!==i)return{valid:!1,error_number:10,error:e[10]}}return"3"==n[3][1]&&"w"==n[1]||"6"==n[3][1]&&"b"==n[1]?{valid:!1,error_number:11,error:e[11]}:{valid:!0,error_number:0,error:e[0]}}function i(){for(var r=0,e="",n=or.a8;n<=or.h1;n++){if(null==fr[n])r++;else{r>0&&(e+=r,r=0);var t=fr[n].color,o=fr[n].type;e+=t===K?o.toUpperCase():o.toLowerCase()}n+1&136&&(r>0&&(e+=r),n!==or.h1&&(e+="/"),r=0,n+=8)}var i="";ur[K]&Y.KSIDE_CASTLE&&(i+="K"),ur[K]&Y.QSIDE_CASTLE&&(i+="Q"),ur[D]&Y.KSIDE_CASTLE&&(i+="k"),ur[D]&Y.QSIDE_CASTLE&&(i+="q"),i=i||"-";var f=pr===Q?"-":w(pr);return[e,lr,i,f,sr,cr].join(" ")}function f(r){for(var e=0;e<r.length;e+=2)"string"==typeof r[e]&&"string"==typeof r[e+1]&&(gr[r[e]]=r[e+1]);return gr}function a(r){vr.length>0||(r!==F?(gr.SetUp="1",gr.FEN=r):(delete gr.SetUp,delete gr.FEN))}function l(r){var e=fr[or[r]];return e?{type:e.type,color:e.color}:null}function u(r,e){if(!("type"in r&&"color"in r))return!1;if(-1===G.indexOf(r.type.toLowerCase()))return!1;if(!(e in or))return!1;var n=or[e];return r.type==M&&ar[r.color]!=Q&&ar[r.color]!=n?!1:(fr[n]={type:r.type,color:r.color},r.type===M&&(ar[r.color]=n),a(i()),!0)}function p(r){var e=l(r);return fr[or[r]]=null,e&&e.type===M&&(ar[e.color]=Q),a(i()),e}function s(r,e,n,t,o){var i={color:lr,from:e,to:n,flags:t,piece:r[e].type};return o&&(i.flags|=Y.PROMOTION,i.promotion=o),r[n]?i.captured=r[n].type:t&Y.EP_CAPTURE&&(i.captured=U),i}function c(r){function e(r,e,n,t,o){if(r[n].type!==U||I(t)!==tr&&I(t)!==rr)e.push(s(r,n,t,o));else for(var i=[B,j,x,$],f=0,a=i.length;a>f;f++)e.push(s(r,n,t,o,i[f]))}var n=[],t=lr,o=L(t),i={b:nr,w:er},f=or.a8,a=or.h1,l=!1,u="undefined"!=typeof r&&"legal"in r?r.legal:!0;if("undefined"!=typeof r&&"square"in r){if(!(r.square in or))return[];f=a=or[r.square],l=!0}for(var p=f;a>=p;p++)if(136&p)p+=7;else{var c=fr[p];if(null!=c&&c.color===t)if(c.type===U){var v=p+H[t][0];if(null==fr[v]){e(fr,n,p,v,Y.NORMAL);var v=p+H[t][1];i[t]===I(p)&&null==fr[v]&&e(fr,n,p,v,Y.BIG_PAWN)}for(d=2;4>d;d++){var v=p+H[t][d];136&v||(null!=fr[v]&&fr[v].color===o?e(fr,n,p,v,Y.CAPTURE):v===pr&&e(fr,n,p,pr,Y.EP_CAPTURE))}}else for(var d=0,E=Z[c.type].length;E>d;d++)for(var b=Z[c.type][d],v=p;;){if(v+=b,136&v)break;if(null!=fr[v]){if(fr[v].color===t)break;e(fr,n,p,v,Y.CAPTURE);break}if(e(fr,n,p,v,Y.NORMAL),"n"===c.type||"k"===c.type)break}}if(!l||a===ar[t]){if(ur[t]&Y.KSIDE_CASTLE){var _=ar[t],y=_+2;null!=fr[_+1]||null!=fr[y]||g(o,ar[t])||g(o,_+1)||g(o,y)||e(fr,n,ar[t],y,Y.KSIDE_CASTLE)}if(ur[t]&Y.QSIDE_CASTLE){var _=ar[t],y=_-2;null!=fr[_-1]||null!=fr[_-2]||null!=fr[_-3]||g(o,ar[t])||g(o,_-1)||g(o,y)||e(fr,n,ar[t],y,Y.QSIDE_CASTLE)}}if(!u)return n;for(var A=[],p=0,E=n.length;E>p;p++)S(n[p]),h(t)||A.push(n[p]),m();return A}function v(r,e){var n="";if(r.flags&Y.KSIDE_CASTLE)n="O-O";else if(r.flags&Y.QSIDE_CASTLE)n="O-O-O";else{var t=C(r,e);r.piece!==U&&(n+=r.piece.toUpperCase()+t),r.flags&(Y.CAPTURE|Y.EP_CAPTURE)&&(r.piece===U&&(n+=w(r.from)[0]),n+="x"),n+=w(r.to),r.flags&Y.PROMOTION&&(n+="="+r.promotion.toUpperCase())}return S(r),d()&&(n+=E()?"#":"+"),m(),n}function g(r,e){for(var n=or.a8;n<=or.h1;n++)if(136&n)n+=7;else if(null!=fr[n]&&fr[n].color===r){var t=fr[n],o=n-e,i=o+119;if(z[i]&1<<V[t.type]){if(t.type===U){if(o>0){if(t.color===K)return!0}else if(t.color===D)return!0;continue}if("n"===t.type||"k"===t.type)return!0;for(var f=J[i],a=n+f,l=!1;a!==e;){if(null!=fr[a]){l=!0;break}a+=f}if(!l)return!0}}return!1}function h(r){return g(L(r),ar[r])}function d(){return h(lr)}function E(){return d()&&0===c().length}function b(){return!d()&&0===c().length}function _(){for(var r={},e=[],n=0,t=0,o=or.a8;o<=or.h1;o++)if(t=(t+1)%2,136&o)o+=7;else{var i=fr[o];i&&(r[i.type]=i.type in r?r[i.type]+1:1,i.type===x&&e.push(t),n++)}if(2===n)return!0;if(3===n&&(1===r[x]||1===r[$]))return!0;if(n===r[x]+2){for(var f=0,a=e.length,o=0;a>o;o++)f+=e[o];if(0===f||f===a)return!0}return!1}function y(){for(var r=[],e={},n=!1;;){var t=m();if(!t)break;r.push(t)}for(;;){var o=i().split(" ").slice(0,4).join(" ");if(e[o]=o in e?e[o]+1:1,e[o]>=3&&(n=!0),!r.length)break;S(r.pop())}return n}function A(r){vr.push({move:r,kings:{b:ar.b,w:ar.w},turn:lr,castling:{b:ur.b,w:ur.w},ep_square:pr,half_moves:sr,move_number:cr})}function S(r){var e=lr,n=L(e);if(A(r),fr[r.to]=fr[r.from],fr[r.from]=null,r.flags&Y.EP_CAPTURE&&(lr===D?fr[r.to-16]=null:fr[r.to+16]=null),r.flags&Y.PROMOTION&&(fr[r.to]={type:r.promotion,color:e}),fr[r.to].type===M){if(ar[fr[r.to].color]=r.to,r.flags&Y.KSIDE_CASTLE){var t=r.to-1,o=r.to+1;fr[t]=fr[o],fr[o]=null}else if(r.flags&Y.QSIDE_CASTLE){var t=r.to+1,o=r.to-2;fr[t]=fr[o],fr[o]=null}ur[e]=""}if(ur[e])for(var i=0,f=ir[e].length;f>i;i++)if(r.from===ir[e][i].square&&ur[e]&ir[e][i].flag){ur[e]^=ir[e][i].flag;break}if(ur[n])for(var i=0,f=ir[n].length;f>i;i++)if(r.to===ir[n][i].square&&ur[n]&ir[n][i].flag){ur[n]^=ir[n][i].flag;break}pr=r.flags&Y.BIG_PAWN?"b"===lr?r.to-16:r.to+16:Q,r.piece===U?sr=0:r.flags&(Y.CAPTURE|Y.EP_CAPTURE)?sr=0:sr++,lr===D&&cr++,lr=L(lr)}function m(){var r=vr.pop();if(null==r)return null;var e=r.move;ar=r.kings,lr=r.turn,ur=r.castling,pr=r.ep_square,sr=r.half_moves,cr=r.move_number;var n=lr,t=L(lr);if(fr[e.from]=fr[e.to],fr[e.from].type=e.piece,fr[e.to]=null,e.flags&Y.CAPTURE)fr[e.to]={type:e.captured,color:t};else if(e.flags&Y.EP_CAPTURE){var o;o=n===D?e.to-16:e.to+16,fr[o]={type:U,color:t}}if(e.flags&(Y.KSIDE_CASTLE|Y.QSIDE_CASTLE)){var i,f;e.flags&Y.KSIDE_CASTLE?(i=e.to+1,f=e.to-1):e.flags&Y.QSIDE_CASTLE&&(i=e.to-2,f=e.to+1),fr[i]=fr[f],fr[f]=null}return e}function C(r,e){for(var n=c({legal:!e}),t=r.from,o=r.to,i=r.piece,f=0,a=0,l=0,u=0,p=n.length;p>u;u++){var s=n[u].from,v=n[u].to,g=n[u].piece;i===g&&t!==s&&o===v&&(f++,I(t)===I(s)&&a++,P(t)===P(s)&&l++)}return f>0?a>0&&l>0?w(t):w(t).charAt(l>0?1:0):""}function T(){for(var r=" +------------------------+\n",e=or.a8;e<=or.h1;e++){if(0===P(e)&&(r+=" "+"87654321"[I(e)]+" |"),null==fr[e])r+=" . ";else{var n=fr[e].type,t=fr[e].color,o=t===K?n.toUpperCase():n.toLowerCase();r+=" "+o+" "}e+1&136&&(r+="|\n",e+=8)}return r+=" +------------------------+\n",r+=" a b c d e f g h\n"}function I(r){return r>>4}function P(r){return 15&r}function w(r){var e=P(r),n=I(r);return"abcdefgh".substring(e,e+1)+"87654321".substring(n,n+1)}function L(r){return r===K?D:K}function R(r){return-1!=="0123456789".indexOf(r)}function O(r){var e=N(r);e.san=v(e,!1),e.to=w(e.to),e.from=w(e.from);var n="";for(var t in Y)Y[t]&e.flags&&(n+=X[t]);return e.flags=n,e}function N(r){var e=r instanceof Array?[]:{};for(var n in r)"object"==typeof n?e[n]=N(r[n]):e[n]=r[n];return e}function k(r){return r.replace(/^\s+|\s+$/g,"")}function q(r){for(var e=c({legal:!1}),n=0,t=lr,o=0,i=e.length;i>o;o++){if(S(e[o]),!h(t))if(r-1>0){var f=q(r-1);n+=f}else n++;m()}return n}var D="b",K="w",Q=-1,U="p",$="n",x="b",j="r",B="q",M="k",G="pnbrqkPNBRQK",F="rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",W=["1-0","0-1","1/2-1/2","*"],H={b:[16,32,17,15],w:[-16,-32,-17,-15]},Z={n:[-18,-33,-31,-14,18,33,31,14],b:[-17,-15,17,15],r:[-16,1,16,-1],q:[-17,-16,-15,1,17,16,15,-1],k:[-17,-16,-15,1,17,16,15,-1]},z=[20,0,0,0,0,0,0,24,0,0,0,0,0,0,20,0,0,20,0,0,0,0,0,24,0,0,0,0,0,20,0,0,0,0,20,0,0,0,0,24,0,0,0,0,20,0,0,0,0,0,0,20,0,0,0,24,0,0,0,20,0,0,0,0,0,0,0,0,20,0,0,24,0,0,20,0,0,0,0,0,0,0,0,0,0,20,2,24,2,20,0,0,0,0,0,0,0,0,0,0,0,2,53,56,53,2,0,0,0,0,0,0,24,24,24,24,24,24,56,0,56,24,24,24,24,24,24,0,0,0,0,0,0,2,53,56,53,2,0,0,0,0,0,0,0,0,0,0,0,20,2,24,2,20,0,0,0,0,0,0,0,0,0,0,20,0,0,24,0,0,20,0,0,0,0,0,0,0,0,20,0,0,0,24,0,0,0,20,0,0,0,0,0,0,20,0,0,0,0,24,0,0,0,0,20,0,0,0,0,20,0,0,0,0,0,24,0,0,0,0,0,20,0,0,20,0,0,0,0,0,0,24,0,0,0,0,0,0,20],J=[17,0,0,0,0,0,0,16,0,0,0,0,0,0,15,0,0,17,0,0,0,0,0,16,0,0,0,0,0,15,0,0,0,0,17,0,0,0,0,16,0,0,0,0,15,0,0,0,0,0,0,17,0,0,0,16,0,0,0,15,0,0,0,0,0,0,0,0,17,0,0,16,0,0,15,0,0,0,0,0,0,0,0,0,0,17,0,16,0,15,0,0,0,0,0,0,0,0,0,0,0,0,17,16,15,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,-1,-1,-1,-1,-1,-1,-1,0,0,0,0,0,0,0,-15,-16,-17,0,0,0,0,0,0,0,0,0,0,0,0,-15,0,-16,0,-17,0,0,0,0,0,0,0,0,0,0,-15,0,0,-16,0,0,-17,0,0,0,0,0,0,0,0,-15,0,0,0,-16,0,0,0,-17,0,0,0,0,0,0,-15,0,0,0,0,-16,0,0,0,0,-17,0,0,0,0,-15,0,0,0,0,0,-16,0,0,0,0,0,-17,0,0,-15,0,0,0,0,0,0,-16,0,0,0,0,0,0,-17],V={p:0,n:1,b:2,r:3,q:4,k:5},X={NORMAL:"n",CAPTURE:"c",BIG_PAWN:"b",EP_CAPTURE:"e",PROMOTION:"p",KSIDE_CASTLE:"k",QSIDE_CASTLE:"q"},Y={NORMAL:1,CAPTURE:2,BIG_PAWN:4,EP_CAPTURE:8,PROMOTION:16,KSIDE_CASTLE:32,QSIDE_CASTLE:64},rr=7,er=6,nr=1,tr=0,or={a8:0,b8:1,c8:2,d8:3,e8:4,f8:5,g8:6,h8:7,a7:16,b7:17,c7:18,d7:19,e7:20,f7:21,g7:22,h7:23,a6:32,b6:33,c6:34,d6:35,e6:36,f6:37,g6:38,h6:39,a5:48,b5:49,c5:50,d5:51,e5:52,f5:53,g5:54,h5:55,a4:64,b4:65,c4:66,d4:67,e4:68,f4:69,g4:70,h4:71,a3:80,b3:81,c3:82,d3:83,e3:84,f3:85,g3:86,h3:87,a2:96,b2:97,c2:98,d2:99,e2:100,f2:101,g2:102,h2:103,a1:112,b1:113,c1:114,d1:115,e1:116,f1:117,g1:118,h1:119},ir={w:[{square:or.a1,flag:Y.QSIDE_CASTLE},{square:or.h1,flag:Y.KSIDE_CASTLE}],b:[{square:or.a8,flag:Y.QSIDE_CASTLE},{square:or.h8,flag:Y.KSIDE_CASTLE}]},fr=new Array(128),ar={w:Q,b:Q},lr=K,ur={w:0,b:0},pr=Q,sr=0,cr=1,vr=[],gr={};return t("undefined"==typeof r?F:r),{WHITE:K,BLACK:D,PAWN:U,KNIGHT:$,BISHOP:x,ROOK:j,QUEEN:B,KING:M,SQUARES:function(){for(var r=[],e=or.a8;e<=or.h1;e++)136&e?e+=7:r.push(w(e));return r}(),FLAGS:X,load:function(r){return t(r)},reset:function(){return n()},moves:function(r){for(var e=c(r),n=[],t=0,o=e.length;o>t;t++)n.push("undefined"!=typeof r&&"verbose"in r&&r.verbose?O(e[t]):v(e[t],!1));return n},in_check:function(){return d()},in_checkmate:function(){return E()},in_stalemate:function(){return b()},in_draw:function(){return sr>=100||b()||_()||y()},insufficient_material:function(){return _()},in_threefold_repetition:function(){return y()},game_over:function(){return sr>=100||E()||b()||_()||y()},validate_fen:function(r){return o(r)},fen:function(){return i()},pgn:function(r){var e="object"==typeof r&&"string"==typeof r.newline_char?r.newline_char:"\n",n="object"==typeof r&&"number"==typeof r.max_width?r.max_width:0,t=[],o=!1;for(var i in gr)t.push("["+i+' "'+gr[i]+'"]'+e),o=!0;o&&vr.length&&t.push(e);for(var f=[];vr.length>0;)f.push(m());for(var a=[],l="";f.length>0;){var u=f.pop();vr.length||"b"!==u.color?"w"===u.color&&(l.length&&a.push(l),l=cr+"."):l=cr+". ...",l=l+" "+v(u,!1),S(u)}if(l.length&&a.push(l),"undefined"!=typeof gr.Result&&a.push(gr.Result),0===n)return t.join("")+a.join(" ");for(var p=0,i=0;i<a.length;i++)p+a[i].length>n&&0!==i?(" "===t[t.length-1]&&t.pop(),t.push(e),p=0):0!==i&&(t.push(" "),p++),t.push(a[i]),p+=a[i].length;return t.join("")},load_pgn:function(r,e){function o(r){return r.replace(/\\/g,"\\")}function i(r){for(var e=r.replace(/=/,"").replace(/[+#]?[?!]*$/,""),n=c(),t=0,o=n.length;o>t;t++)if(e===v(n[t]).replace(/=/,"").replace(/[+#]?[?!]*$/,"")||p&&e===v(n[t],p).replace(/=/,"").replace(/[+#]?[?!]*$/,""))return n[t];return null}function a(r){return i(k(r))}function l(r){for(var e in r)return!0;return!1}function u(r,e){for(var n="object"==typeof e&&"string"==typeof e.newline_char?e.newline_char:"\r?\n",t={},i=r.split(new RegExp(o(n))),f="",a="",l=0;l<i.length;l++)f=i[l].replace(/^\[([A-Z][A-Za-z]*)\s.*\]$/,"$1"),a=i[l].replace(/^\[[A-Za-z]+\s"(.*)"\]$/,"$1"),k(f).length>0&&(t[f]=a);return t}var p="undefined"!=typeof e&&"sloppy"in e?e.sloppy:!1,s="object"==typeof e&&"string"==typeof e.newline_char?e.newline_char:"\r?\n",g=new RegExp("^(\\[(.|"+o(s)+")*\\])("+o(s)+")*1.("+o(s)+"|.)*$","g"),h=r.replace(g,"$1");"["!==h[0]&&(h=""),n();var d=u(h,e);for(var E in d)f([E,d[E]]);if("1"===d.SetUp&&!("FEN"in d&&t(d.FEN)))return!1;var b=r.replace(h,"").replace(new RegExp(o(s),"g")," ");b=b.replace(/(\{[^}]+\})+?/g,"");for(var _=/(\([^\(\)]+\))+?/g;_.test(b);)b=b.replace(_,"");b=b.replace(/\d+\.(\.\.)?/g,""),b=b.replace(/\.\.\./g,""),b=b.replace(/\$\d+/g,"");var y=k(b).split(new RegExp(/\s+/));y=y.join(",").replace(/,,+/g,",").split(",");for(var A="",m=0;m<y.length-1;m++){if(A=a(y[m]),null==A)return!1;S(A)}if(A=y[y.length-1],W.indexOf(A)>-1)l(gr)&&"undefined"==typeof gr.Result&&f(["Result",A]);else{if(A=a(A),null==A)return!1;S(A)}return!0},header:function(){return f(arguments)},ascii:function(){return T()},turn:function(){return lr},move:function(r,e){var n="undefined"!=typeof e&&"sloppy"in e?e.sloppy:!1,t=null,o=c();if("string"==typeof r){for(var i=r.replace(/=/,"").replace(/[+#]?[?!]*$/,""),f=0,a=o.length;a>f;f++)if(i===v(o[f]).replace(/=/,"").replace(/[+#]?[?!]*$/,"")||n&&i===v(o[f],n).replace(/=/,"").replace(/[+#]?[?!]*$/,"")){t=o[f];break}}else if("object"==typeof r)for(var f=0,a=o.length;a>f;f++)if(!(r.from!==w(o[f].from)||r.to!==w(o[f].to)||"promotion"in o[f]&&r.promotion!==o[f].promotion)){t=o[f];break}if(!t)return null;var l=O(t);return S(t),l},undo:function(){var r=m();return r?O(r):null},clear:function(){return e()},put:function(r,e){return u(r,e)},get:function(r){return l(r)},remove:function(r){return p(r)},perft:function(r){return q(r)},square_color:function(r){if(r in or){var e=or[r];return(I(e)+P(e))%2===0?"light":"dark"}return null},history:function(r){for(var e=[],n=[],t=("undefined"!=typeof r&&"verbose"in r&&r.verbose);vr.length>0;)e.push(m());for(;e.length>0;){var o=e.pop();n.push(t?O(o):v(o)),S(o)}return n}}};"undefined"!=typeof exports&&(exports.Chess=Chess),"undefined"!=typeof define&&define(function(){return Chess});
{
"name": "chess.js",
"version": "0.10.0",
"version": "0.10.1",
"description": "A Javascript chess library for chess move generation/validation, piece placement/movement, and check/checkmate/draw detection",

@@ -5,0 +5,0 @@ "author": "Jeff Hlywa <jhlywa@gmail.com> (https://github.com/jhlywa)",

@@ -22,3 +22,3 @@ # chess.js

```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/chess.js/0.9.4/chess.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/chess.js/0.10.1/chess.js"></script>
```

@@ -46,2 +46,3 @@

- [Redbull - Battle for the Queen](http://battleforthequeen.redbull.com/)
- [Asm.js Chess Battle](https://developer.microsoft.com/en-us/microsoft-edge/testdrive/demos/chess/)
- [3D Hartwig Chess](http://creativejs.com/2012/12/3d-hartwig-chess/)

@@ -48,0 +49,0 @@ - [Scene VR](http://client.scenevr.com/?connect=chess.scenevr.hosting/chess.xml)

@@ -598,4 +598,25 @@ if (typeof require != "undefined") {

expect: true,
sloppy: true}
sloppy: true},
// the sloppy PGN parser should still accept correctly disambiguated moves
{pgn: [
'1.e4 e5 2.Nf3 d6 3.d4 Bg4 4.dxe5 Bxf3 5.Qxf3 dxe5 6.Qf5 Nc6 7.Bb5 Ne7',
'8.Qxe5 Qd7 9.O-O Nxe5 10.Bxd7+ Nxd7 11.Rd1 O-O-O 12.Nc3 Ng6 13.Be3 a6',
'14.Ba7 b6 15.Na4 Kb7 16.Bxb6 cxb6 17.b3 b5 18.Nb2 Nge5 19.f3 Rc8',
'20.Rac1 Ba3 21.Rb1 Rxc2 22.f4 Ng4 23.Rxd7+ Kc6 24.Rxf7 Bxb2 25.Rxg7',
'Ne3 26.Rg3 Bd4 27.Kh1 Rxa2 28.Rc1+ Kb6 29.e5 Rf8 30.e6 Rxf4 31.e7 Re4',
'32.Rg7 Bxg7'],
fen: '8/4P1bp/pk6/1p6/4r3/1P2n3/r5PP/2R4K w - - 0 33',
expect: true,
sloppy: true},
{pgn: [
'1.e4 e5 2.Nf3 Nc6 3.Bc4 Nf6 4.Ng5 d5 5.exd5 Nxd5 6.Nxf7 Kxf7 7.Qf3+',
'Ke6 8.Nc3 Nb4'],
fen: 'r1bq1b1r/ppp3pp/4k3/3np3/1nB5/2N2Q2/PPPP1PPP/R1B1K2R w KQ - 4 9',
expect: true,
sloppy: true
},
];

@@ -695,7 +716,14 @@

// sloppy move parser
// strict move parser
{fen: 'r2qkbnr/ppp2ppp/2n5/1B2pQ2/4P3/8/PPP2PPP/RNB1K2R b KQkq - 3 7',
legal: true,
next: 'r2qkb1r/ppp1nppp/2n5/1B2pQ2/4P3/8/PPP2PPP/RNB1K2R w KQkq - 4 8',
move: 'Ne7'},
// strict move parser should reject over disambiguation
{fen: 'r2qkbnr/ppp2ppp/2n5/1B2pQ2/4P3/8/PPP2PPP/RNB1K2R b KQkq - 3 7',
legal: false,
move: 'Nge7'},
// sloppy move parser
{fen: 'r2qkbnr/ppp2ppp/2n5/1B2pQ2/4P3/8/PPP2PPP/RNB1K2R b KQkq - 3 7',

@@ -707,2 +735,9 @@ legal: true,

// the sloppy parser should still accept correctly disambiguated moves
{fen: 'r2qkbnr/ppp2ppp/2n5/1B2pQ2/4P3/8/PPP2PPP/RNB1K2R b KQkq - 3 7',
legal: true,
sloppy: true,
move: 'Ne7',
next: 'r2qkb1r/ppp1nppp/2n5/1B2pQ2/4P3/8/PPP2PPP/RNB1K2R w KQkq - 4 8'},
];

@@ -709,0 +744,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc