I GOT IT, a working IsGlyph%(index512) Function AND it confirms my manual count made in reply #17 above. Namely 379 Proper Glyphs can be found in ALL the different fills of a TTT board or 3x3 cell space.
Here is the IsGlyph%(Index512) Function:
I used it to make sure it was a Glyph in the GlyphDraw Sub and I counted all Glyphs drawn for the Shared ProperGlyphCount:
So we get the same graphic I showed you last night in reply #17 only done by Computer coding rather than on sight elimination of Improper Glyphs.
I am going to stick a feather in my hat before I move onto uniqueness of Glyphs. BTW I used simple variable nc in place of an nc() array and forgot to change a comment.
Here is the IsGlyph%(Index512) Function:
Code: (Select All)
Function IsGlyph% (Index512 As Integer)
Dim As Integer x, y, index, CCount, nc, nc1, a(4, 4)
' load a array with 1 if cell is there leave 0 if not
For y = 0 To 2
For x = 0 To 2
index = y * 3 + x
If (Index512 And (2 ^ index)) Then a(x + 1, y + 1) = 1: CCount = CCount + 1
Next
Next
If CCount <= 1 Then Exit Function ' not a Glyph more than one cell needed for Glyph
If CCount > 1 And a(2, 2) = 1 Then IsGlyph% = -1: Exit Function ' center cell means Glyph automatically
' ok now for cells in a() do a neighbor count like in Conway Game of Life, loading nc()
For y = 1 To 3
For x = 1 To 3
If a(x, y) Then ' count neighbors by summing 8 cells around (x, y)
nc = a(x - 1, y - 1) + a(x - 1, y) + a(x - 1, y + 1) + a(x, y - 1) + a(x, y + 1) + a(x + 1, y - 1) + a(x + 1, y) + a(x + 1, y + 1)
If nc = 0 Then Exit Function ' isolated cell = NOT A Glyph!
If nc = 1 Then
nc1 = nc1 + 1
If nc1 > 2 Then Exit Function ' too many dead ends, not a glyph
End If
End If
Next
Next
'still here?
IsGlyph% = -1 ' It passed all my tests !
End FunctionI used it to make sure it was a Glyph in the GlyphDraw Sub and I counted all Glyphs drawn for the Shared ProperGlyphCount:
Code: (Select All)
_Title "3x3 TTT Cell fills IsGlyph Function" ' bplus 2025-09-23
'from
'_title "512 Variations Of TTT Board Fill" 'bplus 2025-09-22
Const PIXEL_SIZE = 7
Const GLYPH_SIZE = 3 * PIXEL_SIZE
Const CELL_SIZE = GLYPH_SIZE + 15
Const GRID_WIDTH = 32
Const GRID_HEIGHT = 16
Const SCREEN_WIDTH = GRID_WIDTH * CELL_SIZE + 15
Const SCREEN_HEIGHT = GRID_HEIGHT * CELL_SIZE + 15
Dim Shared ProperGlyphCount
Dim glyphs(511) As Integer
Screen _NewImage(SCREEN_WIDTH, SCREEN_HEIGHT, 32)
_ScreenMove 60, 60
' 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 511
glyphs(i) = i
Next
' Draw each glyph at its OGN location
For ogn% = 0 To 511
GlyphDraw glyphs(ogn%), ogn%
Next
' Overlay grid lines
DrawGridOverlay
'_PrintString (5, SCREEN_HEIGHT - 20), "Press any key to exit..."
'Do: Loop Until InKey$ <> ""
_MessageBox "Proper Glyphs that can be made from 512 different TTT board fills", " is" + Str$(ProperGlyphCount)
System
Sub GlyphDraw (shape%, ogn%)
If IsGlyph%(ogn%) = 0 Then Exit Sub Else ProperGlyphCount = ProperGlyphCount + 1
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 + 15
y% = baseY% + row% * PIXEL_SIZE + 15
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
Function IsGlyph% (Index512 As Integer)
Dim As Integer x, y, index, CCount, nc, nc1, a(4, 4)
' load a array with 1 if cell is there leave 0 if not
For y = 0 To 2
For x = 0 To 2
index = y * 3 + x
If (Index512 And (2 ^ index)) Then a(x + 1, y + 1) = 1: CCount = CCount + 1
Next
Next
If CCount <= 1 Then Exit Function ' not a Glyph more than one cell needed for Glyph
If CCount > 1 And a(2, 2) = 1 Then IsGlyph% = -1: Exit Function ' center cell means Glyph automatically
' ok now for cells in a() do a neighbor count like in Conway Game of Life, loading nc()
For y = 1 To 3
For x = 1 To 3
If a(x, y) Then ' count neighbors by summing 8 cells around (x, y)
nc = a(x - 1, y - 1) + a(x - 1, y) + a(x - 1, y + 1) + a(x, y - 1) + a(x, y + 1) + a(x + 1, y - 1) + a(x + 1, y) + a(x + 1, y + 1)
If nc = 0 Then Exit Function ' isolated cell = NOT A Glyph!
If nc = 1 Then
nc1 = nc1 + 1
If nc1 > 2 Then Exit Function ' too many dead ends, not a glyph
End If
End If
Next
Next
'still here?
IsGlyph% = -1 ' It passed all my tests !
End Function
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 + 15
y% = gy% * CELL_SIZE + 15
For i = 1 To 2
Line (x% + i * PIXEL_SIZE, y%)-(x% + i * PIXEL_SIZE, y% + GLYPH_SIZE - 1), _RGB32(0) ', 128, 128), BF
Line (x%, y% + i * PIXEL_SIZE)-(x% + GLYPH_SIZE - 1, y% + i * PIXEL_SIZE), _RGB32(0) ', 128, 128), BF
Next
Next
Next
End SubSo we get the same graphic I showed you last night in reply #17 only done by Computer coding rather than on sight elimination of Improper Glyphs.
I am going to stick a feather in my hat before I move onto uniqueness of Glyphs. BTW I used simple variable nc in place of an nc() array and forgot to change a comment.
724 855 599 923 575 468 400 206 147 564 878 823 652 556 bxor cross forever

