{"spec_id":"maze-printable","library":"seaborn","language":"python","code":"\"\"\" anyplot.ai\nmaze-printable: Printable Maze Puzzle\nLibrary: seaborn 0.13.2 | Python 3.13.13\nQuality: 87/100 | Updated: 2026-05-16\n\"\"\"\n\nimport os\n\nimport matplotlib.pyplot as plt\nimport numpy as np\nimport seaborn as sns\n\n\n# Theme tokens\nTHEME = os.getenv(\"ANYPLOT_THEME\", \"light\")\nPAGE_BG = \"#FAF8F1\" if THEME == \"light\" else \"#1A1A17\"\nINK = \"#1A1A17\" if THEME == \"light\" else \"#F0EFE8\"\n\n# Okabe-Ito palette\nIMPRINT = [\"#009E73\", \"#C475FD\", \"#4467A3\", \"#BD8233\", \"#AE3030\", \"#2ABCCD\", \"#954477\"]\n\n# Set theme\nsns.set_theme(style=\"white\", rc={\"figure.facecolor\": PAGE_BG, \"axes.facecolor\": PAGE_BG, \"text.color\": INK})\n\n# Maze parameters\nnp.random.seed(123)\nWIDTH = 25\nHEIGHT = 25\n\n# Initialize maze grid (0=wall, 1=passage)\nmaze = np.zeros((2 * HEIGHT + 1, 2 * WIDTH + 1), dtype=int)\n\n# Carve passages using DFS\nvisited = np.zeros((HEIGHT, WIDTH), dtype=bool)\nstack = [(0, 0)]\nvisited[0, 0] = True\nmaze[1, 1] = 1\n\ndirections = [(0, 1), (1, 0), (0, -1), (-1, 0)]\n\nwhile stack:\n    y, x = stack[-1]\n    neighbors = []\n\n    for dy, dx in directions:\n        ny, nx = y + dy, x + dx\n        if 0 <= ny < HEIGHT and 0 <= nx < WIDTH and not visited[ny, nx]:\n            neighbors.append((ny, nx, dy, dx))\n\n    if neighbors:\n        ny, nx, dy, dx = neighbors[np.random.randint(len(neighbors))]\n        visited[ny, nx] = True\n        maze[2 * ny + 1, 2 * nx + 1] = 1\n        maze[2 * y + 1 + dy, 2 * x + 1 + dx] = 1\n        stack.append((ny, nx))\n    else:\n        stack.pop()\n\n# Create figure - square format for maze (3600x3600 px)\nfig, ax = plt.subplots(figsize=(12, 12), facecolor=PAGE_BG)\n\n# Create heatmap with theme-aware colors\nif THEME == \"light\":\n    colors = [\"#000000\", \"#FFFFFF\"]\nelse:\n    colors = [\"#FFFFFF\", \"#000000\"]\n\ncmap = sns.color_palette(colors, as_cmap=True)\nsns.heatmap(maze, ax=ax, cmap=cmap, cbar=False, square=True, xticklabels=False, yticklabels=False, linewidths=0)\n\n# Mark start position (top-left passage)\nstart_y, start_x = 1, 1\ncircle_start = plt.Circle((start_x + 0.5, start_y + 0.5), 0.55, color=IMPRINT[0], zorder=10)\nax.add_patch(circle_start)\nax.text(\n    start_x + 0.5,\n    start_y + 0.5,\n    \"S\",\n    fontsize=22,\n    fontweight=\"bold\",\n    color=\"white\",\n    ha=\"center\",\n    va=\"center\",\n    zorder=11,\n)\n\n# Mark goal position (bottom-right passage)\ngoal_y, goal_x = 2 * HEIGHT - 1, 2 * WIDTH - 1\ncircle_goal = plt.Circle((goal_x + 0.5, goal_y + 0.5), 0.55, color=IMPRINT[1], zorder=10)\nax.add_patch(circle_goal)\nax.text(\n    goal_x + 0.5, goal_y + 0.5, \"G\", fontsize=22, fontweight=\"bold\", color=\"white\", ha=\"center\", va=\"center\", zorder=11\n)\n\n# Add title\nax.set_title(\"maze-printable · seaborn · anyplot.ai\", fontsize=28, fontweight=\"bold\", pad=20, color=INK)\n\n# Clean up for printing\nax.set_aspect(\"equal\")\nsns.despine(left=True, bottom=True)\n\nplt.tight_layout()\nplt.savefig(f\"plot-{THEME}.png\", dpi=300, bbox_inches=\"tight\", facecolor=PAGE_BG)\n"}