def add_wall(self, wall): if wall == "right": # Right wall self.walls.append( VerticalWall( self.ball_radius, self.inner_wall_max_dist, -self.inner_wall_max_dist, self.inner_wall_max_dist, )) if wall == "left": # Left wall self.walls.append( VerticalWall( self.ball_radius, -self.inner_wall_max_dist, -self.inner_wall_max_dist, self.inner_wall_max_dist, )) if wall == "bottom": # Bottom wall self.walls.append( HorizontalWall( self.ball_radius, self.inner_wall_max_dist, -self.inner_wall_max_dist, self.inner_wall_max_dist, )) if wall == "top": self.walls.append( HorizontalWall( self.ball_radius, -self.inner_wall_max_dist, -self.inner_wall_max_dist, self.inner_wall_max_dist, ))
def __init__(self, wall_shape="", inner_wall_max_dist=1, **kwargs): self.quick_init(locals()) super().__init__(**kwargs) self.inner_wall_max_dist = inner_wall_max_dist self.wall_shape = wall_shape if wall_shape == "u": self.walls = [ # Right wall VerticalWall( self.ball_radius, self.inner_wall_max_dist, -self.inner_wall_max_dist, self.inner_wall_max_dist, ), # Left wall VerticalWall( self.ball_radius, -self.inner_wall_max_dist, -self.inner_wall_max_dist, self.inner_wall_max_dist, ), # Bottom wall HorizontalWall( self.ball_radius, self.inner_wall_max_dist, -self.inner_wall_max_dist, self.inner_wall_max_dist, ) ] if wall_shape == "-": self.walls = [ HorizontalWall( self.ball_radius, self.inner_wall_max_dist, -self.inner_wall_max_dist, self.inner_wall_max_dist, ) ] if wall_shape == "--": self.walls = [ HorizontalWall( self.ball_radius, 0, -self.inner_wall_max_dist, self.inner_wall_max_dist, ) ]
def fixed_wall(self, wall_shape): if wall_shape == "u": self.walls = [ # Right wall VerticalWall( self.ball_radius, self.inner_wall_max_dist, -self.inner_wall_max_dist, self.inner_wall_max_dist, ), # Left wall VerticalWall( self.ball_radius, -self.inner_wall_max_dist, -self.inner_wall_max_dist, self.inner_wall_max_dist, ), # Bottom wall HorizontalWall( self.ball_radius, self.inner_wall_max_dist, -self.inner_wall_max_dist, self.inner_wall_max_dist, ) ] if wall_shape == "-" or wall_shape == "h": self.walls = [ HorizontalWall( self.ball_radius, self.inner_wall_max_dist, -self.inner_wall_max_dist, self.inner_wall_max_dist, ) ] if wall_shape == "--": self.walls = [ HorizontalWall( self.ball_radius, 0, -self.inner_wall_max_dist, self.inner_wall_max_dist, ) ] if wall_shape == "big-u": self.walls = [ VerticalWall(self.ball_radius, self.inner_wall_max_dist * 2, -self.inner_wall_max_dist * 2, self.inner_wall_max_dist, self.wall_thickness), # Left wall VerticalWall(self.ball_radius, -self.inner_wall_max_dist * 2, -self.inner_wall_max_dist * 2, self.inner_wall_max_dist, self.wall_thickness), # Bottom wall HorizontalWall(self.ball_radius, self.inner_wall_max_dist, -self.inner_wall_max_dist * 2, self.inner_wall_max_dist * 2, self.wall_thickness), ] if wall_shape == "easy-u": self.walls = [ VerticalWall(self.ball_radius, self.inner_wall_max_dist * 2, -self.inner_wall_max_dist * 0.5, self.inner_wall_max_dist, self.wall_thickness), # Left wall VerticalWall(self.ball_radius, -self.inner_wall_max_dist * 2, -self.inner_wall_max_dist * 0.5, self.inner_wall_max_dist, self.wall_thickness), # Bottom wall HorizontalWall(self.ball_radius, self.inner_wall_max_dist, -self.inner_wall_max_dist * 2, self.inner_wall_max_dist * 2, self.wall_thickness), ] if wall_shape == "big-h": self.walls = [ # Bottom wall HorizontalWall( self.ball_radius, self.inner_wall_max_dist, -self.inner_wall_max_dist * 2, self.inner_wall_max_dist * 2, ), ] if wall_shape == "box": self.walls = [ # Bottom wall VerticalWall(self.ball_radius, 0, 0, 0, self.wall_thickness), ] if wall_shape == "none": self.walls = []
def __init__( self, wall_shape="", inner_wall_max_dist=1, **kwargs ): self.quick_init(locals()) super().__init__(**kwargs) self.inner_wall_max_dist = inner_wall_max_dist self.wall_shape = wall_shape if wall_shape == "u": self.walls = [ # Right wall VerticalWall( self.ball_radius, self.inner_wall_max_dist, -self.inner_wall_max_dist, self.inner_wall_max_dist, ), # Left wall VerticalWall( self.ball_radius, -self.inner_wall_max_dist, -self.inner_wall_max_dist, self.inner_wall_max_dist, ), # Bottom wall HorizontalWall( self.ball_radius, self.inner_wall_max_dist, -self.inner_wall_max_dist, self.inner_wall_max_dist, ) ] if wall_shape == "-": self.walls = [ HorizontalWall( self.ball_radius, self.inner_wall_max_dist, -self.inner_wall_max_dist, self.inner_wall_max_dist, ) ] if wall_shape == "--": self.walls = [ HorizontalWall( self.ball_radius, 0, -self.inner_wall_max_dist, self.inner_wall_max_dist, ) ] if wall_shape == 'maze': self.walls = [ VerticalWall( min_dist=self.ball_radius, x_pos=-5, bottom_y=-9.5, top_y=-2, thickness=0.5 ), VerticalWall( min_dist=self.ball_radius, x_pos=-5, bottom_y=2, top_y=7, thickness=0.5 ), HorizontalWall( min_dist=self.ball_radius, y_pos=-5, left_x=0, right_x=6, thickness=0.5 ) ]
def __init__(self, wall_shape="hard-maze", wall_thickness=1.0, inner_wall_max_dist=1, **kwargs): self.quick_init(locals()) super().__init__(**kwargs) self.inner_wall_max_dist = inner_wall_max_dist self.wall_shape = wall_shape self.wall_thickness = wall_thickness WALL_FORMATIONS = { "u": [ # Right wall VerticalWall( self.ball_radius, self.inner_wall_max_dist, -self.inner_wall_max_dist, self.inner_wall_max_dist, ), # Left wall VerticalWall( self.ball_radius, -self.inner_wall_max_dist, -self.inner_wall_max_dist, self.inner_wall_max_dist, ), # Bottom wall HorizontalWall( self.ball_radius, self.inner_wall_max_dist, -self.inner_wall_max_dist, self.inner_wall_max_dist, ) ], "-": [ HorizontalWall( self.ball_radius, self.inner_wall_max_dist, -self.inner_wall_max_dist, self.inner_wall_max_dist, ) ], "--": [ HorizontalWall( self.ball_radius, 0, -self.inner_wall_max_dist, self.inner_wall_max_dist, ) ], "big-u": [ VerticalWall(self.ball_radius, self.inner_wall_max_dist * 2, -self.inner_wall_max_dist * 2, self.inner_wall_max_dist, self.wall_thickness), # Left wall VerticalWall(self.ball_radius, -self.inner_wall_max_dist * 2, -self.inner_wall_max_dist * 2, self.inner_wall_max_dist, self.wall_thickness), # Bottom wall HorizontalWall(self.ball_radius, self.inner_wall_max_dist, -self.inner_wall_max_dist * 2, self.inner_wall_max_dist * 2, self.wall_thickness), ], "easy-u": [ VerticalWall(self.ball_radius, self.inner_wall_max_dist * 2, -self.inner_wall_max_dist * 0.5, self.inner_wall_max_dist, self.wall_thickness), # Left wall VerticalWall(self.ball_radius, -self.inner_wall_max_dist * 2, -self.inner_wall_max_dist * 0.5, self.inner_wall_max_dist, self.wall_thickness), # Bottom wall HorizontalWall(self.ball_radius, self.inner_wall_max_dist, -self.inner_wall_max_dist * 2, self.inner_wall_max_dist * 2, self.wall_thickness), ], "big-h": [ # Bottom wall HorizontalWall( self.ball_radius, self.inner_wall_max_dist, -self.inner_wall_max_dist * 2, self.inner_wall_max_dist * 2, ), ], "box": [ # Bottom wall VerticalWall(self.ball_radius, 0, 0, 0, self.wall_thickness), ], "easy-maze": [ VerticalWall( self.ball_radius, 0, -self.boundary_dist, self.inner_wall_max_dist, ), ], "medium-maze": [ VerticalWall( self.ball_radius, -self.boundary_dist / 3, -self.boundary_dist, self.inner_wall_max_dist, ), VerticalWall(self.ball_radius, self.boundary_dist / 3, -self.inner_wall_max_dist, self.boundary_dist), ], "hard-maze": [ HorizontalWall( self.ball_radius, -self.boundary_dist + self.inner_wall_max_dist, -self.boundary_dist, self.inner_wall_max_dist, ), VerticalWall( self.ball_radius, self.inner_wall_max_dist, -self.boundary_dist + self.inner_wall_max_dist, self.boundary_dist - self.inner_wall_max_dist, ), HorizontalWall( self.ball_radius, self.boundary_dist - self.inner_wall_max_dist, -self.boundary_dist + self.inner_wall_max_dist, self.inner_wall_max_dist, ), VerticalWall( self.ball_radius, -self.boundary_dist + self.inner_wall_max_dist, -self.boundary_dist + self.inner_wall_max_dist * 2, self.boundary_dist - self.inner_wall_max_dist, ), HorizontalWall( self.ball_radius, -self.boundary_dist + self.inner_wall_max_dist * 2, -self.boundary_dist + self.inner_wall_max_dist, 0, ), ], "horizontal-maze": [ HorizontalWall( self.ball_radius, -self.boundary_dist / 2, -self.boundary_dist, self.inner_wall_max_dist, ), HorizontalWall(self.ball_radius, 0, -self.inner_wall_max_dist, self.boundary_dist), HorizontalWall( self.ball_radius, self.boundary_dist / 2, -self.boundary_dist, self.inner_wall_max_dist, ), ], None: [], } self.walls = WALL_FORMATIONS.get(wall_shape, [])
def __init__(self, wall_shape="", wall_thickness=1.0, inner_wall_max_dist=1, **kwargs): self.quick_init(locals()) super().__init__(**kwargs) self.inner_wall_max_dist = inner_wall_max_dist self.wall_shape = wall_shape self.wall_thickness = wall_thickness if wall_shape == "u": self.walls = [ # Right wall VerticalWall( self.ball_radius, self.inner_wall_max_dist, -self.inner_wall_max_dist, self.inner_wall_max_dist, ), # Left wall VerticalWall( self.ball_radius, -self.inner_wall_max_dist, -self.inner_wall_max_dist, self.inner_wall_max_dist, ), # Bottom wall HorizontalWall( self.ball_radius, self.inner_wall_max_dist, -self.inner_wall_max_dist, self.inner_wall_max_dist, ) ] if wall_shape == "-" or wall_shape == "h": self.walls = [ HorizontalWall( self.ball_radius, self.inner_wall_max_dist, -self.inner_wall_max_dist, self.inner_wall_max_dist, ) ] if wall_shape == "--": self.walls = [ HorizontalWall( self.ball_radius, 0, -self.inner_wall_max_dist, self.inner_wall_max_dist, ) ] if wall_shape == "big-u": self.walls = [ VerticalWall(self.ball_radius, self.inner_wall_max_dist * 2, -self.inner_wall_max_dist * 2, self.inner_wall_max_dist, self.wall_thickness), # Left wall VerticalWall(self.ball_radius, -self.inner_wall_max_dist * 2, -self.inner_wall_max_dist * 2, self.inner_wall_max_dist, self.wall_thickness), # Bottom wall HorizontalWall(self.ball_radius, self.inner_wall_max_dist, -self.inner_wall_max_dist * 2, self.inner_wall_max_dist * 2, self.wall_thickness), ] if wall_shape == "easy-u": self.walls = [ VerticalWall(self.ball_radius, self.inner_wall_max_dist * 2, -self.inner_wall_max_dist * 0.5, self.inner_wall_max_dist, self.wall_thickness), # Left wall VerticalWall(self.ball_radius, -self.inner_wall_max_dist * 2, -self.inner_wall_max_dist * 0.5, self.inner_wall_max_dist, self.wall_thickness), # Bottom wall HorizontalWall(self.ball_radius, self.inner_wall_max_dist, -self.inner_wall_max_dist * 2, self.inner_wall_max_dist * 2, self.wall_thickness), ] if wall_shape == "big-h": self.walls = [ # Bottom wall HorizontalWall( self.ball_radius, self.inner_wall_max_dist, -self.inner_wall_max_dist * 2, self.inner_wall_max_dist * 2, ), ] if wall_shape == "box": self.walls = [ # Bottom wall VerticalWall(self.ball_radius, 0, 0, 0, self.wall_thickness), ] if wall_shape == "none": self.walls = []