Class NPuzzleGraphGenerator
- java.lang.Object
-
- ai.libs.jaicore.search.exampleproblems.npuzzle.standard.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
-
Constructor Summary
Constructors Constructor Description NPuzzleGraphGenerator(int[][] board)
-
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.
-
-
-
Method Detail
-
getRootGenerator
public org.api4.java.datastructure.graph.implicit.ISingleRootGenerator<ai.libs.jaicore.problems.npuzzle.NPuzzleState> getRootGenerator()
- Specified by:
getRootGenerator
in interfaceorg.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 interfaceorg.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.
-
-