Exemplo n.º 1
0
    private void Solve_TreeSolver()
    {
        if (_treeSolver == null && _solverThread == null)
        {
            _solverThread = new Thread(() =>
            {
                Debug.LogFormat("[TileGridController] - WORKER THREAD - Starting solver...");

                _treeSolver    = new Solvers.TreeSolver(CurrentBoardState, _maxSolverSearchDepth, _stopAfterNSolutionsFound);
                int[] solution = _treeSolver.Solution;

                UnityMainThreadDispatcher.Instance().Enqueue(() =>
                {
                    _treeSolver   = null;
                    _solverThread = null;

                    if (solution != null)
                    {
                        Debug.LogFormat("[TileGridController] - MAIN THREAD solution (length:{0}): [{1}]", solution.Length, string.Join(", ", solution));
                    }
                    else
                    {
                        Debug.LogFormat("[TileGridController] - MAIN THREAD found no solution for current board state");
                    }
                });
            });

            _solverThread.Start();
        }
    }
 public void Before()
 {
     _ts = new TreeSolver();
 }