' **************** ' create a perlin noise heightmap ' I'm not hugely bothered about the properties of the heightmap, so perlin will do. ' You'll want something a bit less erratic Function perlin#[,](size,steps=4) Local map#[size,size] Local tmp#[size,size] Local tsize,x,y,i,j,u#,v# Local f = 1 For s=1 To steps tsize = size/f For x=0 To tsize-1 For y=0 To tsize-1 tmp[x,y] = Rnd()/steps Next Next For x=0 To tsize-1 For y=0 To tsize-1 For i=0 To f-1 For j=0 To f-1 u#=Float(i)/f v#=Float(j)/f map[x*f+i,y*f+j] :+ (1-u)*(1-v)*tmp[x,y] + (1-u)*v*tmp[x,y+1] + u*(1-v)*tmp[x+1,y] + u*v*tmp[x+1,y+1] Next Next Next Next f:*2 Next Return map End Function Function round(n#) If (n Mod 1)<.5 Return Floor(n) Else Return Floor(n)+1 End Function ' round off heights to a certain number of discrete levels, so the map is less smooth Function stepmap(map#[,],levels) Local size = Sqr(Len(map)) Local x,y For x=0 To size-1 For y=0 To size-1 map[x,y] = round(map[x,y]*levels)/Float(levels) Next Next End Function ' apply a symmetric exponential function to the heights, to increase the difference between highs and lows Function curvemap(map#[,],pow#=.5) Local size = Sqr(Len(map)) Local x,y Local t#,s For x=0 To size-1 For y=0 To size-1 t#=map[x,y]-.5 s=Sgn(t) t=Abs(t)^pow map[x,y] = s*t+.5 Next Next End Function ' create a circular plateau, to make a space that a province can be seen to spread across quickly Function hill(map#[,],x,y,minr#=.05,maxr#=.2) Local size = Sqr(Len(map)) Local f# = Rnd(minr,maxr) Local r# = f*size Local h# = Rnd(0,1) Local i,j,w,u,v For i = -r To r u = x+i If u>=0 And u=0 And v=0 And i=0 And j