mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-10 13:51:53 +09:00
some bayer matrix things and my discoveries
This commit is contained in:
64
work_files/odd_numbered_bayer_matrix_gen.py
Normal file
64
work_files/odd_numbered_bayer_matrix_gen.py
Normal file
@@ -0,0 +1,64 @@
|
||||
def printMatrix(mat):
|
||||
for n in range(matrixSize):
|
||||
outstr = ""
|
||||
for k in range(matrixSize):
|
||||
outstr += str(mat[n][k])
|
||||
|
||||
if (k < matrixSize - 1):
|
||||
outstr += ","
|
||||
|
||||
|
||||
print(outstr)
|
||||
|
||||
|
||||
|
||||
matrixSize = 9
|
||||
# Matrix sizes I've tested:
|
||||
# slanted diagonal (gud!): 7, 8, 9
|
||||
# ortho pattern: 3, 4, 6
|
||||
# ortho diagonal: 5
|
||||
|
||||
|
||||
matrix = [x[:] for x in [[-1] * matrixSize] * matrixSize]
|
||||
|
||||
|
||||
# init matrix
|
||||
cellX = 0
|
||||
cellY = (matrixSize >> 1)
|
||||
for num in range(matrixSize * matrixSize):
|
||||
if (matrix[cellY][cellX] == -1):
|
||||
matrix[cellY][cellX] = num
|
||||
else:
|
||||
thefuck = matrix[cellY][cellX]
|
||||
error("Matrix position ("+str(cellX)+", "+str(cellY)+"is occupied by "+thefuck)
|
||||
|
||||
if (matrix[(cellY - 1) % matrixSize][(cellX + 1) % matrixSize] == -1):
|
||||
cellX = (cellX + 1) % matrixSize
|
||||
cellY = (cellY - 1) % matrixSize
|
||||
else:
|
||||
cellY = (cellY + 1) % matrixSize
|
||||
|
||||
|
||||
# vertical shifts
|
||||
for xpos in range(0, matrixSize):
|
||||
lookup = [-1] * matrixSize
|
||||
|
||||
for ycursor in range(matrixSize):
|
||||
lookup[ycursor] = matrix[ycursor][xpos]
|
||||
|
||||
for ycursor in range(matrixSize):
|
||||
matrix[(ycursor - xpos) % matrixSize][xpos] = lookup[ycursor]
|
||||
|
||||
|
||||
# horizontal shifts
|
||||
for ypos in range(0, matrixSize):
|
||||
shift = (matrixSize - 1) - ypos + 1
|
||||
lookup = list(matrix[ypos])
|
||||
|
||||
for xcursor in range(matrixSize):
|
||||
matrix[ypos][(xcursor + shift) % matrixSize] = lookup[xcursor]
|
||||
|
||||
|
||||
|
||||
|
||||
printMatrix(matrix)
|
||||
BIN
work_files/the_accidental_bayer_matrix.xlsx
Normal file
BIN
work_files/the_accidental_bayer_matrix.xlsx
Normal file
Binary file not shown.
Reference in New Issue
Block a user