how to array with some random from a set?

I want to make a wooden house. The wall is made up from several meshes(for example, red/green/green 3 meshes). Is there a way to place the wood pole in some random way, but

  1. on x-direction, there are X_num poles; on y-direction, there are Y_num poles
  2. the disance is random, 0<=dx<=dx_max, 0<=dy<=dy_max, but no pole are allowed to overlap
  3. the pole can rotate 0<=dphi<=dphi_max

thnaks

http://pic9.huitu.com/res/20130605/138821_20130605002257358200_1.jpg