Vibe Coding is a cool way to write programs with the help of AI (artificial intelligence). Imagine having a super-smart assistant by your side while coding! The AI can help you in different ways -- it might create an entire program for you, or just give you ideas and help with specific parts, depending on what you need.
To get started, you simply talk to the AI and explain what you want your program to do. The AI will then create a rough version of the program for you. After that, you can ask the AI questions, make suggestions, or request changes to add new features or fix things until the program is just the way you want it.
For this project, I will begin the AI chat with simple request about drawing a single triangle. As the conversation progresses, the requests will get more complex.
Here's a clean, robust implementation of a triangular enclosure made from three 100-unit walls, centered so that (0,0,0) sits roughly in the middle of the triangle. Everything is expressed using your genericShapes API and follows your conventions for wall height, thickness, and material.
Core Geometry (Equilateral Triangle) To make all three walls exactly 100 units long, we use an equilateral triangle. For an equilateral triangle of side length 100: Height (h) = sqrt(3)/2 * 100 ~~ 86.6
A convenient coordinate layout:
Bottom-left vertex: (-50, -28)
Bottom-right vertex: (+50, -28)
Top vertex: x=0, y=57
Example Code (ready to run)
Can you add color using the :color() method? Pass a Color3 value that looks reddish.
Absolutely -- here's the same triangular enclosure, now using the :color() method with a reddish Color3 value applied to each wall.
I'll use a warm red tone like:
Updated Code with Color3 added (ready to run)
Excellent. Now create a slightly more complex algorithm that divides each side into two equal line segments. So, instead of drawing one line for each side, you will draw two lines--a left half and a right half.
Great -- now we'll upgrade the triangular enclosure so that each wall is drawn as two equal wall segments instead of one long wall. This is a clean geometric extension of what you already built.
Below is a modular, scalable approach that:
Computes the midpoint of each wall
Draws two wall segments per side
Preserves the same height, thickness, and material
Keeps the triangle centered around the origin
This keeps the logic teachable and extensible for future "depth-based" subdivision. Step 1 -- Triangle Geometry (same as before) We keep the same equilateral triangle coordinates: A = top B = bottom-left C = bottom-right Each side is 100 units long.
Step 2 -- Helper function to draw a wall in two equal segments This function: Takes two endpoints Computes the midpoint Draws two wall segments Applies color and material
Step 3 -- Use the helper to draw all three sides
Now draw a slightly larger triangle around this one. The larger triangle needs to have the total length of each side as 150 pixels. As for the line segments, this larger triangle should have 3 segments instead of 2. So, it might be better to create a function that performs this line drawing using the segments based on the depth of the triangle. The number of segments will always be the depth of the triangle plus 1. The smallest triangle would be 1+1 and the next larger triangle will be 2+1.
Absolutely, now we'll generalize your triangle-drawing logic into a depth-based segmented wall generator, then use it to draw:
Your original triangle (side = 100, depth = 1 -> 2 segments)
A larger triangle around it (side = 150, depth = 2 -> 3 segments)
This gives you a scalable pattern for any number of triangle layers. Core Idea For any triangle:
depth determines the number of segments per side segments = depth + 1 Each side is subdivided into equal-length wall pieces Each piece is drawn using s.wall()
This is exactly the pattern you described.
Step 1 -- Utility: subdivide a line into N equal segments
This returns an array of points including both endpoints.
Step 2 -- Draw a segmented wall side
Step 3 -- Function to draw a full segmented triangle
Outer triangle (side = 150) For an equilateral triangle:
These points are exactly 150 units apart. Step 5 -- Final combined script
Can you create a function so that multiple levels of triangles can be built? The smallest has a side with length of 50. Then the side of each additional level if 50 more than the previous level and the number of segments increases by 1 for each additional level. I would like to get to 7 levels of triangles.
Absolutely, this is the perfect moment to generalize everything into a multi-level triangular framework generator. You'll get 7 concentric equilateral triangles, each: Centered around the origin Increasing in side length by 50 units per level Increasing in segmentation depth by 1 per level Using your wall-based segmented drawing system
This becomes a clean, scalable geometric engine. Step 1 -- Function to compute triangle vertices All triangles are centered around the origin.
Step 2 -- Subdivide a line into N equal segments
Step 3 -- Draw a segmented wall side
Step 4 -- Draw a full segmented triangle
Step 5 -- Build N levels of triangles This is the function you asked for.
Step 6 -- Build 7 levels
Complete Program (ready to run)
Now I would like to turn this into a very simple maze. Let's assign each side drawn a letter such that the bottom side will be "A" and the left side will be "B" and the right side will be "C". Now, let's select a random line segment from the "A" side and choose not to draw that one segment. Then for the next level of triangle, lets select a random line segment from the "B" side and choose not to draw that one segment. Then for the next level of triangle, lets select a random line segment from the "C" side and do the same. I think a global variable should help keep track of the side that is going to have the missing segment. Then just increment that global variable each time through the loop. Probably, you could include it in the for() loop initialization and increment. For example: for(var depth = 1, side = 1; depth <= 7; depth++, side++) . Then pass the "side" to the drawTriangle() function and use it in a Boolean expression when passing arguments to the drawSegmentedLine() function. Something like: drawSegmentedLine(x1, y1, x2, y2, depth, side%3==1); If the drawSegmentedLine() function receives a "true" as the last parameter, then calculate a random index for the line segment to be skipped and then add an if() condition just before the actual line(sx1, sy1, sx2, sy3) function call.
This is where your framework really starts to feel like a system - we're now layering in maze logic, driven by a rotating side selector (A -> B -> C -> A -> ...), and skipping exactly one segment on the chosen side for each triangle level.
I'll give you a clean, extensible implementation that plugs directly into your existing multi-level triangle generator.
Below is the full upgraded program, with:
Side selector cycling through A, B, C
Each triangle level skipping one random segment on the chosen side
Depth-based segmentation still intact
All triangles centered around the origin
Fully compatible with your genericShapes API
Let's walk through the logic, then I'll show the complete code.
Side Assignment You defined: A = bottom side B = left side C = right side
We'll map these to the triangle edges:
This matches the orientation of your coordinate system. Side Selector Logic We use:
Step 2 -- Update to accept the "side selector"
We pass in a number that determines which side gets the missing segment: * 1 -> A the bottom * 2 -> B the left * 0 -> C the right because side % 3 cycles as 1, 2, 0, 1, 2, 0 etc.
Each side gets exactly one skipped segment. Skipping a Random Segment Inside drawSegmentedWall, we add:
A skipOne boolean
If skipOne == true, choose a random segment index
Skip drawing that segment FULL PROGRAM -- With Maze Logic