ID:1544457
 
(See the best response by Ter13.)
Code:
world
maxx=65
maxy=65
view=32
loop_checks=0

turf
icon = 'White.dmi'
snow
icon_state = "White"
stone
icon_state = "Grey"
grass
icon_state = "Green"
sand
icon_state = "Yellow"
water
icon_state = "Blue"
mob
icon = 'white.dmi'
icon_state = "Ply"
Stat()
stat("Stats","[Progress]")
verb
Start()
StartWorld()

var/Grid[1024][1024]
var/Progress = 0
var/Tiles = 0

proc
StartWorld()
var/mx = world.maxx
var/my = world.maxy
var/Total = 20
var/a = rand(10)
Grid[1][mx] = a
MakeIcon(a,1,my)
Total -= a

var/b = rand(Total /1)
Grid[mx][my] = b
MakeIcon(b,mx,my)
Total -= b

var/c = rand(Total /2)
Grid[mx][1] = c
MakeIcon(c,mx,1)
Total -= c

var/d = rand(Total /3)
Grid[1][1] = d
MakeIcon(d,1,1)
Diamond(a,1,world.maxy, b,world.maxx,world.maxy, c,world.maxx,1, d,1,1, mx*my)

Diamond(a,ax,ay, b,bx,by, c,cx,cy, d,dx,dy,size)
size /= 3
world << "[size]"
if(size < 2)
return

var/da = (a + b) / 2
var/dax = (ax + bx) / 2
var/day = (ay + by) / 2
Grid[dax][day] = da
MakeIcon(da,dax,day)

var/db = (b + c) / 2
var/dbx = (bx + cx) / 2
var/dby = (by + cy) / 2
Grid[dbx][dby] = db
MakeIcon(db,dbx,dby)

var/dc = (c + d) / 2
var/dcx = (cx + dx) / 2
var/dcy = (cy + dy) / 2
Grid[dcx][dcy] = dc
MakeIcon(dc,dcx,dcy)

var/dd = (d + a) / 2
var/ddx = (dx + ax) / 2
var/ddy = (dy + ay) / 2
Grid[ddx][ddy] = dd
MakeIcon(dd,ddx,ddy)

var/m = (da + db + dc + dd )/4
var/mx = (dax + dbx + dcx + ddx )/4
var/my = (day + dby + dcy + ddy )/4
Grid[mx][my] = m
MakeIcon(m,mx,my)
Tiles += 5
Progress = (world.maxx*world.maxy) - Tiles
spawn(1) Diamond(a,ax,ay,da,dax,day,m,mx,my,dd,ddx,ddy,size)
spawn(1) Diamond(da,dax,day,b,bx,by,db,dbx,dby,m,mx,my,size)
spawn(1) Diamond(m,mx,my,db,dbx,dby,c,cx,cy,dc,dcx,dcy,size)
spawn(1) Diamond(dd,ddx,ddy,m,mx,my,dc,dcx,dcy,d,dx,dy,size)

ReadMap(list/Grid)

var/x = 1
var/y = 1
for(var/i, i <= world.maxx+world.maxy,i++)
var/H = Grid[x][y]
var/turf/T = locate(x,y,1)
T.text = "[round(H)]"
MakeIcon(a,ax,ay)
var/type
if(a < 3){
type = /turf/water
}else if(a < 5){
type = /turf/sand
}else if(a < 8){
type = /turf/grass
}else if(a < 9){
type = /turf/stone
}else if(a <= 20){
type = /turf/snow
}
new type(locate(ax,ay,1))

Mmk, so using the diamond square tech i made my own version for byond, originally was going to make a list that had 3 variables in it Height, X, and Y, and then storing those lists in another list called Grid, but error after error it just wasnt worth it, so i settled so a more simple approach, the thing is, its too simple, if you C/P this into DM and make a new .dmi file for the turfs, you will see once you run it that it works PERFECTLY, with 1 flaw, it is pretty much just straight lines, i wanna know how to make it more random, more realistic, this is my first time doing D/S algorithm and im just grasping the concept, anyone with more experience willing to help me? Btw, i tried to add rand(0,1) to da,db,dc,dd and it just made the map weird looking like you could see where each square was, im guessing this is because im dumb or something but wht/evr im feeling accomplished atm so i wont let my horribleness effect me xD, but yeah if anyone could tell id love you forever <3

Let me link you to my years-old experiment with diamond-square.

http://www.byond.com/members/ Ter13?command=view_post&post=139795

I'll warn you, it's rough.
Thanks ter, but i believe ive read that already, also it dosnt answer my question, mine works perfectly, just i need more randomness to it so it isnt 4 straight lines, but i dont know where to begin :S for me it was hard just to understand how D/S works and implement it into DM(Implementing was the hardest lol).
Best response
Maybe show me the results so I can better understand the problem?

Diamond-square algorithm is just a way to subdivide space and induce turbulence. If you need more randomness, you should look into limiting the scope of your initial fractal cross-section to only part of the total map area, and having more seed points.