import matplotlib.pyplot as plt
import matplotlib.patches as patches

# Create a figure and axis
fig, ax = plt.subplots(figsize=(12, 6))

# Define the grid size
rows, cols = 3, 5

# Define the colors for clear and painted tiles
clear_color = 'lightgreen'
white_paint_color = 'white'
black_paint_color = 'black'

# Define the robot color
robot1_color = 'white'

# Define the tile status for the goal state
tile_status = {
    'tile_0-1': 'clear', 'tile_0-2': 'clear', 'tile_0-3': 'clear', 'tile_0-4': 'clear', 'tile_0-5': 'clear',
    'tile_1-1': 'painted white', 'tile_1-2': 'painted black', 'tile_1-3': 'painted white', 'tile_1-4': 'painted black', 'tile_1-5': 'painted white',
    'tile_2-1': 'painted black', 'tile_2-2': 'painted white', 'tile_2-3': 'painted black', 'tile_2-4': 'painted white', 'tile_2-5': 'painted black',
}

# Draw the tiles
for row in range(rows):
    for col in range(cols):
        tile_id = f'tile_{row}-{col+1}'
        status = tile_status[tile_id]
        if 'painted white' in status:
            color = white_paint_color
        elif 'painted black' in status:
            color = black_paint_color
        else:
            color = clear_color
        rect = patches.Rectangle((col, rows-row-1), 1, 1, linewidth=1, edgecolor='black', facecolor=color)
        ax.add_patch(rect)
        ax.text(col + 0.5, rows-row-0.5, tile_id, ha='center', va='center', fontsize=8, color='black' if color != black_paint_color else 'white')

# Draw the robot with "no constraints" status
robot1_position = (0.5, -0.5)
circle1 = patches.Circle(robot1_position, 0.3, edgecolor='black', facecolor=robot1_color)
ax.add_patch(circle1)
ax.text(robot1_position[0], robot1_position[1] - 0.2, 'robot1\n(no constraints)', ha='center', va='center', fontsize=8, color='black')

# Draw available colors
color_white_position = (6, 2)
color_black_position = (6, 1)
rect_white = patches.Rectangle(color_white_position, 1, 1, linewidth=1, edgecolor='black', facecolor=white_paint_color)
ax.add_patch(rect_white)
ax.text(color_white_position[0] + 0.5, color_white_position[1] + 0.5, 'color_white\navailable', ha='center', va='center', fontsize=8, color='black')

rect_black = patches.Rectangle(color_black_position, 1, 1, linewidth=1, edgecolor='black', facecolor=black_paint_color)
ax.add_patch(rect_black)
ax.text(color_black_position[0] + 0.5, color_black_position[1] + 0.5, 'color_black\navailable', ha='center', va='center', fontsize=8, color='white')

# Set limits and labels
ax.set_xlim(0, cols + 2)
ax.set_ylim(-1, rows)
ax.set_xticks([])
ax.set_yticks([])

# Add legend
legend_elements = [
    patches.Patch(facecolor=clear_color, edgecolor='black', label='Clear Tile'),
    patches.Patch(facecolor=white_paint_color, edgecolor='black', label='Painted White'),
    patches.Patch(facecolor=black_paint_color, edgecolor='black', label='Painted Black'),
    patches.Patch(facecolor=robot1_color, edgecolor='black', label='Robot1 (White)'),
]
ax.legend(handles=legend_elements, loc='upper right', bbox_to_anchor=(1.3, 1))

# Save the figure
plt.savefig('<PATH_REMOVED>', bbox_inches='tight')
plt.show()