예제 #1
0
        private int[,] AfterData(TheCase theCase, int index)
        {
            var theData         = (int[, ])data.Clone();
            var chooseDirection = (CubeDirection)theCase.chooseDirection;
            var moveDirection   = (CubeDirection)theCase.moveDirection;

            for (int j = 0; j < theCase.howManyWillPush; j++)
            {
                var i = theCase.howManyWillPush - j - 1;

                CubeCoord chosenPosition = new CubeCoord(0, 0, 0);
                if (chooseDirection.ToCoord() == moveDirection.ToCoord())
                {
                    chosenPosition = theCase.target + (AxialCoord)chooseDirection.ToCoord() * (theCase.howManyIsChosen + i);
                }
                if (chooseDirection.ToCoord() == moveDirection.ToCoord() * (-1))
                {
                    chosenPosition = theCase.target - (AxialCoord)chooseDirection.ToCoord() + (AxialCoord)moveDirection.ToCoord() * i;
                }

                //var chosenPosition = theCase.target + (AxialCoord)chooseDirection.ToCoord() * (theCase.howManyIsChosen + i);

                var beforePosition = (AxialCoord)chosenPosition;
                var afterPosition  = beforePosition + (AxialCoord)moveDirection.ToCoord();
                theData[beforePosition.x, beforePosition.z] = 0;

                if (!IsInArea(afterPosition.x, afterPosition.z))
                {
                    continue;
                }

                theData[afterPosition.x, afterPosition.z] = 3 - index;
            }
            for (int j = 0; j < theCase.howManyIsChosen; j++)
            {
                int i;
                if (chooseDirection.ToCoord() == moveDirection.ToCoord())
                {
                    i = theCase.howManyIsChosen - j - 1;
                }
                else
                {
                    i = j;
                }

                var beforePosition = theCase.target + (AxialCoord)chooseDirection.ToCoord() * i;
                var afterPosition  = beforePosition + (AxialCoord)moveDirection.ToCoord();
                theData[beforePosition.x, beforePosition.z] = 0;
                theData[afterPosition.x, afterPosition.z]   = index;
            }
            return(theData);
        }
예제 #2
0
        private TheCase[] PossibleThingsGet(int[,] data, int index)
        {
            var possibles = new TheCase[max];

            pushOutables      = 0;
            howMuchIsPossible = 0;

            for (int i = 0; i < board.settings.arraySize; i++)
            {
                for (int j = 0; j < board.settings.arraySize; j++)
                {
                    if (data[i, j] != index)
                    {
                        continue;
                    }

                    for (int m = 1; m <= 3; m++)
                    {
                        for (int k = 0; k < 3; k++)
                        {
                            var chooseCoord = ((CubeDirection)k).ToCoord();
                            if (!CanChoose(data, new AxialCoord(i, j), chooseCoord, m, index))
                            {
                                continue;
                            }
                            if (m == 1)
                            {
                                k = 2;
                            }

                            for (int l = 0; l < 6; l++)
                            {
                                var moveCoord = ((CubeDirection)l).ToCoord();

                                if (CanPushMarble(data, new AxialCoord(i, j), chooseCoord, moveCoord, m, index))
                                {
                                    possibles[howMuchIsPossible] = new TheCase(new AxialCoord(i, j), k, l, m, howManyWillPush, Priority.nothing, opponentPush, pushOut);
                                    if (pushOut)
                                    {
                                        pushOutables++;
                                    }
                                    howMuchIsPossible++;
                                }
                            }
                        }
                    }
                }
            }

            return(possibles);
        }
예제 #3
0
        private TheCase[] GetSuperiors()
        {
            var aiPossibles = howMuchIsPossible;

            var R             = new int[aiPossibles];
            var A             = new bool[aiPossibles];
            var D             = new int[aiPossibles];
            var superiorCases = new TheCase[aiPossibles];

            var rMin = 136;
            var dMin = 24;
            var rank = (Priority)8;
            var j    = 0;

            for (int i = 0; i < aiPossibles; i++)
            {
                var afterData         = AfterData(possibles[i], aiIndex);
                var opponentPossibles = PossibleThingsGet(afterData, 3 - aiIndex);

                if (possibles[i].target == new AxialCoord(2, 8))
                {
                    for (var k = 0; k < howMuchIsPossible; k++)
                    {
                        Debug.Log(opponentPossibles[k] + " ");
                    }
                }

                if (howMuchIsPossible <= rMin)
                {
                    if (howMuchIsPossible < rMin)
                    {
                        R = new int[aiPossibles];
                    }
                    rMin = howMuchIsPossible;
                    R[i] = rMin;
                }

                if (possibles[i].pushOut)
                {
                    A[i] = true;
                }

                if (pushOutables <= dMin)
                {
                    if (pushOutables < dMin)
                    {
                        D = new int[aiPossibles];
                    }
                    dMin = pushOutables;
                    D[i] = dMin;
                }
            }

            for (int i = 0; i < aiPossibles; i++)
            {
                var r = R[i] > 0;
                var a = A[i];
                var d = D[i] > 0;

                if (r && a && d)
                {
                    possibles[i].priority = Priority.Trinity;
                }
                if (!r && a && d)
                {
                    possibles[i].priority = Priority.attackAndDefense;
                }
                if (r && !a && d)
                {
                    possibles[i].priority = Priority.defenseAndReduce;
                }
                if (!r && !a && d)
                {
                    possibles[i].priority = Priority.defense;
                }
                if (r && a && !d)
                {
                    possibles[i].priority = Priority.attackAndReduce;
                }
                if (!r && a && !d)
                {
                    possibles[i].priority = Priority.attack;
                }
                if (r && !a && !d)
                {
                    possibles[i].priority = Priority.opponentPossibleReduce;
                }
                if (!r && !a && !d)
                {
                    possibles[i].priority = Priority.nothing;
                }

                if (rank > possibles[i].priority)
                {
                    rank          = possibles[i].priority;
                    superiorCases = new TheCase[aiPossibles];
                    j             = 0;
                }

                if (rank == possibles[i].priority)
                {
                    superiorCases[j] = possibles[i];
                    j++;
                }
            }

            superior = j;
            return(superiorCases);
        }