#!/usr/bin/env python from copy import deepcopy from random import shuffle X = 10 Y = 12 grid = [[None for i in range(X)] for j in range(Y)] indices = [(i,j) for j in range(Y) for i in range(X)] shuffle(indices) # patterns will be a dict of dict of lists, such that: # patterns[c1][c2] = [(dx, dy), ...] where (dx, dy) are the offsets # from a tile of color c2 to a tile of color c1 patterns = {} for i,j in indices: c = 0 while True: c += 1 # check if we're the same color of adjacent tiles print 'on tile ', i, j, ' trying ', c if j>0: if i>0: if grid[j-1][i-1] == c: print 'matches above left' continue if i+10: if grid[j][i-1] == c: print 'matches left' continue if i+10: if grid[j+1][i-1] == c: print 'matches below left' continue if i+1