public Move GetMove(CheckerBoard currentBoard, Player player, int turn = 0)
        {
            var root = new DfsNode(currentBoard);

            root.Name = "0";
            AddToTree(root, currentBoard, 0);

            if (root.Children == null || root.Children.Count() == 0)
            {
                return(null);
            }

            var bestScore = new BestInTreeScore {
                Score = Int32.MinValue, Moves = new List <IList <Move> >()
            };

            findBestMoveInTree(root, new List <Move>(), player, bestScore);

            // Save tree
            //TreeJsonSaver.Save("dfs", root);

            if (bestScore.Moves == null || bestScore.Moves.Count == 0)
            {
                return(null);
            }
            else
            {
                //return bestScore.Moves.OrderBy(o => Guid.NewGuid()).First().First();
                var bestPath = listHelper.Random(bestScore.Moves);
                return(bestPath.First());
            }
        }
        private void findBestMoveInTree(DfsNode node, IList <Move> previousMoves, Player player, BestInTreeScore bestScore)
        {
            // Dosao je do lista, evaluate
            if (node.Children == null || node.Children.Count() == 0)
            {
                var s = scoreForceAdventage(node.Board, player);

                if (s > bestScore.Score)
                {
                    bestScore.Score = s;
                    bestScore.Moves.Clear();
                    bestScore.Moves.Add(previousMoves);
                }
                else if (s == bestScore.Score)
                {
                    bestScore.Moves.Add(previousMoves);
                }
            }
            else
            {
                foreach (var child in node.Children)
                {
                    var pm = previousMoves.ToList();
                    pm.Add(child.Move);
                    findBestMoveInTree(child, pm, player, bestScore);
                }
            }
        }