from node import Node



# Inputs:   Initial state 9 numbers (0-9) long in order from top left corner of board to bottom right
#           Goal state: list of 9 numbers (0-8) in order from top left corner of 8-puzzle board to bottom right
#           Number representing search wanted (0:BFS, 1:GBFS, 2:A* Misplaced, 3:A* Manhattan)

# Outputs:
#         Total Expanded nodes
#         Path generated by search selected, representing the movement of the blank position
#


def api():
    closed = []
    queue = []
    a = Node()
    a.board = list(map(int, input("\nEnter initial state of the 8-puzzle by entering the numbers in a spaced list\n"
                   "Going left to right starting with the first row, represent the blank with a 0\n"
                   "Example: 0 1 2 3 4 5 6 7 8  \n\nInitial State:").split(" ")))

    a.goal = list(map(int, input("Enter initial state of the 8-puzzle by entering the numbers in a spaced list\n"
                  "Going left to right starting with the first row, represent the blank with a 0\n"
                  "Example: 0 1 2 3 4 5 6 7 8  \n\nGoal State:").split(" ")))
    a.searchType = 2
    a.searchType = int(input("Enter 0:BFS, "
                    "1:GBFS, "
                    "2:A* Misplaced, "
                    "3:A* Manhattan:\n"))

    a.initial_search_value()

    if a.parityCompare(a.goal, a.board):
        queue.append(a)
        if(a.goal != a.board):
            k = a.move(queue, closed)
            print("Inputs of blank movement from initial to final state: \n", a.directions(k.path()))
        else:
            print("8-Puzzle Completed with 0 moves or expansions")
    else:
        print("UNABLE TO BE SOLVED DUE TO PARITY")


api()
