예제 #1
0
        private static void ClassicMinMax_Iteration(int currentDepth, AJL_Tree Tree)
        {
            bool isMaximisingPlayer = currentDepth % 2 != 0 ? true : false; //0,2,4...false, 1,3,5...true

            foreach (var node in Tree.depthCollection[currentDepth])
            {
                if (isMaximisingPlayer)
                {
                    double tempScore = -1_000;
                    foreach (var child in node.childIDs)
                    {
                        tempScore = Math.Max(Tree.identCollection[child].score, tempScore);
                    }
                    node.score = tempScore;
                }
                else
                {
                    double tempScore = 1_000;
                    foreach (var child in node.childIDs)
                    {
                        tempScore = Math.Min(Tree.identCollection[child].score, tempScore);
                    }
                    node.score = tempScore;
                }
            }
        }
예제 #2
0
        public static void ClassicMinMax(AJL_Tree Tree)
        {
            var currentDepth = Tree.depthCollection.Last().Key - 1;

            for (int i = currentDepth; i >= 0; i--)
            {
                ClassicMinMax_Iteration(i, Tree);
            }
        }