welcome: please sign in

2009-12-07 01:04:49時点のリビジョン2

メッセージを消す
location: 解のある配置を作る

ばらばらにする

        int spx, spy;

                g.setColor(Color.lightGray);
                g.fillRect(spx*haba, spy*haba, haba, haba);

                spx = yoko-1;
                spy = tate-1;
                for (cnt = 0; cnt < (tate*yoko*2); )    // 偶数回置換
                {
                        x = (int)(Math.random() * yoko);
                        y = (int)(Math.random() * tate);
                        if(x != spx || y != spy)
                        {
                                ban[spx][spy] = ban[x][y];
                                spx = x;
                                spy = y;
                                cnt++;
                        }
                }