positionWeight method
位置权重
Implementation
int positionWeight(ChessPos pos) {
String item = fen[pos.y][pos.x];
List<String> points = movePoints(pos);
int team = item.codeUnitAt(0) < ChessFen.colIndexBase ? 0 : 1;
int weight = 0;
for (var point in points) {
ChessPos cPos = ChessPos.fromCode(point);
String code = fen[cPos.y][cPos.x];
if ((team == 0 && code == 'K') || (team == 1 && code == 'k')) {
} else if (code != '0') {
if (code == 'p') {
if (cPos.y < 5) {
code = 'p+';
if (cPos.y < 3 && cPos.x > 2 && cPos.x < 7) {
code = 'p++';
}
}
} else if (code == 'P') {
if (cPos.y > 4) {
code = 'P+';
if (cPos.y > 6 && cPos.x > 2 && cPos.x < 7) {
code = 'P++';
}
}
}
weight += chessWeight[code.toLowerCase()]!;
}
}
return weight;
}