`rank` is not a function when trying to call `main_evaluation` at https://hxim.github.io/Stockfish-Evaluation-Guide

16 views Asked by At

I'm trying to evaluate a position using code at https://hxim.github.io/Stockfish-Evaluation-Guide but when run with starting position it results:

Uncaught TypeError: rank is not a function
    at space_area (stockfish_evaluation.js:1369:14)
    at sum (stockfish_evaluation.js:93:65)
    at space_area (stockfish_evaluation.js:1367:30)
    at space (stockfish_evaluation.js:1394:12)
    at middle_game_evaluation (stockfish_evaluation.js:117:8)
    at main_evaluation (stockfish_evaluation.js:97:12)
    at <anonymous>:1:1

Code at stockfish_evaluation.js:

function board(pos, x, y) {
  if (x >= 0 && x <= 7 && y >= 0 && y <= 7) return pos.b[x][y];
  return "x";
}
function rank(pos, square) {
  //if (square == null) return sum(pos, rank);
  return 8 - square.y;
}
function file(pos, square) {
  //if (square == null) return sum(pos, file);
  return 1 + square.x;
}
function main_evaluation(pos) {
  var mg = middle_game_evaluation(pos);
  var eg = end_game_evaluation(pos);
  var p = phase(pos), rule50 = rule50(pos);
  eg = eg * scale_factor(pos, eg) / 64;
  var v = (((mg * p + ((eg * (128 - p)) << 0)) / 128) << 0);
  if (arguments.length == 1) v = ((v / 16) << 0) * 16;
  v += tempo(pos);
  v = (v * (100 - rule50) / 100) << 0;
  return v;
}
...
0

There are 0 answers