Class NPuzzleGraphGenerator

  • All Implemented Interfaces:
    org.api4.java.datastructure.graph.implicit.IGraphGenerator<ai.libs.jaicore.problems.npuzzle.NPuzzleState,​java.lang.String>

    public class NPuzzleGraphGenerator
    extends java.lang.Object
    implements org.api4.java.datastructure.graph.implicit.IGraphGenerator<ai.libs.jaicore.problems.npuzzle.NPuzzleState,​java.lang.String>
    A simple generator for the normal NPuzzleProblem.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected int dimension  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.api4.java.datastructure.graph.implicit.ISingleRootGenerator<ai.libs.jaicore.problems.npuzzle.NPuzzleState> getRootGenerator()  
      org.api4.java.datastructure.graph.implicit.ISuccessorGenerator<ai.libs.jaicore.problems.npuzzle.NPuzzleState,​java.lang.String> getSuccessorGenerator()  
      ai.libs.jaicore.problems.npuzzle.NPuzzleState move​(ai.libs.jaicore.problems.npuzzle.NPuzzleState n, int y, int x)
      The actual move of the empty tile.
      ai.libs.jaicore.problems.npuzzle.NPuzzleState move​(ai.libs.jaicore.problems.npuzzle.NPuzzleState n, java.lang.String move)
      Moves the empty tile to another location.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • dimension

        protected int dimension
    • Constructor Detail

      • NPuzzleGraphGenerator

        public NPuzzleGraphGenerator​(int[][] board)
    • Method Detail

      • getRootGenerator

        public org.api4.java.datastructure.graph.implicit.ISingleRootGenerator<ai.libs.jaicore.problems.npuzzle.NPuzzleState> getRootGenerator()
        Specified by:
        getRootGenerator in interface org.api4.java.datastructure.graph.implicit.IGraphGenerator<ai.libs.jaicore.problems.npuzzle.NPuzzleState,​java.lang.String>
      • getSuccessorGenerator

        public org.api4.java.datastructure.graph.implicit.ISuccessorGenerator<ai.libs.jaicore.problems.npuzzle.NPuzzleState,​java.lang.String> getSuccessorGenerator()
        Specified by:
        getSuccessorGenerator in interface org.api4.java.datastructure.graph.implicit.IGraphGenerator<ai.libs.jaicore.problems.npuzzle.NPuzzleState,​java.lang.String>
      • move

        public ai.libs.jaicore.problems.npuzzle.NPuzzleState move​(ai.libs.jaicore.problems.npuzzle.NPuzzleState n,
                                                                  java.lang.String move)
        Moves the empty tile to another location. The possible parameters to move the empty tiles are: l for moving the empty space to the left. right for moving the empty space to the right. u for moving the empty space upwards. d for moving the empty space downwards.
        Parameters:
        n - The NPuzzleNode which contains the boardconfiguration.
        m - The character which indicates the specific moves. Possible characters are given above.
      • move

        public ai.libs.jaicore.problems.npuzzle.NPuzzleState move​(ai.libs.jaicore.problems.npuzzle.NPuzzleState n,
                                                                  int y,
                                                                  int x)
        The actual move of the empty tile.
        Parameters:
        n - The node which contains the boardconfiguration.
        y - The movement on the y-axis. This value should be -1 if going upwards, 1 if going downwards. Otherwise it should be 0.
        x - The movement on the y-axis. This value should be -1 if going left, 1 if going right. Otherwise it should be 0.