Don't like ads? PRO users don't see any ads ;-)
Guest

geekboy possible shuffle

By: a guest on Apr 10th, 2010  |  syntax: None  |  size: 0.50 KB  |  hits: 108  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. been googling found this ^_^
  2.  
  3.  
  4.  
  5. public void scramble() // Called from the outside
  6.         {
  7.                 int i,j,k,l;
  8.                 if (!automatic)
  9.                 {
  10.                         for (i=0;i<4;i++)
  11.                                 for (j=0;j<4;j++)
  12.                                         map[7+i*6+j]=(i*4+j+1)&15;
  13.                         for (i=0;i<16;i++)
  14.                         {
  15.                                 l=(randi()>>5)%15;
  16.                                 j=7+6*(l/4)+(l&3);
  17.                                 l=(randi()>>5)%15;
  18.                                 k=7+6*(l/4)+(l&3);
  19.                                 while (k==j)
  20.                                 {
  21.                                         l=(randi()>>5)%15;
  22.                                         k=7+6*(l/4)+(l&3);
  23.                                 }
  24.                                 l=map[k];
  25.                                 map[k]=map[j];
  26.                                 map[j]=l;
  27.                         }
  28.                         buildBackground();
  29.                         repaint();
  30.                 }
  31.         }