[REBOL] Re: Slow map generator
From: ryanc::iesco-dms::com at: 8-Nov-2001 11:37
Hey
Here is where all the time is wasted, so its a good place to start:
for x 1 map_size_x 1 [
mx: map_adjust_x (x - 1)
px: map_adjust_x (x + 1)
a: 2 * get_hmap x y
a: a + get_hmap px my
a: a + get_hmap mx my
a: a + get_hmap mx py
a: a + get_hmap px py
a: a + get_hmap x my
a: a + get_hmap mx y
a: a + get_hmap x py
a: a + get_hmap px y
a: max (a - 30 + random 60) 0
set_hmap x y a / 10
]
I would suggest trying something looking like this:
for x 1 map_size_x 1 [
mx: either x - 1< 1 [map_size_x][either x - 1 > map_size_x [1][x - 1]]
px: either x + 1< 1 [map_size_x][either x + 1 > map_size_x [1][x + 1]]
a: 2 * map/:x/:y
a: a + map/:px/:my + map/:mx/:my + map/:mx/:py +
map/:px/:py + map/:x/:my + map/:mx/:y + map/:x/:py +
map/:px/:y
a: max (a - 30 + random 60) 0
poke map/:x y a / 10
]
The idea is that you can problably get a gain by using a x/y mapping scheme in this case.
It should make up for remapping the image when done I could optimize a bit more, keeping
it linear, but maybe later...
--Ryan