def generate(psX, psY, ring): '''psX, psY - prescalers for x, y''' map = {} while ring.stepcounter < 360: x, y = polar_to_cartesian(*ring.getrandomcoords()) x *= psX y *= psY fillin(map, int(x), int(y)) ring.advance() return map
def pkogen(maxprovinz): MAPSIZE = 100 # This is only half of the map! MINDIST = 60-maxprovinz*2 provinzes = [] failed_attempts = 0 while failed_attempts < 50: prov = (random()*(MAPSIZE-MINDIST//2), random()*360) try: for pt in provinzes: if polarcs_distance(prov[0], prov[1], pt[0], pt[1]) < MINDIST: failed_attempts += 1 raise Exception except: continue failed_attempts = 0 provinzes.append(prov) if len(provinzes) == maxprovinz: break provinzes = map(lambda x: polar_to_cartesian(*x), provinzes) provinzes = map(lambda x: (int(x[0]), int(x[1])), provinzes) return provinzes