trandoductin wrote:
this is probably a total hack but you could do something like this
(define v #( 0 0 0 0 1 1 1 1 2 2 2 2 ))
(srand (car (gettimeofday)))
(define a 0)
(define b 0)
(define temp 0)
(define swaps 12) ; number of random swaps
(while (> swaps 0)
(set! a (rand (vector-length v)))
(set! b (rand (vector-length v)))
(set! temp (aref v a))
(aset v a (aref v b))
(aset v b temp)
(set! swaps (- swaps 1))
)
I see how it works by swapping the values of two randomly chosen cells, and I take it, referring to it being a total hack is that there is no guarantee all locations are changed, but this might actually work in my favour so I made the variable (swaps) a value to be input. The only changes I made was aset/aref to vector-set/ref
My original script generated a sloped image that produced a bad join when polar coordinates were used
Your hack aids in generating a level image (image 2)
Which gives a good join when polar coordinates are used (image 3)
Thanks again, it would have taken me a long time to work that code out myself if ever
Attachment:
1.jpg [ 26.03 KiB | Viewed 2746 times ]
Attachment:
File comment: image 2
2.jpg [ 105.47 KiB | Viewed 2746 times ]
Attachment:
File comment: image 3
3.jpg [ 91.94 KiB | Viewed 2746 times ]