void Graphics::pushState(State &state) {
    compareState(mState.top(), state);
    mState.push(state);
}
void Graphics::popState() {
    State &prev_state = mState.top();
    mState.pop();
    compareState(prev_state, mState.top());
}
bool PlannerThread::planning_cycle()
{
    checkPause();
    if (!updateState())
    {
        return false;
    }
    checkPause();
    if (!completePlannerState())
    {
        return false;
    }
    checkPause();
    if (!loadState())
    {
        return false;
    }
    checkPause();
    if (compareState())
    {
        checkPause();
        if (!adaptRules())
        {
            return false;
        }
        checkPause();
    }
    checkPause();
    if (!goalUpdate())
    {
        return false;
    }
    checkPause();
    if (!loadGoal())
    {
        return false;
    }
    checkPause();
    if (!planCompletion())
    {
        return true;
    }
    checkPause();
    if (!checkHoldingSymbols())
    {
        checkPause();
        jumpBack();
        checkPause();
        if (!resetConfig())
        {
            return false;
        }
        checkPause();
    }
    else 
    {
        checkPause();
        if (checkGoalCompletion())
        {
            checkPause();
            if (!resetRules())
            {
                return false;
            }
            checkPause();
            if (!resetConfig())
            {
                return false;
            }
            checkPause();
            if (!loadRules())
            {
                return false;
            }
            checkPause();
            if (!jumpForward())
            {
                return false;
            }
            checkPause();
            return true;
        }
        checkPause();
        int flag_prada = PRADA();
        checkPause();
        if (flag_prada == 0)
        {
            return false;
        }
        else if (flag_prada == 2)
        {
            if (!increaseHorizon())
            {
                return false;
            }
            checkPause();
            return true;
        }
        if (!loadUsedObjs())
        {
            return false;
        }
        checkPause();
        if (!codeAction())
        {
            return false;
        }
        checkPause();
        if (!execAction())
        {
            return false;
        }
        checkPause();
        if (!preserveState())
        {
            return false;
        }
        checkPause();
        if (!checkFailure())
        {
            return false;
        }
        checkPause();
    }
    checkPause();
    return true;
}