def checkNeighbors(k,flag,connectors,mapfiledata): return any([checkType(x,flag,mapfiledata) for x in itertools.chain.from_iterable(filter(lambda xx: k in xx, connectors))])
drawObj.line(segs[2],fill=color,width=6) # load a font fontsize = max(im.width,im.height)/75 if args.fontsize_province_number <= 0 else args.fontsize_province_number fnt = ImageFont.truetype(args.fontface,fontsize) #select out territories def numLandConnections(k,connectors): return len(filter(lambda xx: k in xx, connectors)) def checkNeighbors(k,flag,connectors,mapfiledata): return any([checkType(x,flag,mapfiledata) for x in itertools.chain.from_iterable(filter(lambda xx: k in xx, connectors))]) """ Example section of taking a map, turning off some throne locations, turning on some caves, turning off the thrones that were already on""" ratios = map(lambda x: 1 if 4 <= numLandConnections(x,connections['normal'].union(connections['river'],connections['mountain'])) and not checkType(x,'Nostart',mapfiledata) else 0, range(1,len(whites_xy)+1)) #ratios = map(lambda x: 1 if 4 <= numLandConnections(x,connections['normal'].union(connections['river'],connections['mountain'])) and not checkType(x,'Nostart',mapfiledata) and not checkNeighbors(x,'Throne',connections['normal'].union(connections['river'],connections['mountain'])) else 0, range(1,len(terrain_types)+1)) # draw connections based on input if args.connection_types == 'all': keys = ('normal','mountain','river','aquatic','amphibious','info-only') elif args.connection_types == 'passable': keys = ('normal','mountain','river','aquatic','amphibious') else: keys = [args.connection_types] for key in keys: for x in connections[key]: decision_inputs = (x,line(x),(im.width,im.height),isPeriodicNS,isPeriodicEW) displayThisPath = eval("profiles."+args.profile).path_filter(*decision_inputs) if displayThisPath: