I can see a few things that are likely to be causing problems:
1. Adding the 0.9999 when picking a random no. for RandYPlacement means you may pick a number outside of the Y index of the array - remember that the Height is one more than the max Y value as the Y index starts at 0.
2. RandYPlacement can keep picking the same number in each loop so some values won't be selected and others could be duplicated.
3. When setting the size of Working_Answer_Array your Z axis needs to be at least 1.
It's always good to try and work things out in a way you can understand but to be honest it would be worth getting your head around Mikal's code - it's quite elegant and really simplifies the process.
Here's a similar version that's even simpler! ;-P
It essentially does the same thing, but only needs one variable; in this case "pick" is a variable added to the array, rather than a local variable.
The "for" loop runs once for each X index in the array.
Each time the loop runs:
- the first action saves to "pick" an index value between 0 and the max X index minus the current loop index, so the first loop it picks between 0 and Width-1 minus 0, the second loop 0 and Width-1 minus 1 and so on until it gets to the final loop where it picks between 0 and width-1 minus width-1, or just 0.
- the second action adds the value in the array at the index "pick" to the end of the array (or "pushes back").
- the third action deletes the index "pick".
This final action reduces the number of values to pick from by one, which is why we reduce the scope of pick by the loopindex at the start of the next loop. Effectively what happens is each loop a random value that hasn't already been picked is grabbed and stuck on the end of the array.
Hope that helps! :-)