public void movement(int zeroIndex, int direction, GridState current) {
        // First check that the movement would be valid
        if (rulesForMovement(zeroIndex, direction)) {
            // Create a new child based on the current state
            GridState child = createChild(current.getElements(), zeroIndex,
                    direction);

            // Set cost of getting to the child state and parent
            child.setCost(current.getCost() + 1);
            child.setParent(current);
            /*
             * Set heuristic cost
             */
            child.setHeuristicCost(heuristic.getHeuristicCost(child, goal));

            /*
             * If the child state is not in the open or closed list, we haven't
             * explored it at all yet, so add to the open list.
             */
            if (!inOpenList(child) && !inClosedList(child)) {
                this.addToOpen(child);

                /*
                 * If it is in a list, find out which list
                 */
            } else {
                GridState checker = inList(child, open);
                /*
                 * If it is in the open list, check to see if it's cost is
                 * better now than it was in the previous open list.
                 */
                if (checker != null) {
                    if (child.getCost() < checker.getCost()) {
                        removeFromOpen(checker);
                        addToOpen(child);
                    } else {
                        /*
                         * Else check if it's in the closed list, and if it's
                         * state was better, then we 'update' the closed list
                         * with the new child.
                         */
                        checker = inList(child, closed);
                        if (checker != null) {
                            if (child.getCost() < checker.getCost()) {
                                removeFromClosed(checker);
                                addToClosed(child);
                            }
                        }
                    }
                }
            }
        }
    }