[REBOL] Re: Slow map generator
From: ryanc:iesco-dms at: 8-Nov-2001 13:16
I optimized a few more little things...
repeat x map_size_x [ ; 'repeat was much faster than 'for in my most recent tests.
mx: pick mx-table x ; lookup tables instead for a sizable gain
px: pick px-table x
; I missed a little last time here. Continious math operations are real fast.
a: 2 * map/:x/:y + 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 0 a - 30 + random 60 ; a little switcheroo here for a minor gain
poke pick map x y a / 10 ; faster yet
]
That should be much faster. --Ryan
Ryan Cole wrote:
> 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
>
> --
> To unsubscribe from this list, please send an email to
> [rebol-request--rebol--com] with "unsubscribe" in the
> subject, without the quotes.
--
Ryan Cole
Programmer Analyst
www.iesco-dms.com
707-468-5400
The contradiction so puzzling to the ordinary way
of thinking comes from the fact that we have to use
language to communicate our inner experience
which in its very nature transcends lingistics.
-D.T. Suzuki