def generateGame(rawGameMat, row, col, mine): zengguang = [] zengguang.append([0] * row * col + [mine]) gameList = MatUtil.mat2list(rawGameMat) for ri in range(len(gameList)): # 丑陋 # 每个非0num有一方程。这个num值,应该改成减完flag的。。。 if 1 <= gameList[ri] <= 8: equ = [0] * len(gameList) # 初始化 mines = gameList[ri] ind8 = MatUtil.circumIjIndexList(MatUtil.ijIndex(col, ri)[0], MatUtil.ijIndex(col, ri)[1], row, col) for ind in ind8: if gameList[MatUtil.realIndex(col, ind[0], ind[1])] == 12: # c equ[MatUtil.realIndex(col, ind[0], ind[1])] = 1 if gameList[MatUtil.realIndex(col, ind[0], ind[1])] == 15: # f mines -= 1 equ.append(mines) # 增广阵的b值 zengguang.append(equ) elif gameList[ri] == 12: # c zengguang[0][ri] = 1 return zengguang
def filt(rawGameMat, soluPool): """简直不能更重要了。返回sage筛选后的soluPool """ gamelist = MatUtil.mat2list(rawGameMat) for i in range(len(gamelist)): # print 'i=',i,'solupool len=',len(soluPool) if not gamelist[i] == 12: # 非sage留0 soluPool = filter(lambda x: x[i] == 0, soluPool) # print 'filt',i,'after, solupool len=',len(soluPool) return soluPool
def filt(rawGameMat, soluPool): '''简直不能更重要了。返回sage筛选后的soluPool ''' gamelist = MatUtil.mat2list(rawGameMat) for i in range(len(gamelist)): # print 'i=',i,'solupool len=',len(soluPool) if not gamelist[i] == 12: # 非sage留0 soluPool = filter(lambda x:x[i] == 0, soluPool) # print 'filt',i,'after, solupool len=',len(soluPool) return soluPool