Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
program to draw a grid of grids and out put all unique 3X3 patterns
#1
here Is a program I was writing with the help of Ai It works but not as expected it is supposed to create all 3x 3 glyphs that are unique )shifted shapes don't count as unique it is supposed to place each unique 3X3 pattern into each grid and it only fills the first grid what is wrong? the rules it has to follow is simple every shape or glyph must have every pixel in it connected to all the others either horizontally or vertically or diagonally I allready know there are 260 in this set  and there are 92 that are not including rotations of ones but including mirror images ones where the mirror does not match the origional shape no matter how much it is rotated or shifted there are 19 such chiraal shapes leaving 73 shapes if you count these mirror images as being the same... how can I fix this program so it properly displays all 260 glyphs and in the right locations even, and possibly adding in a value for each that gives it a unique value based on an order binary representation of the glyph? (reading up from 2^0 being the bottom left and increasing left to right and bottom to top in powers of 2)?? and saya printing this value in a 3 by 4 graphical font that draws the numbers into the wasste space under each glyph? that can be added later I just need to figure out how to get the glyphs to displaay right The ai keeps spitting out programs that are identically equivelent to this one. like it is stuck in an unending loop, please help
Code: (Select All)
DECLARE SUB GlyphDraw(shape%, ogn%)
DECLARE SUB DrawGridOverlay()

Const PIXEL_SIZE = 10
Const GLYPH_SIZE = 3 * PIXEL_SIZE
Const CELL_SIZE = GLYPH_SIZE + 15
Const GRID_WIDTH = 20
Const GRID_HEIGHT = 13
Const SCREEN_WIDTH = GRID_WIDTH * CELL_SIZE
Const SCREEN_HEIGHT = GRID_HEIGHT * CELL_SIZE

Dim glyphs(259) As Integer

Screen _NewImage(SCREEN_WIDTH, SCREEN_HEIGHT, 32)

' Fill background with blue
Line (0, 0)-(SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1), _RGB32(32, 32, 196), BF

' Generate 260 random glyphs (0 to 511)
Randomize Timer
For i = 0 To 259
    glyphs(i) = Int(Rnd * 512)
Next

' Draw each glyph at its OGN location
For ogn = 0 To 259
    GlyphDraw glyphs(ogn), ogn
Next

' Overlay grid lines
DrawGridOverlay

_PrintString (5, SCREEN_HEIGHT - 20), "Press any key to exit..."
Do: Loop Until InKey$ <> ""

Sub GlyphDraw (shape%, ogn%)
    Dim row%, col%, index%, x%, y%
    Dim baseX%, baseY%
    baseX = (ogn Mod GRID_WIDTH) * CELL_SIZE
    baseY = (ogn \ GRID_WIDTH) * CELL_SIZE

    For row = 0 To 2
        For col = 0 To 2
            index = row * 3 + col
            x = baseX + col * PIXEL_SIZE
            y = baseY + row * PIXEL_SIZE
            If (shape And (2 ^ index)) Then
                Line (x, y)-(x + PIXEL_SIZE - 1, y + PIXEL_SIZE - 1), _RGB32(76, 255, 0), BF
            Else
                Line (x, y)-(x + PIXEL_SIZE - 1, y + PIXEL_SIZE - 1), _RGB32(0, 96, 0), BF
            End If
        Next
    Next
End Sub

Sub DrawGridOverlay
    Dim gx%, gy%, x%, y%
    For gx = 0 To GRID_WIDTH - 1
        For gy = 0 To GRID_HEIGHT - 1
            x = gx * CELL_SIZE
            y = gy * CELL_SIZE
            For i = 1 To 2
                Line (x + i * PIXEL_SIZE, y)-(x + i * PIXEL_SIZE, y + GLYPH_SIZE - 1), _RGB32(128, 128, 128), BF
                Line (x, y + i * PIXEL_SIZE)-(x + GLYPH_SIZE - 1, y + i * PIXEL_SIZE), _RGB32(128, 128, 128), BF
            Next
        Next
    Next
End Sub
Reply


Messages In This Thread
program to draw a grid of grids and out put all unique 3X3 patterns - by Dragoncat - 09-22-2025, 11:39 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  draw lines and polygons with triangles . James D Jarvis 2 883 09-15-2023, 03:00 PM
Last Post: James D Jarvis

Forum Jump:


Users browsing this thread: