def check_free(self): # loop through each n-omino for ord_c in range(1,6): # get free pieces ominoes = self.get_pieces(ord_c) # loop through each piece for piece_i in range(len(ominoes)): piece = ominoes[piece_i] piece = [[int(math.ceil(float(col)/10)) for col in row] for row in piece] piece = Piece.remove_empty(piece) # check given piece against all other pieces for check_i in range(len(ominoes)): # skip, if piece index is same as check index if piece_i==check_i: continue # loop through all possible configurations (rotations/translations) confs = range(0,8) for conf_i in confs: # grab piece to check against check = ominoes[check_i] check = [[int(math.ceil(float(col)/10)) for col in row] for row in check] check = Piece.remove_empty(check) if conf_i==0: pass elif conf_i==1: check = Piece.rot_90(check) elif conf_i==2: check = Piece.rot_180(check) elif conf_i==3: check = Piece.rot_270(check) elif conf_i==4: check = Piece.mirror_horz(check) elif conf_i==5: check = Piece.mirror_horz(check) check = Piece.rot_90(check) elif conf_i==6: check = Piece.mirror_vert(check) elif conf_i==7: check = Piece.mirror_vert(check) check = Piece.rot_90(check) if piece==check: print 'identical pieces found. {0},{1},{2},{3}'.format( ord_c,piece_i,check_i,conf_i) print piece print check
for color_i in colors: # loop through each configuration for conf_i in confs: # skip configurations that aren't unique if ord_c<=1 and conf_i>=1: continue if ord_c<=2 and conf_i>=2: continue if ord_c<=3 and conf_i>=4: continue # get current piece & remove empty rows/cols tiles = ominoes[omino_i]; tiles = Piece.remove_empty(tiles) # rotate/mirror current piece if conf_i==0: pass elif conf_i==1: tiles = Piece.rot_90(tiles) elif conf_i==2: tiles = Piece.rot_180(tiles) elif conf_i==3: tiles = Piece.rot_270(tiles) elif conf_i==4: tiles = Piece.mirror_horz(tiles); elif conf_i==5: tiles = Piece.mirror_horz(tiles); tiles = Piece.rot_90(tiles)