trapq: Fix bug that broke numerical stability workaround for initial movement

Commit b60804bb changed the trapq head sentinel to store
print_time=-1.  However, it failed to update trapq_add_move() that
relied on that value to detect the head sentinel.  As a result,
numerical stability issues could lead to stepcompress errors.

Fix by changing trapq_add_move() to detect the head sentinel even with
a negative print_time.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor
2025-10-04 19:35:41 -04:00
parent 768b19e8be
commit c49dbb5a87

View File

@@ -104,7 +104,7 @@ trapq_add_move(struct trapq *tq, struct move *m)
// Add a null move to fill time gap
struct move *null_move = move_alloc();
null_move->start_pos = m->start_pos;
if (!prev->print_time && m->print_time > MAX_NULL_MOVE)
if (prev->print_time <= 0. && m->print_time > MAX_NULL_MOVE)
// Limit the first null move to improve numerical stability
null_move->print_time = m->print_time - MAX_NULL_MOVE;
else