def place_units_around(owner, type, x, y, dxm, dym, nmin, nmax): n = rand_range(nmin, nmax-nmin) for i in range(n): dx,dy = rand_diff(2,2) xx,yy = force_valid_coords(x+dx, y+dy) u = Unit(owner,type,xx,yy) units.append(u)
def splash_terrain(terr, x, y, dx, dy, nmin, limit, maxdepth=100, depth=0, sofar=0): depth += 1 if depth > maxdepth: return sofar, depth if is_valid_xy(x,y): map[x][y].terr = terr sofar += 1 if sofar >= limit: return sofar, depth minbase = min(nmin-sofar, 1) n = rand_range(minbase,5) for i in range(n): if chance(3,4): pass else: odx = dx ody = dy dx,dy = rand_diff(2,2) dx = dx + odx dy = dy + ody nx = x + dx ny = y + dy sofar, depth = splash_terrain(terr,nx,ny,dx,dy,nmin,limit,maxdepth,depth,sofar) if sofar >= limit: break return sofar, depth