/* can we just switch sides? */
if (row_from + 1 == row_to && side_from == 1 && side_to == 0) {
- return distance_switch(switch_from, switch_to);
+ return pessimistic_distance(switch_from, row_from, switch_to, row_to) - 31;
}
if (row_from == row_to + 1 && side_from == 0 && side_to == 1) {
- return distance_switch(switch_from, switch_to);
+ return pessimistic_distance(switch_from, row_from, switch_to, row_to) - 31;
}
return pessimistic_distance(row_from, switch_from, row_to, switch_to);
int optimistic_distance(int row_from, int switch_from, int row_to, int switch_to)
{
- if (abs(row_from - row_to) <= 1)
+ if (row_from == row_to)
return distance_switch(switch_from, switch_to);
+ else if (abs(row_from - row_to) == 1)
+ return pessimistic_distance(row_from, switch_from, row_to, switch_to) - 31;
else
return pessimistic_distance(row_from, switch_from, row_to, switch_to);
}