The array rows are being over written, so i'm getting the last column written across the array. tilegrid[x][y]=n appears to fill the entire row. I'm calling it a row but it's the Nth item in each sub array that gets over written.
tilegrid=[['O']*7]*9
while running>0:
my = pygetwindow.getWindowsWithTitle('HuniePop 2 - Double Date')
if my:
#left, top, right, bot = win32gui.GetWindowRect(my)
#rect=(my[0].left,my[0].top,my[0].width,my[0].height)
rect=(my[0].left,my[0].top,my[0].left+my[0].width,my[0].top+my[0].height)
#print(rect)
p = PIL.ImageGrab.grab(bbox=rect)
#p = pyautogui.screenshot(region=rect)
for y in range(0,7):
for x in range(0,9):
extract=p.crop(box=(gx+space*x,gy+space*y,gx+size+space*x,gy+size+space*y))
#name="all"+str(x)+str(y)+".png"
#extract.save(name)
n='O'
low=999999
for i in tilelist:
out=PIL.ImageChops.difference(extract,i[0])
val=ImageStat.Stat(out).sum[0]
if val<low:
low=val
n=i[1]
tilegrid[x][y]=n
#print(tilegrid[x][y],end='')
#print(tilegrid)
print(n,end='')
print()
print()
for y in range(0,7):
for x in range(0,9):
print(tilegrid[x][y],end='')
print()
print(tilegrid)
time.sleep(10)
else:
print('Window not found')
running=running-1
time.sleep(10)
If I uncomment the line #print(tilegrid) I can see during each iteration in x the entire row gets filled.
CFPFNFSCD
DFFHSCPDX
XDHDFBXSB
NCNNXNHCF
NPNNFHHDH
SHCDSNFSP
SHCDHCBNF
DDDDDDDDD
XXXXXXXXX
BBBBBBBBB
FFFFFFFFF
HHHHHHHHH
PPPPPPPPP
FFFFFFFFF
[['D', 'X', 'B', 'F', 'H', 'P', 'F'], ['D', 'X', 'B', 'F', 'H', 'P', 'F'], ['D', 'X', 'B', 'F', 'H', 'P', 'F'], ['D', 'X', 'B', 'F', 'H', 'P', 'F'], ['D', 'X', 'B', 'F', 'H', 'P', 'F'], ['D', 'X', 'B', 'F', 'H', 'P', 'F'], ['D', 'X', 'B', 'F', 'H', 'P', 'F'], ['D', 'X', 'B', 'F', 'H', 'P', 'F'], ['D', 'X', 'B', 'F', 'H', 'P', 'F']]