Enhancements to parking environment#464
Enhancements to parking environment#464sowmen wants to merge 3 commits intoFarama-Foundation:masterfrom
Conversation
eleurent
left a comment
There was a problem hiding this comment.
Hi, thanks a lot for the very nice features.
I am just slightly concerned that this PR adds quite a lot of boilerplate code which I am not sure is needed. I am also not sure why you felt the need of printing the lane identifiers, I don't really see the use for this and it also adds unnecessary complexity (per-lane identifier, font-size...).
Will approve subject to code quality improvements.
| cls.continuous_line(lane, surface, stripes_count, s0, side) | ||
|
|
||
| if lane.display_font_size != None: | ||
| x = (last_pixel[0][0] + last_pixel[1][0]) // 2 - 8 |
There was a problem hiding this comment.
I think that passing around this additional return_last_pixel argument and the associated returned value is a bit awkward, it adds unnecessary complexity, requires changing the several functions signature (which are now inconsistent) etc.
Instead, you can just recompute the coordinate here: surface.vec2pix(lane.position(lane.length, 0))
| net.add_lane("a", "b", StraightLane([x, y_offset], [x, y_offset+length], width=width, line_types=lt)) | ||
| net.add_lane("b", "c", StraightLane([x, -y_offset], [x, -y_offset-length], width=width, line_types=lt)) | ||
|
|
||
| row_ys = [] |
There was a problem hiding this comment.
I think this could be simplified, why is this list needed? is the y coordinate not just a linear function of the row index? maybe make this a lambda function.
| allowed_y_space.append([row_ys[i][0]+8, row_ys[i-2][1]-8]) | ||
|
|
||
| self.allowed_vehicle_space = { | ||
| 'x' : (-30, 30), |
There was a problem hiding this comment.
Not sure why this is hardcoded, it doesn't seem to adapt to other configs. Also, this is not used here, please move to create_vehicles.
| 'y' : allowed_y_space | ||
| } | ||
|
|
||
| # Walls |
There was a problem hiding this comment.
not sure why the code for walls is that much longer, it used to be 2 loops for horizontal and vertical walls. Can you not just change the endpoints positions to adapt to number of rows?
| return | ||
|
|
||
| self.sim_surface.move_display_window_to(self.window_position()) | ||
| self.sim_surface.move_display_window_to(self.window_position() if center else [0.5, 0.5]) |
There was a problem hiding this comment.
I don't think you should edit these common files in abstract and graphics, instead just subclass the window_position() method in the environment to customise it.
Also, I don't understand why you use [0.5, 0.5] as a centre position, this is in meters so it looks like a strange choice to me.
Added the following enhancements to the parking environment:
2 rows with walls
4 rows
6 rows
6 rows all cars
Additional Obstacles
Random agent location