+ const oppCol = V.GetOppCol(color);
+ const getOppEval = () => {
+ let evalOpp = this.evalPosition();
+ this.getAllValidMoves().forEach(m => {
+ // Do not consider knight landings here
+ if (m.appear.length > 0) {
+ this.play(m);
+ const score = this.getCurrentScore();
+ let mvEval = 0;
+ if (["1-0", "0-1"].includes(score))
+ mvEval = (score == "1-0" ? 1 : -1) * maxeval;
+ else if (score == "*") mvEval = this.evalPosition();
+ if (
+ (oppCol == 'w' && mvEval > evalOpp) ||
+ (oppCol == 'b' && mvEval < evalOpp)
+ ) {
+ evalOpp = mvEval;
+ }
+ this.undo(m);
+ }
+ });
+ return evalOpp;
+ };
+ // Custom "search" at depth 2