Package aima.gui.demo.search

Source Code of aima.gui.demo.search.GenerateRandomEightPuzzleBoard

package aima.gui.demo.search;

import java.util.Random;

import aima.core.environment.eightpuzzle.EightPuzzleBoard;

/**
* @author Ravi Mohan
*
*/

public class GenerateRandomEightPuzzleBoard {
  public static void main(String[] args) {
    Random r = new Random();
    EightPuzzleBoard board = new EightPuzzleBoard(new int[] { 0, 1, 2, 3,
        4, 5, 6, 7, 8 });
    for (int i = 0; i < 50; i++) {
      int th = r.nextInt(4);
      if (th == 0) {
        board.moveGapUp();
      }
      if (th == 1) {
        board.moveGapDown();
      }
      if (th == 2) {
        board.moveGapLeft();
      }
      if (th == 3) {
        board.moveGapRight();
      }
    }
    System.out.println(board);
  }

}
TOP

Related Classes of aima.gui.demo.search.GenerateRandomEightPuzzleBoard

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.