- scanKings(fen) {
- // Kings may be swapped, so they are not tracked (no kingPos)
- this.INIT_COL_KING = { w: -1, b: -1 };
- const fenRows = V.ParseFen(fen).position.split("/");
- const startRow = { 'w': V.size.x - 1, 'b': 0 };
- for (let i = 0; i < fenRows.length; i++) {
- let k = 0; //column index on board
- for (let j = 0; j < fenRows[i].length; j++) {
- switch (fenRows[i].charAt(j)) {
- case "k":
- this.INIT_COL_KING["b"] = k;
- break;
- case "K":
- this.INIT_COL_KING["w"] = k;
- break;
- default: {
- const num = parseInt(fenRows[i].charAt(j), 10);
- if (!isNaN(num)) k += num - 1;
- }
- }
- k++;
- }
- }
- }