예제 #1
0
        public int EndOfTheGame(PlayerCell flag)
        {
            Line[] arr1 = LinesCounter.HorLines(this, flag);
            for (int i = 1; i < arr1[0].length; i++)
            {
                if (arr1[i].length >= N)
                {
                    return(1);
                }
            }
            Line[] arr2 = LinesCounter.VerLines(this, flag);
            for (int i = 1; i < arr2[0].length; i++)
            {
                if (arr2[i].length >= N)
                {
                    return(1);
                }
            }
            Line[] arr3 = LinesCounter.DiagLeft(this, flag);
            for (int i = 1; i < arr3[0].length; i++)
            {
                if (arr3[i].length >= N)
                {
                    return(1);
                }
            }
            Line[] arr4 = LinesCounter.DiagRight(this, flag);
            for (int i = 1; i < arr4[0].length; i++)
            {
                if (arr4[i].length >= N)
                {
                    return(1);
                }
            }
            bool c = Overflow(Field);

            if (c)
            {
                return(0);
            }

            return(-1);
        }
예제 #2
0
        private static long heuristicAntagonist(FieldContext gameProcess, PlayerCell first, PlayerCell flag)
        {
            long score = 0;

            Line[] arr = LinesCounter.DiagLeft(gameProcess, flag);
            score += HeuristicLineAntagonist(arr, gameProcess.N, first, flag);

            arr    = LinesCounter.DiagRight(gameProcess, flag);
            score += HeuristicLineAntagonist(arr, gameProcess.N, first, flag);

            arr    = LinesCounter.HorLines(gameProcess, flag);
            score += HeuristicLineAntagonist(arr, gameProcess.N, first, flag);

            arr    = LinesCounter.VerLines(gameProcess, flag);
            score += HeuristicLineAntagonist(arr, gameProcess.N, first, flag);

            if (flag == PlayerCell.Antagonist)//bot
            {
                score = (-1) * score;
            }

            return(score);
        }