コード例 #1
0
    /// <summary>
    /// Update UI;
    /// Check the solver's state and manipulate UI accordingly;
    /// </summary>
    void Update()
    {
        // If the solver just stopped
        if (solverRunning && !m_NQueensSolver.IsRunning())
        {
            solverRunning = false;

            Vector2Int[] solverResult = m_NQueensSolver.FetchResult();

            if (solverResult != null)
            {
                // if a solution is found:
                // 1. change UI
                // 2. show the solution on the checker board
                m_UiController.OnSolverFinish();

                m_CheckerBoard.SetQueens(solverResult);
            }
            else
            {
                // if calculation is cancelled:
                // only change UI
                m_UiController.OnSolverCancelled();
            }
        }
    }