001    /*
002     * Created on Sep 12, 2004
003     *
004     */
005    package aima.search.demos;
006    
007    import java.util.Random;
008    
009    import aima.search.eightpuzzle.EightPuzzleBoard;
010    
011    /**
012     * @author Ravi Mohan
013     * 
014     */
015    
016    public class GenerateRandomEightPuzzleBoard {
017            public static void main(String[] args) {
018                    Random r = new Random();
019                    EightPuzzleBoard board = new EightPuzzleBoard(new int[] { 0, 1, 2, 3,
020                                    4, 5, 6, 7, 8 });
021                    for (int i = 0; i < 50; i++) {
022                            int th = r.nextInt(4);
023                            if (th == 0) {
024                                    board.moveGapUp();
025                            }
026                            if (th == 1) {
027                                    board.moveGapDown();
028                            }
029                            if (th == 2) {
030                                    board.moveGapLeft();
031                            }
032                            if (th == 3) {
033                                    board.moveGapRight();
034                            }
035                    }
036                    System.out.println(board);
037            }
038    
039    }