joker727 Claude Opus 4.8 commited on
Commit
900b2ee
·
1 Parent(s): e7e6d91

Fully tile the flat (no gaps); realistic single passage

Browse files

100% tiled plans (apartment flat, not a house): rooms grow into every void
and leftover interior pockets become one small passage (never on the outer
wall, never a dead-end). GPT prompt updated to tile the whole plate.
Verified 2BHK 30x40 & 3BHK 40x60: 100% fill, 0 overlaps, all rooms present,
pooja in NE, <=1 interior passage.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

Files changed (2) hide show
  1. core/gpt_layout.py +10 -2
  2. core/pdf_templates.py +26 -4
core/gpt_layout.py CHANGED
@@ -129,11 +129,19 @@ _LAYOUT_SYSTEM = (
129
  "bedroom ~11%, kitchen ~7%, dining_room ~7%, study ~5%, staircase ~12%, "
130
  "washroom ~3%, utility ~2%, pooja ~2%. The master must be the biggest room, "
131
  "the living room clearly bigger than any washroom, and pooja the smallest.\n\n"
 
 
 
 
 
 
 
132
  "OUTPUT: ONLY JSON, no markdown:\n"
133
  '{"layouts":[{"columns":[{"width":<0..1>,"rooms":[{"name":<room>,'
134
  '"height":<0..1>}, ...]}, ...]}, ...]}\n'
135
- "Rules: column widths in a layout sum to ~1.0; room heights in a column sum "
136
- "to ~1.0; use 2-3 columns; include EVERY requested room EXACTLY once and add "
 
137
  "no others (internal_corridor is optional). Make each layout STRUCTURALLY "
138
  "DIFFERENT from the others (move rooms between columns, change column count "
139
  "and widths) while keeping every Vastu rule above."
 
129
  "bedroom ~11%, kitchen ~7%, dining_room ~7%, study ~5%, staircase ~12%, "
130
  "washroom ~3%, utility ~2%, pooja ~2%. The master must be the biggest room, "
131
  "the living room clearly bigger than any washroom, and pooja the smallest.\n\n"
132
+ "THIS IS A FLAT INSIDE AN APARTMENT BUILDING, not a house on open ground: "
133
+ "the rooms must TILE THE WHOLE floor plate with NO leftover gaps — every bit "
134
+ "of the plot is a room (walls are shared). Do NOT leave empty space. If a "
135
+ "little circulation space is genuinely needed to reach inner rooms, give it "
136
+ "to a single small internal_corridor/passage that is bounded by rooms on both "
137
+ "sides (never a big hall, never running along an outer wall, never a stub "
138
+ "that dead-ends).\n\n"
139
  "OUTPUT: ONLY JSON, no markdown:\n"
140
  '{"layouts":[{"columns":[{"width":<0..1>,"rooms":[{"name":<room>,'
141
  '"height":<0..1>}, ...]}, ...]}, ...]}\n'
142
+ "Rules: column widths in a layout MUST sum to EXACTLY 1.0; room heights in a "
143
+ "column MUST sum to EXACTLY 1.0 (this is what keeps the flat fully tiled with "
144
+ "no gaps); use 2-3 columns; include EVERY requested room EXACTLY once and add "
145
  "no others (internal_corridor is optional). Make each layout STRUCTURALLY "
146
  "DIFFERENT from the others (move rooms between columns, change column count "
147
  "and widths) while keeping every Vastu rule above."
core/pdf_templates.py CHANGED
@@ -1577,9 +1577,13 @@ def _ensure_present(boxes, names, ix0, iy0, ix1, iy1):
1577
  for nm in names:
1578
  if nm == "internal_corridor" or any(b["name"] == nm for b in boxes):
1579
  continue
1580
- donor = max((b for b in boxes if b["name"] not in names
1581
- and b["name"] not in _FIXED),
1582
- key=lambda b: b["w"] * b["h"], default=None)
 
 
 
 
1583
  if donor is None or donor["w"] * donor["h"] < 24.0:
1584
  continue
1585
  if donor["w"] >= donor["h"]:
@@ -2833,9 +2837,27 @@ def build_from_spec(spec, name, plot_w, plot_h, road_side, selected_optional,
2833
  rooms = _close_all_gaps(rooms, lx0, ly0, lx1, ly1)
2834
  rooms = _enforce_size_hierarchy(rooms)
2835
  rooms = _promote_master_to_largest(rooms)
2836
- rooms = _close_all_gaps(rooms, lx0, ly0, lx1, ly1)
2837
  rooms = _ensure_present(rooms, ({"kitchen"} | _PROTECT),
2838
  lx0, ly0, lx1, ly1)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2839
  rooms = _resolve_overlaps(rooms)
2840
 
2841
  if road_side != "S":
 
1577
  for nm in names:
1578
  if nm == "internal_corridor" or any(b["name"] == nm for b in boxes):
1579
  continue
1580
+ # Prefer to carve from a room that isn't itself a must-have; but if every
1581
+ # room is required, fall back to the largest room that isn't the missing
1582
+ # one / a fixed / the tiny pooja, so a donor always exists.
1583
+ cand = [b for b in boxes if b["name"] != nm and b["name"] not in _FIXED
1584
+ and b["name"] != "pooja_room"]
1585
+ pref = [b for b in cand if b["name"] not in names]
1586
+ donor = max(pref or cand, key=lambda b: b["w"] * b["h"], default=None)
1587
  if donor is None or donor["w"] * donor["h"] < 24.0:
1588
  continue
1589
  if donor["w"] >= donor["h"]:
 
2837
  rooms = _close_all_gaps(rooms, lx0, ly0, lx1, ly1)
2838
  rooms = _enforce_size_hierarchy(rooms)
2839
  rooms = _promote_master_to_largest(rooms)
 
2840
  rooms = _ensure_present(rooms, ({"kitchen"} | _PROTECT),
2841
  lx0, ly0, lx1, ly1)
2842
+ # FULLY TILE the flat — an apartment has NO white gaps. First grow the
2843
+ # spacious rooms into every void; then label any leftover INTERIOR pocket
2844
+ # as a passage (internal_corridor). Corridors are kept realistic: at most
2845
+ # one, never sitting on the outer wall (those are absorbed into the
2846
+ # neighbouring room), so a passage never dead-ends against the boundary.
2847
+ rooms = _close_all_gaps(rooms, lx0, ly0, lx1, ly1)
2848
+ for _ in range(3):
2849
+ _fill_voids(rooms, lx0, ly0, lx1, ly1, cell=0.5, min_void=0.4,
2850
+ allow_new_balcony=False)
2851
+ rooms = _close_all_gaps(rooms, lx0, ly0, lx1, ly1, any_room=True)
2852
+ rooms = _merge_fragments(rooms)
2853
+ _fill_voids(rooms, lx0, ly0, lx1, ly1, cell=0.3, min_void=0.2,
2854
+ allow_new_balcony=False)
2855
+ # Corridor cleanup LAST so it always wins: passages never sit on the
2856
+ # outer wall, and at most ONE small passage survives.
2857
+ rooms = _merge_fragments(rooms)
2858
+ rooms = _absorb_edge_corridors(rooms, lx0, ly0, lx1, ly1)
2859
+ rooms = _limit_corridors(rooms, lx0, ly0, lx1, ly1, max_keep=1)
2860
+ rooms = _absorb_edge_corridors(rooms, lx0, ly0, lx1, ly1)
2861
  rooms = _resolve_overlaps(rooms)
2862
 
2863
  if road_side != "S":