#include <iostream>
#include <string>
#include "BackTrack.h"
#include "Application.h"
#include "Position.h"

using namespace std;

int main()
{
    const string INITIAL_STATE =
        "The initial state is as follows:\n";
    const string FINAL_STATE =
        "The final state is as follows:\n";
    const string SUCCESS=
        "\n\nA solution has been found:";
    const string START_FAILURE =
        "\n\nThe start position is invalid.";
    const string FAILURE =
        "\n\nThere is no solution:";

    Application app;
    Position start = app.generateInitialState();
    cout << INITIAL_STATE << endl;
    cout << app << endl;
    BackTrack b (app);
    if (!app.valid (start))
        cout << START_FAILURE << endl;
    else
    {
        app.record (start);
        if (app.done (start) || b.tryToSolve (start))
            cout << SUCCESS << endl << app;
        else
        {
            app.undo (start);
            cout << FAILURE << endl << app;
        } // failure after starting
    } // start is valid

    return 0;
} // main


