private int alphabeta(Node root, int alpha, int beta, bool maximizingPlayer)
        {
            if (root.isLeaf())
            {
                return(root.value);
            }

            if (maximizingPlayer)
            {
                foreach (Node n in root.children)
                {
                    alpha = Math.Max(alpha, alphabeta(n, alpha, beta, false));
                    if (beta < alpha)
                    {
                        break;
                    }
                }
                root.value = alpha;
                return(alpha);
            }
            else
            {
                foreach (Node n in root.children)
                {
                    beta = Math.Min(beta, alphabeta(n, alpha, beta, true));
                    if (beta < alpha)
                    {
                        break;
                    }
                }
                root.value = beta;
                return(beta);
            }
        }
        private int max(Node root)
        {
            if (root.isLeaf())
            {
                return(root.value);
            }
            else
            {
                int highestValue = Int32.MinValue;

                foreach (Node n in root.children)
                {
                    int value = min(n);
                    if (value > highestValue)
                    {
                        highestValue = value;
                        n.value      = value;
                    }
                }

                root.value = highestValue;
                return(highestValue);
            }
        }
        private int min(Node root)
        {
            if (root.isLeaf())
            {
                return(root.value);
            }
            else
            {
                int lowestValue = Int32.MaxValue;

                foreach (Node n in root.children)
                {
                    int value = max(n);
                    if (value < lowestValue)
                    {
                        lowestValue = value;
                        n.value     = value;
                    }
                }

                root.value = lowestValue;
                return(lowestValue);
            }
        }