import pygame def get_empty_cells(grid): """ Returns a list of (x, y) tuples for cells in grid that are empty (value 0). """ empty = [] for y, row in enumerate(grid): for x, cell in enumerate(row): if cell == 0: empty.append((x, y)) return empty def get_cell_center(x, y, cell_size=80): """ Converts cell coordinates (x, y) to pixel coordinates of the cell center. """ return pygame.Vector2(x * cell_size + cell_size / 2, y * cell_size + cell_size / 2) def draw_arrow(surface, color, start, end, width=3): pygame.draw.line(surface, color, start, end, width) direction = (end - start).normalize() arrow_size = 10 perpendicular = pygame.Vector2(-direction.y, direction.x) point1 = end - direction * arrow_size + perpendicular * arrow_size / 2 point2 = end - direction * arrow_size - perpendicular * arrow_size / 2 pygame.draw.polygon(surface, color, [end, point1, point2])