+int distance(int row_from, int switch_from, int side_from, int row_to, int switch_to, int side_to)
+{
+ /* can we just walk directly? */
+ if (row_from == row_to && side_from == side_to) {
+ return distance_switch(switch_from, switch_to);
+ }
+
+ /* can we just switch sides? */
+ if (row_from + 1 == row_to && side_from == 1 && side_to == 0) {
+ return distance_switch(switch_from, switch_to);
+ }
+ if (row_from == row_to + 1 && side_from == 0 && side_to == 1) {
+ return distance_switch(switch_from, switch_to);
+ }
+
+ return pessimistic_distance(row_from, switch_from, row_to, switch_to);
+}
+