- let move_num = display_line.move_num;
- let toplay = display_line.toplay;
-
- // Truncate PV at the start if needed.
- let start_display_move_num = display_line.start_display_move_num;
- if (start_display_move_num > 0) {
- pv = pv.slice(start_display_move_num);
- let to_add = start_display_move_num;
- if (toplay === 'b') {
- ++move_num;
- toplay = 'w';
- --to_add;
- }
- if (to_add % 2 == 1) {
- toplay = 'b';
- --to_add;
- }
- move_num += to_add / 2;
- if (splicepos !== null && splicepos > 0) {
- --splicepos;
- }
- }
+ let move_num = find_move_num(display_line.start_fen);
+ let toplay = find_toplay(display_line.start_fen);
+ let halfmove_num = move_num * 2 + (toplay === 'w' ? 0 : 1); // From two, for simplicity.