-
- doubleMoves.sort((a, b) => {
- return (color == "w" ? 1 : -1) * (b.eval - a.eval);
- });
- let candidates = [0]; //indices of candidates moves
- for (
- let i = 1;
- i < doubleMoves.length && doubleMoves[i].eval == doubleMoves[0].eval;
- i++
- ) {
- candidates.push(i);
- }
- return doubleMoves[randInt(candidates.length)].moves;