- for (let c of ['w', 'b']) {
- if (variety(c)) {
- for (let i=0; i<this.size.x; i++) {
- for (let j=0; j<this.size.y; j++) {
- const pieceIJ = this.getPiece(i, j);
- if (
- this.board[i][j] != "" &&
- !['p', 'k', 'u'].includes(pieceIJ)
- ) {
- // NOTE: could also use a "flip" strategy similar to Benedict
- next.vanish.push(new PiPo({c: c, p: pieceIJ, x: i, y: j}));
- next.appear.push(new PiPo({c: c, p: 'u', x: i, y: j}));
- this.reserve[c][pieceIJ]++;
- }
+ this.playOnBoard(move);
+ const twoOrMorePieces = {w: variety('w'), b: variety('b')};
+ const resetCols =
+ Object.keys(twoOrMorePieces).filter(k => twoOrMorePieces[k]);
+ if (resetCols.length >= 1) {
+ for (let i=0; i<this.size.x; i++) {
+ for (let j=0; j<this.size.y; j++) {
+ const colIJ = this.getColor(i, j);
+ const pieceIJ = this.getPiece(i, j);
+ if (
+ resetCols.includes(colIJ) &&
+ this.board[i][j] != "" &&
+ !['p', 'k', 'u'].includes(pieceIJ)
+ ) {
+ // NOTE: could also use a "flip" strategy similar to Benedict
+ next.vanish.push(new PiPo({c: colIJ, p: pieceIJ, x: i, y: j}));
+ next.appear.push(new PiPo({c: colIJ, p: 'u', x: i, y: j}));
+ this.reserve[colIJ][pieceIJ]++;