@@ -65,14 +65,38 @@ def rearrange_impl(
6565 start = grid .sub_grid (zone , src_x , src_y )
6666 end = grid .sub_grid (zone , dst_x , dst_y )
6767
68- x_positions = grid .get_xpos (start )
69-
7068 def parking_x (index : int ):
69+ x_positions = grid .get_xpos (zone )
7170 return x_positions [index ] + 3.0 * (2 * (index % 2 ) - 1 )
7271
73- src_parking = grid .from_positions (ilist .map (parking_x , src_x ), grid .get_ypos (zone ))
72+ def parking_y_start (index : int ):
73+ start_y = grid .get_ypos (start )[index ]
74+ end_y = grid .get_ypos (end )[index ]
75+ if start_y <= end_y :
76+ start_y = start_y + 3.0
77+ else :
78+ start_y = start_y - 3.0
79+
80+ return start_y
81+
82+ def parking_y_end (index : int ):
83+ start_y = grid .get_ypos (start )[index ]
84+ end_y = grid .get_ypos (end )[index ]
85+ if start_y < end_y :
86+ end_y = end_y - 3.0
87+ else :
88+ end_y = end_y + 3.0
89+
90+ return end_y
7491
75- dst_parking = grid .shift (end , 0.0 , 3.0 )
92+ num_y = len (src_y )
93+
94+ src_parking = grid .from_positions (
95+ ilist .map (parking_x , src_x ), ilist .map (parking_y_start , ilist .range (num_y ))
96+ )
97+ dst_parking = grid .from_positions (
98+ ilist .map (parking_x , dst_x ), ilist .map (parking_y_end , ilist .range (num_y ))
99+ )
76100 mid_pos = grid .from_positions (
77101 grid .get_xpos (src_parking ), grid .get_ypos (dst_parking )
78102 )
0 commit comments