As a more general problem, I have a 2 dimensional array of values. I need to be able to iterate every member of the array and swap it with a psuedo-random neighbor (within an nxn neighborhood). This would ordinarily be trivial, but unfortunately at each step of the iteration, a value can only modify

*itself*and is only aware of the values that exist before iterations and the seed to the whole operation. I cannot cache swaps because each iteration is unaware of them, nor can the iteration be stopped or reversed. Therefore, and more formally, I need a function that takes an x,y pair and produces some psuedorandom x',y' such that f(x,y) = x',y' and f(x',y') = x,y where 0<|x-x'| <= n and 0<|y-y'|<= n. I may be overthinking this (or not thinking at all!) but I'm not sure how to approach this, to be honest.

I suspect that any periocidy would be relatively unnoticeable as the input array is already fairly random. Also, the array is only 4196 x 4196 units large, so a relatively short period would not have a chance of recurring. With these two things in mind, a very bad randomizer is perfectly fine. I also dont care if the algorithm can generate collisions - it's just a noise function, the collisions will be more noise as long as they are not very regular.