Posted: Fri Jun 03, 2005 10:59 am Post subject: Shuffle Algorithm
I need an algorithm that takes my 2d array (1..4, 1..4) and gives each coord (the first array in the 2d is the x, the second is the y) a number from 1 through 16. Each number must be used only once.
Thanks
Sponsor Sponsor
rizzix
Posted: Fri Jun 03, 2005 11:29 am Post subject: (No subject)
n = y*4 + x
Artimes
Posted: Fri Jun 03, 2005 11:37 am Post subject: (No subject)
Wouldn't that give me the same output every time?
lyam_kaskade
Posted: Fri Jun 03, 2005 11:41 am Post subject: (No subject)
code:
for y:0..3
for x:0..3
array (x,y):=(y*4+x) + 1
end for
end for
GlobeTrotter
Posted: Fri Jun 03, 2005 4:38 pm Post subject: (No subject)
Artimes wrote:
Wouldn't that give me the same output every time?
Yes it would, I don't know what these people are talking about.
First go through and assign them normal values, in order 1 - 16 then,
go through the two degrees in nested for loops. In these loops pick a random numer between 1 and 16 and swap the given element with the random one.
Artimes
Posted: Fri Jun 03, 2005 8:11 pm Post subject: (No subject)