+ // After moving, add stones captured in "step" direction from new
+ // location [x, y] to mv.vanish (if any captured stone!)
+ addCapture([x, y], step, move) {
+ let [i, j] = [x + step[0], y + step[1]];
+ while (
+ this.onBoard(i, j) &&
+ this.board[i][j] != "" &&
+ this.getColor(i, j) == oppCol
+ ) {
+ move.vanish.push(new PiPo({ x: i, y: j, c: oppCol, p: 's' }));
+ [i, j] = [i + step[0], j + step[1]];
+ }
+ return (move.vanish.length >= 2);
+ }
+
+ stepToArrow(s, forward) {
+ const baseShift = (forward ? 0 : 8),
+ colShift = (this.playerColor=='w' ? 0 : 4);
+ const doShift = (c) => {
+ return String.fromCharCode(
+ 97 + (c.charCodeAt(0) - 97 + colShift) % 8 + baseShift);
+ };
+ switch (s) {
+ case "-1_0": return doShift('a');
+ case "-1_1": return doShift('b');
+ case "0_1": return doShift('c');
+ case "1_1": return doShift('d');
+ case "1_0": return doShift('e');
+ case "1_-1": return doShift('f');
+ case "0_-1": return doShift('g');
+ case "-1_-1": return doShift('h');
+ }
+ return ''; //never reached
+ };
+
+
+// TODO: getPotentialMove_s() + pre-compute atLeastOneCapture() after each opponent move
+
+