public class Node { private Node parent; public Node[] children; private int numChildren; private int number; private int pathCost; private int nodeCost; private String nodename; public int a; public int b; public int movetiems = 0; public int traveltimes = 0; public Node() { number = 0; nodeCost = 0; numChildren = 0; pathCost = 0; children = new Node[3];//Max 3 way to move nodename = new String(""); }/* public void expand() { for (int i = 1; i <= 8; ++i) { //if (puzzles.legal(i)) { //Puzzle puzzle = new Puzzle(puzzles.number); //puzzle.move(i); //Node child = new Node(puzzle); child.parent = this; child.number = i; child.pathCost = pathCost + 1; // Using A* search,may change to another search //child.nodeCost = pathCost + puzzle.totalCost(); //children[numChildren++] = child; } } }*/ public void addChild(String name){ Node child = new Node(); child.parent = this; child.nodename = name; children[numChildren++] = child; } public void addChild(String name,int value){ addChild(name); children[numChildren-1].nodeCost = value; } public void setCost(int c){ nodeCost = c; } public Node getParent() { return parent; } public int getNumChildren() { return numChildren; } public Node getChild(int i) { return children[i]; } public int getPuzzleNumber() { return number; } public int getCost() { return nodeCost; } public void setName(String n){ nodename = n; } public Node getNode(String name){ for(int i=0;ithis.parent.a) this.parent.a = beta; System.out.println("Unexpanding "+minmax+" Node "+ nodename+" alpha="+alpha+" Beta="+beta); return nodeCost; }else{ a = alpha; b = beta; } int value = 0; for(int i=0;ithis.parent.a){ this.parent.a = b; this.parent.movetiems++; } } return a; } public boolean allChildHaveNumber(){ boolean right = true; for(int i=0;i max) max = children[i].nodeCost; } return max; } public int getMinFromChild(){ int min = 32767; for(int i=0;i