Add true repetition detection
[vchess.git] / public / javascripts / variants / Ultima.js
CommitLineData
32cfcea4
BA
1class UltimaRules extends ChessRules
2{
2eef6db6
BA
3 static getPpath(b)
4 {
5 if (b[1] == "m") //'m' for Immobilizer (I is too similar to 1)
6 return "Ultima/" + b;
7 return b; //usual piece
8 }
32cfcea4 9
2eef6db6
BA
10 initVariables(fen)
11 {
12 this.kingPos = {'w':[-1,-1], 'b':[-1,-1]};
13 const fenParts = fen.split(" ");
14 const position = fenParts[0].split("/");
15 for (let i=0; i<position.length; i++)
16 {
17 let k = 0;
18 for (let j=0; j<position[i].length; j++)
19 {
20 switch (position[i].charAt(j))
21 {
22 case 'k':
23 this.kingPos['b'] = [i,k];
24 break;
25 case 'K':
26 this.kingPos['w'] = [i,k];
27 break;
28 default:
29 let num = parseInt(position[i].charAt(j));
30 if (!isNaN(num))
31 k += (num-1);
32 }
33 k++;
34 }
35 }
36 this.epSquares = []; //no en-passant here
37 }
38
39 setFlags(fen)
40 {
41 // TODO: for compatibility?
42 this.castleFlags = {"w":[false,false], "b":[false,false]};
43 }
44
45 static get IMMOBILIZER() { return 'm'; }
46 // Although other pieces keep their names here for coding simplicity,
47 // keep in mind that:
48 // - a "rook" is a coordinator, capturing by coordinating with the king
49 // - a "knight" is a long-leaper, capturing as in draughts
50 // - a "bishop" is a chameleon, capturing as its prey
51 // - a "queen" is a withdrawer, capturing by moving away from pieces
52
2f3c8451
BA
53 // Is piece on square (x,y) immobilized?
54 isImmobilized([x,y])
2eef6db6 55 {
7688bf77
BA
56 const piece = this.getPiece(x,y);
57 const color = this.getColor(x,y);
58 const oppCol = this.getOppCol(color);
59 const V = VariantRules;
60 const adjacentSteps = V.steps[V.ROOK].concat(V.steps[V.BISHOP]);
61 const [sizeX,sizeY] = V.size;
9d218497 62 outerLoop:
7688bf77
BA
63 for (let step of adjacentSteps)
64 {
65 const [i,j] = [x+step[0],y+step[1]];
66 if (i>=0 && i<sizeX && j>=0 && j<sizeY && this.board[i][j] != V.EMPTY
67 && this.getColor(i,j) == oppCol)
68 {
69 const oppPiece = this.getPiece(i,j);
9d218497 70 if (oppPiece == V.BISHOP && piece == V.IMMOBILIZER)
f4fd6580 71 return true;
9d218497 72 if (oppPiece == V.IMMOBILIZER && ![V.BISHOP,V.IMMOBILIZER].includes(piece))
7688bf77 73 {
9d218497
BA
74 // Moving is impossible only if this immobilizer is not neutralized
75 for (let step2 of adjacentSteps)
76 {
77 const [i2,j2] = [i+step2[0],j+step2[1]];
78 if (i2>=0 && i2<sizeX && j2>=0 && j2<sizeY
79 && this.board[i2][j2] != V.EMPTY && this.getColor(i2,j2) == color)
80 {
f4fd6580
BA
81 if ([V.BISHOP,V.IMMOBILIZER].includes(this.getPiece(i2,j2)))
82 return false;
9d218497
BA
83 }
84 }
f4fd6580 85 return true; //immobilizer isn't neutralized
7688bf77
BA
86 }
87 }
88 }
f4fd6580 89 return false;
2f3c8451
BA
90 }
91
92 getPotentialMovesFrom([x,y])
93 {
94 // Pre-check: is thing on this square immobilized?
95 if (this.isImmobilized([x,y]))
96 return [];
2eef6db6
BA
97 switch (this.getPiece(x,y))
98 {
99 case VariantRules.IMMOBILIZER:
100 return this.getPotentialImmobilizerMoves([x,y]);
101 default:
102 return super.getPotentialMovesFrom([x,y]);
103 }
2eef6db6
BA
104 }
105
106 getSlideNJumpMoves([x,y], steps, oneStep)
107 {
108 const color = this.getColor(x,y);
109 const piece = this.getPiece(x,y);
110 let moves = [];
111 const [sizeX,sizeY] = VariantRules.size;
112 outerLoop:
113 for (let step of steps)
114 {
115 let i = x + step[0];
116 let j = y + step[1];
117 while (i>=0 && i<sizeX && j>=0 && j<sizeY
118 && this.board[i][j] == VariantRules.EMPTY)
119 {
120 moves.push(this.getBasicMove([x,y], [i,j]));
121 if (oneStep !== undefined)
122 continue outerLoop;
123 i += step[0];
124 j += step[1];
125 }
126 // Only king can take on occupied square:
127 if (piece==VariantRules.KING && i>=0 && i<sizeX && j>=0
128 && j<sizeY && this.canTake([x,y], [i,j]))
129 {
130 moves.push(this.getBasicMove([x,y], [i,j]));
131 }
132 }
133 return moves;
134 }
135
a3c86ec9
BA
136 // Modify capturing moves among listed pawn moves
137 addPawnCaptures(moves, byChameleon)
138 {
139 const steps = VariantRules.steps[VariantRules.ROOK];
140 const [sizeX,sizeY] = VariantRules.size;
141 const color = this.turn;
142 const oppCol = this.getOppCol(color);
143 moves.forEach(m => {
144 if (!!byChameleon && m.start.x!=m.end.x && m.start.y!=m.end.y)
145 return; //chameleon not moving as pawn
146 // Try capturing in every direction
147 for (let step of steps)
148 {
149 const sq2 = [m.end.x+2*step[0],m.end.y+2*step[1]];
150 if (sq2[0]>=0 && sq2[0]<sizeX && sq2[1]>=0 && sq2[1]<sizeY
151 && this.board[sq2[0]][sq2[1]] != VariantRules.EMPTY
152 && this.getColor(sq2[0],sq2[1]) == color)
153 {
154 // Potential capture
155 const sq1 = [m.end.x+step[0],m.end.y+step[1]];
156 if (this.board[sq1[0]][sq1[1]] != VariantRules.EMPTY
157 && this.getColor(sq1[0],sq1[1]) == oppCol)
158 {
159 const piece1 = this.getPiece(sq1[0],sq1[1]);
160 if (!byChameleon || piece1 == VariantRules.PAWN)
161 {
162 m.vanish.push(new PiPo({
163 x:sq1[0],
164 y:sq1[1],
165 c:oppCol,
166 p:piece1
167 }));
168 }
169 }
170 }
171 }
172 });
173 }
174
7688bf77 175 // "Pincher"
2eef6db6
BA
176 getPotentialPawnMoves([x,y])
177 {
7688bf77 178 let moves = super.getPotentialRookMoves([x,y]);
a3c86ec9
BA
179 this.addPawnCaptures(moves);
180 return moves;
2eef6db6
BA
181 }
182
a3c86ec9 183 addRookCaptures(moves, byChameleon)
2eef6db6 184 {
a3c86ec9 185 const color = this.turn;
7688bf77
BA
186 const oppCol = this.getOppCol(color);
187 const kp = this.kingPos[color];
7688bf77
BA
188 moves.forEach(m => {
189 // Check piece-king rectangle (if any) corners for enemy pieces
190 if (m.end.x == kp[0] || m.end.y == kp[1])
191 return; //"flat rectangle"
192 const corner1 = [Math.max(m.end.x,kp[0]), Math.min(m.end.y,kp[1])];
193 const corner2 = [Math.min(m.end.x,kp[0]), Math.max(m.end.y,kp[1])];
194 for (let [i,j] of [corner1,corner2])
195 {
196 if (this.board[i][j] != VariantRules.EMPTY && this.getColor(i,j) == oppCol)
197 {
a3c86ec9
BA
198 const piece = this.getPiece(i,j);
199 if (!byChameleon || piece == VariantRules.ROOK)
200 {
201 m.vanish.push( new PiPo({
202 x:i,
203 y:j,
204 p:piece,
205 c:oppCol
206 }) );
207 }
7688bf77
BA
208 }
209 }
210 });
a3c86ec9
BA
211 }
212
213 // Coordinator
214 getPotentialRookMoves(sq)
215 {
216 let moves = super.getPotentialQueenMoves(sq);
217 this.addRookCaptures(moves);
7688bf77 218 return moves;
2eef6db6
BA
219 }
220
7688bf77 221 // Long-leaper
a3c86ec9 222 getKnightCaptures(startSquare, byChameleon)
2eef6db6 223 {
7688bf77
BA
224 // Look in every direction for captures
225 const V = VariantRules;
226 const steps = V.steps[V.ROOK].concat(V.steps[V.BISHOP]);
227 const [sizeX,sizeY] = V.size;
a3c86ec9
BA
228 const color = this.turn;
229 const oppCol = this.getOppCol(color);
230 let moves = [];
231 const [x,y] = [startSquare[0],startSquare[1]];
232 const piece = this.getPiece(x,y); //might be a chameleon!
233 outerLoop:
7688bf77
BA
234 for (let step of steps)
235 {
236 let [i,j] = [x+step[0], y+step[1]];
237 while (i>=0 && i<sizeX && j>=0 && j<sizeY && this.board[i][j]==V.EMPTY)
238 {
239 i += step[0];
240 j += step[1];
241 }
a3c86ec9
BA
242 if (i<0 || i>=sizeX || j<0 || j>=sizeY || this.getColor(i,j)==color
243 || (!!byChameleon && this.getPiece(i,j)!=V.KNIGHT))
244 {
7688bf77 245 continue;
a3c86ec9
BA
246 }
247 // last(thing), cur(thing) : stop if "cur" is our color, or beyond board limits,
248 // or if "last" isn't empty and cur neither. Otherwise, if cur is empty then
249 // add move until cur square; if cur is occupied then stop if !!byChameleon and
250 // the square not occupied by a leaper.
251 let last = [i,j];
252 let cur = [i+step[0],j+step[1]];
253 let vanished = [ new PiPo({x:x,y:y,c:color,p:piece}) ];
254 while (cur[0]>=0 && cur[0]<sizeX && cur[1]>=0 && cur[1]<sizeY)
255 {
256 if (this.board[last[0]][last[1]] != V.EMPTY)
257 {
258 const oppPiece = this.getPiece(last[0],last[1]);
259 if (!!byChameleon && oppPiece != V.KNIGHT)
260 continue outerLoop;
261 // Something to eat:
262 vanished.push( new PiPo({x:last[0],y:last[1],c:oppCol,p:oppPiece}) );
263 }
264 if (this.board[cur[0]][cur[1]] != V.EMPTY)
265 {
266 if (this.getColor(cur[0],cur[1]) == color
267 || this.board[last[0]][last[1]] != V.EMPTY) //TODO: redundant test
268 {
269 continue outerLoop;
270 }
271 }
272 else
273 {
274 moves.push(new Move({
275 appear: [ new PiPo({x:cur[0],y:cur[1],c:color,p:piece}) ],
276 vanish: JSON.parse(JSON.stringify(vanished)), //TODO: required?
277 start: {x:x,y:y},
278 end: {x:cur[0],y:cur[1]}
279 }));
280 }
281 last = [last[0]+step[0],last[1]+step[1]];
282 cur = [cur[0]+step[0],cur[1]+step[1]];
283 }
7688bf77
BA
284 }
285 return moves;
2eef6db6
BA
286 }
287
a3c86ec9
BA
288 // Long-leaper
289 getPotentialKnightMoves(sq)
290 {
291 return super.getPotentialQueenMoves(sq).concat(this.getKnightCaptures(sq));
292 }
293
c28265aa 294 getPotentialBishopMoves([x,y])
2eef6db6 295 {
c28265aa
BA
296 let moves = super.getPotentialQueenMoves([x,y])
297 .concat(this.getKnightCaptures([x,y],"asChameleon"));
2f3c8451 298 // No "king capture" because king cannot remain under check
a3c86ec9
BA
299 this.addPawnCaptures(moves, "asChameleon");
300 this.addRookCaptures(moves, "asChameleon");
301 this.addQueenCaptures(moves, "asChameleon");
302 // Post-processing: merge similar moves, concatenating vanish arrays
303 let mergedMoves = {};
304 const [sizeX,sizeY] = VariantRules.size;
305 moves.forEach(m => {
306 const key = m.end.x + sizeX * m.end.y;
307 if (!mergedMoves[key])
308 mergedMoves[key] = m;
309 else
310 {
311 for (let i=1; i<m.vanish.length; i++)
312 mergedMoves[key].vanish.push(m.vanish[i]);
313 }
314 });
315 // Finally return an array
316 moves = [];
317 Object.keys(mergedMoves).forEach(k => { moves.push(mergedMoves[k]); });
318 return moves;
2eef6db6
BA
319 }
320
a3c86ec9
BA
321 // Withdrawer
322 addQueenCaptures(moves, byChameleon)
2eef6db6 323 {
a3c86ec9
BA
324 if (moves.length == 0)
325 return;
326 const [x,y] = [moves[0].start.x,moves[0].start.y];
7688bf77
BA
327 const V = VariantRules;
328 const adjacentSteps = V.steps[V.ROOK].concat(V.steps[V.BISHOP]);
329 let capturingDirections = [];
a3c86ec9 330 const color = this.turn;
7688bf77 331 const oppCol = this.getOppCol(color);
a3c86ec9 332 const [sizeX,sizeY] = V.size;
7688bf77
BA
333 adjacentSteps.forEach(step => {
334 const [i,j] = [x+step[0],y+step[1]];
a3c86ec9
BA
335 if (i>=0 && i<sizeX && j>=0 && j<sizeY
336 && this.board[i][j] != V.EMPTY && this.getColor(i,j) == oppCol
337 && (!byChameleon || this.getPiece(i,j) == V.QUEEN))
338 {
7688bf77 339 capturingDirections.push(step);
a3c86ec9 340 }
7688bf77
BA
341 });
342 moves.forEach(m => {
343 const step = [
344 m.end.x!=x ? (m.end.x-x)/Math.abs(m.end.x-x) : 0,
345 m.end.y!=y ? (m.end.y-y)/Math.abs(m.end.y-y) : 0
346 ];
a3c86ec9 347 // NOTE: includes() and even _.isEqual() functions fail...
7688bf77 348 // TODO: this test should be done only once per direction
a3c86ec9
BA
349 if (capturingDirections.some(dir =>
350 { return (dir[0]==-step[0] && dir[1]==-step[1]); }))
7688bf77
BA
351 {
352 const [i,j] = [x-step[0],y-step[1]];
353 m.vanish.push(new PiPo({
354 x:i,
355 y:j,
356 p:this.getPiece(i,j),
357 c:oppCol
358 }));
359 }
360 });
2eef6db6
BA
361 }
362
a3c86ec9
BA
363 getPotentialQueenMoves(sq)
364 {
365 let moves = super.getPotentialQueenMoves(sq);
366 this.addQueenCaptures(moves);
367 return moves;
368 }
369
45338cdd
BA
370 getPotentialImmobilizerMoves(sq)
371 {
a3c86ec9 372 // Immobilizer doesn't capture
45338cdd
BA
373 return super.getPotentialQueenMoves(sq);
374 }
375
2eef6db6
BA
376 getPotentialKingMoves(sq)
377 {
378 const V = VariantRules;
379 return this.getSlideNJumpMoves(sq,
380 V.steps[V.ROOK].concat(V.steps[V.BISHOP]), "oneStep");
381 }
382
2f3c8451 383 // isAttacked() is OK because the immobilizer doesn't take
9d218497 384
2f3c8451 385 isAttackedByPawn([x,y], colors)
2eef6db6 386 {
f4fd6580
BA
387 // Square (x,y) must be surroundable by two enemy pieces,
388 // and one of them at least should be a pawn (moving).
2f3c8451 389 const dirs = [ [1,0],[0,1],[1,1],[-1,1] ];
f4fd6580
BA
390 const steps = VariantRules.steps[VariantRules.ROOK]
391 .concat(VariantRules.steps[VariantRules.BISHOP]);
2f3c8451
BA
392 const [sizeX,sizeY] = VariantRules.size;
393 for (let dir of dirs)
394 {
395 const [i1,j1] = [x-dir[0],y-dir[1]]; //"before"
396 const [i2,j2] = [x+dir[0],y+dir[1]]; //"after"
397 if (i1>=0 && i1<sizeX && i2>=0 && i2<sizeX
f4fd6580 398 && j1>=0 && j1<sizeY && j2>=0 && j2<sizeY)
2f3c8451 399 {
f4fd6580
BA
400 if ((this.board[i1][j1]!=VariantRules.EMPTY
401 && colors.includes(this.getColor(i1,j1))
402 && this.board[i2][j2]==VariantRules.EMPTY)
403 ||
404 (this.board[i2][j2]!=VariantRules.EMPTY
405 && colors.includes(this.getColor(i2,j2))
406 && this.board[i1][j1]==VariantRules.EMPTY))
407 {
408 // Search a movable enemy pawn landing on the empty square
409 for (let step of steps)
410 {
411 let [ii,jj] = (this.board[i1][j1]==VariantRules.EMPTY ? [i1,j1] : [i2,j2]);
412 let [i3,j3] = [ii+step[0],jj+step[1]];
413 while (i3>=0 && i3<sizeX && j3>=0 && j3<sizeY
414 && this.board[i3][j3]==VariantRules.EMPTY)
415 {
416 i3 += step[0];
417 j3 += step[1];
418 }
419 if (i3>=0 && i3<sizeX && j3>=0 && j3<sizeY
420 && this.getPiece(i3,j3) == VariantRules.PAWN
421 && !this.isImmobilized([i3,j3]))
422 {
423 return true;
424 }
425 }
426 }
2f3c8451
BA
427 }
428 }
429 return false;
2eef6db6
BA
430 }
431
2f3c8451 432 isAttackedByRook([x,y], colors)
2eef6db6 433 {
f4fd6580
BA
434 // King must be on same column or row,
435 // and a rook should be able to reach a capturing square
2f3c8451 436 const [sizeX,sizeY] = VariantRules.size;
f4fd6580
BA
437 // colors contains only one element, giving the oppCol and thus king position
438 const sameRow = (x == this.kingPos[colors[0]][0]);
439 const sameColumn = (y == this.kingPos[colors[0]][1]);
440 if (sameRow || sameColumn)
2f3c8451 441 {
f4fd6580 442 // Look for the enemy rook (maximum 1)
2f3c8451
BA
443 for (let i=0; i<sizeX; i++)
444 {
f4fd6580 445 for (let j=0; j<sizeY; j++)
2f3c8451 446 {
f4fd6580
BA
447 if (this.board[i][j] != VariantRules.EMPTY
448 && this.getPiece(i,j) == VariantRules.ROOK)
449 {
450 if (this.isImmobilized([i,j]))
451 return false; //because only one rook
452 // Can it reach a capturing square?
453 // Easy but quite suboptimal way (TODO): generate all moves (turn is OK)
454 const moves = this.getPotentialMovesFrom([i,j]);
455 for (let move of moves)
456 {
457 if (sameRow && move.end.y == y || sameColumn && move.end.x == x)
458 return true;
459 }
460 }
2f3c8451
BA
461 }
462 }
463 }
464 return false;
2eef6db6
BA
465 }
466
2f3c8451 467 isAttackedByKnight([x,y], colors)
2eef6db6 468 {
2f3c8451
BA
469 // Square (x,y) must be on same line as a knight,
470 // and there must be empty square(s) behind.
471 const V = VariantRules;
472 const steps = V.steps[V.ROOK].concat(V.steps[V.BISHOP]);
473 const [sizeX,sizeY] = V.size;
474 outerLoop:
475 for (let step of steps)
7aea7942 476 {
2f3c8451
BA
477 const [i0,j0] = [x+step[0],y+step[1]];
478 if (i0>=0 && i0<sizeX && j0>=0 && j0<sizeY && this.board[i0][j0] == V.EMPTY)
479 {
480 // Try in opposite direction:
481 let [i,j] = [x-step[0],y-step[1]];
482 while (i>=0 && i<sizeX && j>=0 && j<sizeY && this.board[i][j] == V.EMPTY)
483 {
484 i -= step[0];
485 j -= step[1];
486 }
487 if (i>=0 && i<sizeX && j>=0 && j<sizeY && colors.includes(this.getColor(i,j))
488 && this.getPiece(i,j) == V.KNIGHT)
489 {
490 if (!this.isImmobilized([i,j]))
491 return true;
492 }
493 }
c28265aa 494 }
2f3c8451
BA
495 return false;
496 }
497
498 isAttackedByBishop([x,y], colors)
499 {
500 // We cheat a little here: since this function is used exclusively for king,
501 // it's enough to check the immediate surrounding of the square.
502 const V = VariantRules;
503 const adjacentSteps = V.steps[V.ROOK].concat(V.steps[V.BISHOP]);
504 const [sizeX,sizeY] = V.size;
505 for (let step of adjacentSteps)
c28265aa 506 {
2f3c8451
BA
507 const [i,j] = [x+step[0],y+step[1]];
508 if (i>=0 && i<sizeX && j>=0 && j<sizeY && this.board[i][j]!=V.EMPTY
509 && colors.includes(this.getColor(i,j)) && this.getPiece(i,j) == V.BISHOP)
7aea7942 510 {
2f3c8451 511 return true; //bishops are never immobilized
7aea7942
BA
512 }
513 }
2f3c8451 514 return false;
2eef6db6
BA
515 }
516
2f3c8451 517 isAttackedByQueen([x,y], colors)
2eef6db6 518 {
2f3c8451
BA
519 // Square (x,y) must be adjacent to a queen, and the queen must have
520 // some free space in the opposite direction from (x,y)
521 const V = VariantRules;
522 const adjacentSteps = V.steps[V.ROOK].concat(V.steps[V.BISHOP]);
523 const [sizeX,sizeY] = V.size;
524 for (let step of adjacentSteps)
7aea7942 525 {
2f3c8451
BA
526 const sq2 = [x+2*step[0],y+2*step[1]];
527 if (sq2[0]>=0 && sq2[0]<sizeX && sq2[1]>=0 && sq2[1]<sizeY
528 && this.board[sq2[0]][sq2[1]] == V.EMPTY)
7aea7942 529 {
2f3c8451
BA
530 const sq1 = [x+step[0],y+step[1]];
531 if (this.board[sq1[0]][sq1[1]] != V.EMPTY
532 && colors.includes(this.getColor(sq1[0],sq1[1]))
533 && this.getPiece(sq1[0],sq1[1]) == V.QUEEN
534 && !this.isImmobilized(sq1))
7aea7942 535 {
2f3c8451 536 return true;
7aea7942
BA
537 }
538 }
539 }
2f3c8451 540 return false;
2eef6db6
BA
541 }
542
2f3c8451 543 updateVariables(move)
a3c86ec9 544 {
2f3c8451
BA
545 // Just update king(s) position(s)
546 const piece = this.getPiece(move.start.x,move.start.y);
547 const c = this.getColor(move.start.x,move.start.y);
548 if (piece == VariantRules.KING && move.appear.length > 0)
549 {
550 this.kingPos[c][0] = move.appear[0].x;
551 this.kingPos[c][1] = move.appear[0].y;
552 }
a3c86ec9
BA
553 }
554
2eef6db6
BA
555 static get VALUES() { //TODO: totally experimental!
556 return {
557 'p': 1,
558 'r': 2,
559 'n': 5,
560 'b': 3,
561 'q': 3,
562 'm': 5,
563 'k': 1000
564 };
565 }
566
567 static get SEARCH_DEPTH() { return 2; } //TODO?
568
569 static GenRandInitFen()
570 {
571 let pieces = { "w": new Array(8), "b": new Array(8) };
572 // Shuffle pieces on first and last rank
573 for (let c of ["w","b"])
574 {
575 let positions = _.range(8);
576 // Get random squares for every piece, totally freely
577
578 let randIndex = _.random(7);
579 const bishop1Pos = positions[randIndex];
580 positions.splice(randIndex, 1);
581
582 randIndex = _.random(6);
583 const bishop2Pos = positions[randIndex];
584 positions.splice(randIndex, 1);
585
586 randIndex = _.random(5);
587 const knight1Pos = positions[randIndex];
588 positions.splice(randIndex, 1);
589
590 randIndex = _.random(4);
591 const knight2Pos = positions[randIndex];
592 positions.splice(randIndex, 1);
593
594 randIndex = _.random(3);
595 const queenPos = positions[randIndex];
596 positions.splice(randIndex, 1);
597
598 randIndex = _.random(2);
599 const kingPos = positions[randIndex];
600 positions.splice(randIndex, 1);
601
602 randIndex = _.random(1);
603 const rookPos = positions[randIndex];
604 positions.splice(randIndex, 1);
45338cdd 605 const immobilizerPos = positions[0];
2eef6db6
BA
606
607 pieces[c][bishop1Pos] = 'b';
608 pieces[c][bishop2Pos] = 'b';
609 pieces[c][knight1Pos] = 'n';
610 pieces[c][knight2Pos] = 'n';
611 pieces[c][queenPos] = 'q';
612 pieces[c][kingPos] = 'k';
613 pieces[c][rookPos] = 'r';
614 pieces[c][immobilizerPos] = 'm';
615 }
616 return pieces["b"].join("") +
617 "/pppppppp/8/8/8/8/PPPPPPPP/" +
618 pieces["w"].join("").toUpperCase() +
619 " 0000"; //TODO: flags?!
620 }
621
622 getFlagsFen()
623 {
624 return "0000"; //TODO: or "-" ?
625 }
32cfcea4 626}