public static void Starter()//Generates first and/or additional yards.
 {
     if (yards.Count == 0)
     {
         cash   = 0;
         crypto = 0;
         YardPrestigeList.Add(0);
         //starts the default game and the first turret
         yards.Add(defaultstart);
         Int64[,] currentyard = yards[0];
         currentyard[0, 1]    = turrets[0, 0];
         currentyard[0, 2]    = turrets[0, 1];
         currentyard[0, 3]    = turrets[0, 2];
         yards[0]             = currentyard;
     }
     else
     {
         YardPrestigeList.Add(0);
         //starts all of the yards from this point on when unlocked
         yards.Add(defaultstart);
         Int64[,] currentyard = yards[yards.Count];
         currentyard[0, 1]    = yards.Count * turrets[0, 0];
         currentyard[0, 2]    = yards.Count * turrets[0, 1];
         currentyard[0, 3]    = yards.Count * turrets[0, 2];
         yards[yards.Count]   = currentyard;
     }
 }
    };                                                           //The Prestige of each individual yard.
    public static void LoadSaveTurrets(string SaveDataString)
    {
        bool catchFound = false;

        string[] subOfSaveTurrets = SaveDataString.Split('|');
        for (int i = 0; i > subOfSaveTurrets.Length; i++)
        {
            if (subOfSaveTurrets[i] != " ")
            {
                if (catchFound == false)
                {
                    Int64[,] tempArr = defaultstart;
                    string[] _subset = subOfSaveTurrets[i].Split('=');
                    yards.Add(defaultstart);
                    for (int x = 0; x < _subset.Length; x++)
                    {
                        string[] tempSub = _subset[x].Split('-');
                        for (int y = 0; y < tempSub.Length; y++)
                        {
                            yards[i][x, y] = Convert.ToInt32(tempSub[y]);
                        }
                    }
                }
                else
                {
                    //-----------------------------------------------------------------------FUTURE SAVE DATA-----------------------------------------------------------------------------------------------------
                }
            }
            else
            {
                catchFound = true;
            }
        }
        HandleTurretLoad();
    }
    public static string SaveSenderTurrets()
    {
        //int temp = yards.Count;
        string Save = "";

        for (int i = 0; i < yards.Count; i++)
        {
            Int64[,] tempArr = yards[i];
            for (int j = 0; j < 50; j++)
            {
                Save += Convert.ToString(tempArr[j, 0]);
                Save += "-";
                Save += Convert.ToString(tempArr[j, 1]);
                Save += "-";
                Save += Convert.ToString(tempArr[j, 2]);
                Save += "=";
            }
            Save += "|";
            Debug.Log(("" + Save));
        }
        for (int i = 0; i < YardPrestigeList.Count; i++)
        {
            Save += Convert.ToString(YardPrestigeList[i]);
            if ((i + 1) < YardPrestigeList.Count)
            {
                Save += ",";
            }
        }
        //Save += Convert.ToString(YardPrestigeList);
        return(Save);
    }
Пример #4
0
        public Int64 Evaluate(Int64[,] board)
        {
            const Int64 numberOfRows    = 7;
            const Int64 kingBonusPoints = 3;

            Int64 player1Counter = 0;
            Int64 player2Counter = 0;

            for (int i = 0; i < board.GetLength(0); i++)
            {
                for (int j = 1 - (i % 2); j < board.GetLength(1); j++)
                {
                    Int64 piece = board[i, j];
                    if (piece == 1)
                    {
                        player1Counter += 5 + (numberOfRows - i);
                    }
                    else if (piece == 2)
                    {
                        player2Counter += 5 + i;
                    }
                    else if (piece == 3)
                    {
                        player1Counter += 5 + numberOfRows + kingBonusPoints;
                    }
                    else if (piece == 4)
                    {
                        player2Counter += 5 + numberOfRows + kingBonusPoints;
                    }
                }
            }

            return(player2Counter - player1Counter);
        }
        public Int64 Evaluate(Int64[,] board)
        {
            Int64 player1Counter = 0;
            Int64 player2Counter = 0;

            for (Int64 row = 0; row < board.GetLength(0); row++)
            {
                for (Int64 column = 1 - (row % 2); column < board.GetLength(1); column++)
                {
                    if (board[row, column] == 1)
                    {
                        player1Counter++;
                    }
                    else if (board[row, column] == 2)
                    {
                        player2Counter++;
                    }
                    else if (board[row, column] == 3)
                    {
                        player1Counter += 2;
                    }
                    else if (board[row, column] == 4)
                    {
                        player2Counter += 2;
                    }
                }
            }

            return(player2Counter - player1Counter);
        }
Пример #6
0
        /// <summary>
        /// Rotate the matrix into its final position. The perimeter of progressively smaller bounding rectangles
        /// are each rotated the minimum number of rotations to achive the result (we only need to rotate a given
        /// rectangle up to one full rotation). We stop rotating once we've finished with the inner-most (smallest)
        /// bounding rectangle, whereby one of its dimensions will be of size 2.
        /// </summary>
        /// <param name="rows">The number of rows in the matrix</param>
        /// <param name="cols">The number of columns in the matrix</param>
        /// <param name="rotations">The number of rotations to execute</param>
        /// <param name="matrix">The matrix to rotate</param>
        /// <returns>The rotated matrix</returns>
        public Int64[,] GetRotatedMatrix(Int64 rows, Int64 cols, Int64 rotations, Int64[,] matrix)
        {
            Int64 minX = 0;
            Int64 maxX = cols;
            Int64 minY = 0;
            Int64 maxY = rows;
            Int64 adjustedRotations = rotations;

            while (AtLeastOneDimensionIsGreaterThanOne(minX, maxX, minY, maxY))
            {
                Int64 fullRotation = GetBoundingRectanglePerimeter(minX, maxX, minY, maxY);

                // we only need to bother with up to one full rotation
                if (rotations > fullRotation)
                {
                    adjustedRotations = rotations % fullRotation;
                }

                // rotate the bounding rectangle for each adjusted rotation
                for (Int64 rotationIndex = 0; rotationIndex < adjustedRotations; rotationIndex++)
                {
                    RotateMatrixBoundingRectangle(minX, maxX, minY, maxY, ref matrix);
                }

                // move down a row and across a column
                minX++;
                maxX--;
                minY++;
                maxY--;
            }

            return(matrix);
        }
Пример #7
0
        public Material[] YdnMatTypeMat(Item[] items)
        {
            Material[] typeId = new Material[items.Length - 1];
            for (int i = 0; i < items.Length - 1; ++i)
            {
                typeId[i] = new Material();
            }
            int r = 0;

            foreach (var item in items)
            {
                Int64[,] materials = item.getProdMats();
                for (int i = 0; i < (materials.Length / 2) - 1; ++i)
                {
                    //find valid material
                    if (materials[i, 1] != 0)
                    {
                        //check if the material has already been listed
                        bool found = false;
                        for (int j = 0; j < typeId.Length; ++j)
                        {
                            if (materials[i, 1] == typeId[j].ID)
                            {
                                //item already exists
                                found = true;
                                break;
                            }
                        }

                        //check the material isn't an item
                        foreach (var thing in items)
                        {
                            if (thing.getTypeID() == materials[i, 1])
                            {
                                found = true;
                                break;
                            }
                        }

                        //add item to the material list
                        if (found == false)
                        {
                            typeId[r].ID = Convert.ToInt32(materials[i, 1]);
                            ++r;
                        }
                    }
                }
            }

            //remove null values
            Material[] temp = new Material[r];
            for (int i = 0; i < r; ++i)
            {
                temp[i] = typeId[i];
            }
            typeId = new Material[r];
            typeId = temp;

            return(typeId);
        }
Пример #8
0
 public static Boolean CheckMoveUpLeft(Int64[,] board, Int64 height, Int64 width)
 {
     try
     {
         return(board[height - 1, width - 1] == 5 || board[height - 1, width - 1] == 6);
     }
     catch { return(false); }
 }
Пример #9
0
 public static Boolean CheckMoveDownRight(Int64[,] board, Int64 height, Int64 width)
 {
     try
     {
         return(board[height + 1, width + 1] == 5 || board[height + 1, width + 1] == 6);
     }
     catch { return(false); }
 }
 public static List <Int64> HandLeNewTurret(int yard, int location) //takes the yard that you are building a turret and places a level one
 {
     Int64[,] currentyard     = yards[yard];
     currentyard[location, 0] = 1;
     //add currency drop =
     yards[yard] = currentyard;
     HandleTurretLoad();
     return(TurretStats(yard, location));
 }
Пример #11
0
 /// <summary>
 /// Print the matrix out to the console
 /// </summary>
 /// <param name="rows">The number of rows in the matrix</param>
 /// <param name="cols">The number of columns in the matrix</param>
 /// <param name="matrix">The matrix to print</param>
 public void PrintMatrix(Int64 rows, Int64 cols, Int64[,] matrix)
 {
     for (Int64 rowIndex = 0; rowIndex < rows; rowIndex++)
     {
         for (Int64 colIndex = 0; colIndex < cols; colIndex++)
         {
             Console.Write(matrix[colIndex, rowIndex] + (colIndex == (cols - 1) ? "\n" : " "));
         }
     }
 }
    public static List <Int64> TurretStats(int yard, int location) //call this to assign stats to a turret on turret awake.
    {
        Int64[,] currentyard = yards[yard];
        List <Int64> templist = new List <Int64>();

        templist.Add(currentyard[location, 0]);
        templist.Add(currentyard[location, 1]);
        templist.Add(currentyard[location, 2]);
        templist.Add(currentyard[location, 3]);
        return(templist);
    }
Пример #13
0
 static void PanelPaint(int robot_x, int robot_y, Int64 output, Int64[,] path)
 {
     if (output == 0)
     {
         path[robot_x, robot_y] = 0;
     }
     else if (output == 1)
     {
         path[robot_x, robot_y] = 1;
     }
 }
Пример #14
0
        public MinimaxOutcome minimax(Int64[,] board, Int64 depth, Boolean minOrMax)
        {
            if (depth == 0)
            {
                return(new MinimaxOutcome
                {
                    Evaluation = Evaluate(board)
                });
            }

            if (minOrMax)
            {
                Int64                    maxEval            = -1000;
                PotentialNextMove        bestMove           = null;
                List <PotentialNextMove> player2MovesBoards = GetAvailableBoards(board, 2);
                foreach (PotentialNextMove player2MovesBoard in player2MovesBoards)
                {
                    MinimaxOutcome evaluation = minimax(player2MovesBoard.Board, depth - 1, false);
                    maxEval = Math.Max(maxEval, evaluation.Evaluation);
                    if (maxEval == evaluation.Evaluation)
                    {
                        bestMove = player2MovesBoard;
                    }
                }

                return(new MinimaxOutcome
                {
                    PotentialNextMove = bestMove,
                    Evaluation = maxEval
                });
            }
            else
            {
                Int64                    minEval            = 1000;
                PotentialNextMove        bestMove           = null;
                List <PotentialNextMove> player1MovesBoards = GetAvailableBoards(board, 1);
                foreach (PotentialNextMove player1MovesBoard in player1MovesBoards)
                {
                    MinimaxOutcome evaluation = minimax(player1MovesBoard.Board, depth - 1, true);
                    minEval = Math.Min(minEval, evaluation.Evaluation);
                    if (minEval == evaluation.Evaluation)
                    {
                        bestMove = player1MovesBoard;
                    }
                }

                return(new MinimaxOutcome
                {
                    PotentialNextMove = bestMove,
                    Evaluation = minEval
                });
            }
        }
Пример #15
0
        public void Solve()
        {
            Int64[] dimensions = Console.ReadLine().Split(' ').Select(Int64.Parse).ToArray <Int64>();
            Int64   rows       = dimensions[0];
            Int64   cols       = dimensions[1];
            Int64   rotations  = dimensions[2];

            Int64[,] matrix = GetMatrix(rows, cols);

            matrix = GetRotatedMatrix(rows, cols, rotations, matrix);

            PrintMatrix(rows, cols, matrix);
        }
Пример #16
0
        static Int64 SetDiffs(List <Int64> Taken, List <Int64> Remains, Int64[,] diffs)
        {
            Int64 res = 0;

            foreach (var t in Taken)
            {
                foreach (var r in Remains)
                {
                    res += diffs[t, r];
                }
            }
            return(res);
        }
Пример #17
0
    public static void Main(string[] args)
    {
        //StreamReader sr = new StreamReader(args[0]);
        //StreamWriter sw = new StreamWriter(args[1]);
        StreamReader sr = new StreamReader("input.txt");
        StreamWriter sw = new StreamWriter("output.txt");

        Int64 m_nCase = Convert.ToInt64(sr.ReadLine());

        String[] tmpA;
        String   tmp;

        for (Int64 cs = 1; cs <= m_nCase; cs++)
        {
            tmpA = sr.ReadLine().Split(' ');
            Int64 m_M = Convert.ToInt64(tmpA[0]);
            Int64 m_V = Convert.ToInt64(tmpA[1]);

            m_nNodeR = (m_M - 1) / 2;
            m_nNodeL = (m_M + 1) / 2;

            m_nodeType = new Int64[2, m_M + 1];
            m_memoiz   = new Int64[2, m_M + 1];
            for (Int64 i = 1; i <= m_nNodeR; i++)
            {
                tmpA             = sr.ReadLine().Split(' ');
                m_nodeType[0, i] = Convert.ToInt64(tmpA[0]);
                m_nodeType[1, i] = Convert.ToInt64(tmpA[1]);
                m_memoiz[0, i]   = -2;
                m_memoiz[1, i]   = -2;
            }
            for (Int64 i = m_nNodeR + 1; i <= m_M; i++)
            {
                m_nodeType[0, i] = Convert.ToInt64(sr.ReadLine());
                m_memoiz[0, i]   = -2;
                m_memoiz[1, i]   = -2;
            }

            Int64 ret = FindNum(1, m_V);
            if (ret < 0)
            {
                sw.Write(String.Format("Case #{0:G}: IMPOSSIBLE\n", cs));
            }
            else
            {
                sw.Write(String.Format("Case #{0:G}: {1:G}\n", cs, ret));
            }
        }
        sr.Close();
        sw.Close();
    }
        public List <PotentialNextMove> GetAvailableBoards(Int64[,] board, Int64 player)
        {
            List <PotentialNextMove> results = new List <PotentialNextMove>();

            List <NextMove> moves = FindMove.FindAvailableMoves(board, player);

            foreach (NextMove move in moves)
            {
                //Copy board
                Int64[,] moveBoard = (Int64[, ])board.Clone();

                //Remove taken pieces form the board
                if (move.Takes.Count > 0)
                {
                    foreach (Piece take in move.Takes)
                    {
                        moveBoard[take.Height, take.Width] = 5;
                    }
                }

                //Add kings
                if (player == 1 && move.NextHeight == 0)
                {
                    moveBoard[move.CurrentHeight, move.CurrentWidth] = 5;
                    moveBoard[move.NextHeight, move.NextWidth]       = 3;
                }
                else if (player == 2 && move.NextHeight == 7)
                {
                    moveBoard[move.CurrentHeight, move.CurrentWidth] = 5;
                    moveBoard[move.NextHeight, move.NextWidth]       = 4;
                }
                else
                {
                    Int64 tempValue = moveBoard[move.CurrentHeight, move.CurrentWidth];
                    moveBoard[move.CurrentHeight, move.CurrentWidth] = 5;
                    moveBoard[move.NextHeight, move.NextWidth]       = tempValue;
                }

                results.Add(new PotentialNextMove
                {
                    Board         = moveBoard,
                    CurrentHeight = move.CurrentHeight,
                    CurrentWidth  = move.CurrentWidth,
                    NextHeight    = move.NextHeight,
                    NextWidth     = move.NextWidth,
                    Takes         = move.Takes
                });
            }

            return(results);
        }
Пример #19
0
        public void WriteExtended(string key, Int64[,] array2D)
        {
            if (writer == null)
            {
                throw new FileEE("無効なストリームです");
            }
            if (array2D == null)
            {
                throw new FileEE("無効な配列が渡されました");
            }
            int countX  = 0;
            int length0 = array2D.GetLength(0);
            int length1 = array2D.GetLength(1);

            int[] countY = new int[length0];
            for (int x = 0; x < length0; x++)
            {
                for (int y = 0; y < length1; y++)
                {
                    if (array2D[x, y] != 0)
                    {
                        countX    = x + 1;
                        countY[x] = y + 1;
                    }
                }
            }
            if (countX == 0)
            {
                return;
            }
            writer.WriteLine(key);
            for (int x = 0; x < countX; x++)
            {
                if (countY[x] == 0)
                {
                    writer.WriteLine("");
                    continue;
                }
                StringBuilder builder = new StringBuilder("");
                for (int y = 0; y < countY[x]; y++)
                {
                    builder.Append(array2D[x, y].ToString());
                    if (y != countY[x] - 1)
                    {
                        builder.Append(",");
                    }
                }
                writer.WriteLine(builder.ToString());
            }
            writer.WriteLine(FINISHER);
        }
Пример #20
0
        public void setValueAll2D(int varInt, Int64 value)
        {
            Int64[,] array = dataIntegerArray2D[varInt];
            int a1 = array.GetLength(0);
            int a2 = array.GetLength(1);

            for (int i = 0; i < a1; i++)
            {
                for (int j = 0; j < a2; j++)
                {
                    array[i, j] = value;
                }
            }
        }
    public static void HandleLevelUP(int yard, int location)//levelup a turret
    {
        Int64[,] currentyard = yards[yard];
        Int64 level = currentyard[location, 0];
        Int64 CTU   = currentyard[location, 3];

        //add currency drop -=CTU
        level += 1;
        currentyard[location, 0] = level;
        currentyard[location, 1] = turrets[level, 0];
        currentyard[location, 2] = turrets[level, 1];
        currentyard[location, 3] = turrets[level, 2];
        yards[yard] = currentyard;
    }
Пример #22
0
        public void setProdMats(int[,] mats)
        {
            prodMats = new Int64[mats.Length / 2, 2];

            //move values from one array to another
            for (int i = 0; i < (mats.Length / 2); ++i)
            {
                if (mats[i, 1] != 0)
                {
                    prodMats[i, 0] = mats[i, 0];
                    prodMats[i, 1] = mats[i, 1];
                }
            }
        }
Пример #23
0
 static int GetRobotInput(int robot_x, int robot_y, Int64[,] path)
 {
     if (path[robot_x, robot_y] == 2 || path[robot_x, robot_y] == 0)
     {
         return(0);
     }
     if (path[robot_x, robot_y] == 1)
     {
         return(1);
     }
     else
     {
         return(666);
     }
 }
Пример #24
0
        public void CanConstructTensorVariableView()
        {
            Device device = new Device(testContext);

            Compiler.PlaidML.Shape   s1 = new Compiler.PlaidML.Shape(testContext, PlaidmlDatatype.PLAIDML_DATA_FLOAT64, 2, 3);
            DeviceTensor             t  = new DeviceTensor(device, s1, "t");
            DeviceTensorView <Int64> v  = t.CreateView <Int64>(MemoryMapType.Discard);

            Int64[,] array = { { 0, 1, 3 }, { 4, 5, 6 } };
            v.CopyFromAndFree(array.Flatten <Int64>().ToArray());
            Assert.Throws <InvalidOperationException>(() => v.Free());
            DeviceTensorView <Int64> v2 = t.CreateView <long>(MemoryMapType.Retain);

            Assert.Equal(3, v2[2]);
            Assert.Equal(6, v2[5]);
        }
Пример #25
0
        private void writeData(Int64[,] array)
        {
            int countZero    = 0;         //0については0が連続する数を記憶する。その他はそのまま記憶する。
            int countAllZero = 0;         //列の要素が全て0である列の連続する数を記憶する。列の要素に一つでも非0があるなら通常の記憶方式。
            int length0      = array.GetLength(0);
            int length1      = array.GetLength(1);

            writer.Write(length0);
            writer.Write(length1);

            for (int x = 0; x < length0; x++)
            {
                for (int y = 0; y < length1; y++)
                {
                    if (array[x, y] == 0)
                    {
                        countZero++;
                    }
                    else
                    {
                        if (countAllZero > 0)
                        {
                            writer.Write(Ebdb.ZeroA1);
                            this.m_WriteInt(countAllZero);
                            countAllZero = 0;
                        }
                        if (countZero > 0)
                        {
                            writer.Write(Ebdb.Zero);
                            this.m_WriteInt(countZero);
                            countZero = 0;
                        }
                        this.m_WriteInt(array[x, y]);
                    }
                }
                if (countZero == length1)                //列の要素が全部0
                {
                    countAllZero++;
                }
                else
                {
                    writer.Write(Ebdb.EoA1);                    //非0があるなら列終端記号を記憶
                }
                countZero = 0;
            }
            writer.Write(Ebdb.EoD);
        }
Пример #26
0
        private static void CalculateGS(byte[,] src, int [,] G, Int64[,] S, int w, int h, ProgressBar p1)
        {
            MainForm.UpdateLabel("Calculating integral images");
            G[0, 0] = src[0, 0];
            S[0, 0] = src[0, 0] * src[0, 0];
            byte pvalue = 0;

            p1.Value   = 0;
            p1.Minimum = 0;
            p1.Maximum = w / 10;
            for (int i = 0; i < w; i++)//i-the number of COLUMN,i.e X
            {
                for (int j = 0; j < h; j++)
                {
                    if (i == 0)
                    {
                        if (j == 0)
                        {
                            continue;
                        }
                        G[i, j] = G[i, j - 1] + src[i, j];
                        S[i, j] = S[i, j - 1] + (int)src[i, j] * src[i, j];
                    }
                    else if (j == 0)
                    {
                        if (i == 0)
                        {
                            continue;
                        }
                        G[i, j] = G[i - 1, j] + src[i, j];
                        S[i, j] = S[i - 1, j] + (int)src[i, j] * src[i, j];
                    }
                    else
                    {
                        G[i, j] = G[i - 1, j] + G[i, j - 1] - G[i - 1, j - 1] + src[i, j];
                        S[i, j] = S[i - 1, j] + S[i, j - 1] - S[i - 1, j - 1] + (int)src[i, j] * src[i, j];
                    }
                }
                pvalue++;
                if (pvalue == 10)
                {
                    pvalue = 0;
                    p1.Value++;
                }
            }
        }
Пример #27
0
        private static void InitialiseZobristValues()
        {
            // Generate some random values
            Random random = new Random();

            zobristRandomPositionValues = new Int64[FIELD_SIZE * FIELD_SIZE, 6];
            for (int i = 0; i < zobristRandomPositionValues.GetLength(0); i++)
            {
                for (int j = 0; j < zobristRandomPositionValues.GetLength(1); j++)
                {
                    zobristRandomPositionValues[i, j] = GenerateRandomLong(random);
                }
            }

            zobristRandomPlayerValues = new Int64[2];
            zobristRandomPlayerValues[(int)Game.Player.White] = GenerateRandomLong(random);
            zobristRandomPlayerValues[(int)Game.Player.Red]   = GenerateRandomLong(random);
        }
        public override void Run()
        {
            Int64[,] enrolled = { { 1091150, 18, 20 },
                                  { 1091250, 11, 20 },
                                  { 1091270,  9, 25 },
                                  { 1091300,  4, 20 },
                                  { 1091350, 20, 20 } };

            for (int i = 0; i <= enrolled.GetUpperBound(0); i++)
            {
                Console.ForegroundColor = ConsoleColor.DarkYellow;
                Console.WriteLine("Course " + enrolled[i, 0]);
                Console.ResetColor();
                Console.WriteLine("Seats available = {0}\n" +
                                  "---------------------",
                                  enrolled[i, 2] - enrolled[i, 1]);
            }
        }
Пример #29
0
 static void PrintRegistration(Int64[,] path)
 {
     for (int i = 20; i < path.GetLength(0) - 10; i++)
     {
         for (int j = 10; j < path.GetLength(1); j++)
         {
             if (path[i, j] == 1)
             {
                 Console.Write("{0}", path[i, j]);
             }
             else
             {
                 Console.Write(" ");
             }
         }
         Console.WriteLine();
     }
 }
Пример #30
0
        public static Tree CheckTakeUp(Int64[,] board, Int64 i, Int64 j, Int64[] playerToTake, Tree tree)
        {
            try
            {
                //left
                if (Array.IndexOf(playerToTake, board[i - 1, j - 1]) > -1)
                {
                    if (board[i - 2, j - 2] == 5 || board[i - 2, j - 2] == 6)
                    {
                        tree.Left = new Tree(new TreeTake
                        {
                            TakeHeight    = i - 1,
                            TakeWidth     = j - 1,
                            CurrentHeight = i - 2,
                            CurrentWidth  = j - 2
                        });
                        CheckTakeUp(board, i - 2, j - 2, playerToTake, tree.Left);
                    }
                }
            }
            catch { }

            try
            {
                //Right
                if (Array.IndexOf(playerToTake, board[i - 1, j + 1]) > -1)
                {
                    if (board[i - 2, j + 2] == 5 || board[i - 2, j + 2] == 6)
                    {
                        tree.Right = new Tree(new TreeTake
                        {
                            TakeHeight    = i - 1,
                            TakeWidth     = j + 1,
                            CurrentHeight = i - 2,
                            CurrentWidth  = j + 2
                        });
                        CheckTakeUp(board, i - 2, j + 2, playerToTake, tree.Right);
                    }
                }
            }
            catch { }

            return(tree);
        }
Пример #31
0
        // Расшифровка
        //-----------------------------------------------------------------------------------------------------------------------------------
        //-----------------------------------------------------------------------------------------------------------------------------------
        public static ZArrayDescriptor pi2_rshfr(ZArrayDescriptor[] img, int sN1, int sN2, int Diag,  int pr_obr, int sdvg_x)
        {
            int w = img[0].width;
            int h = img[0].height;

            int NOD=China(sN1, sN2);                                     // Проверка на взаимную простоту
                                                                         // Вычисление формулы sN1, sN2 -> в глобальные n1, n2
               // int[,] bmp_r = new int[sN2 + 3, sN1 + 3];                  // Массив точек в таблице 2pi
               // bmp_2pi(img, bmp_r, Diag, pr_obr, sdvg_x);                 // Заполнение массива bmp_r

            Z = new Int64[w, h];

            GLBL_FAZE(n1, n2, Diag);                                     // Заполнение массива glbl_faze[] (Все -1 кроме номеров полос)
                                                                         // glbl_faze1[] расширяется значениям номеров полос
                                                                         //  РАСШИФРОВКА (Заполнение Z[,])
            rash_2pi(img[1], img[0], img[2], NOD, sdvg_x, n1, n2, Diag, Z);

            ZArrayDescriptor result = new ZArrayDescriptor();
            result.array = new long[w][];

            for (int i = 0; i < w; i++)
            {
                result.array[i] = new long[h];
            }

            result.width = w;
            result.height = h;
            for (int i = 0; i < w; i++)                                                                   //  Отображение точек на pictureBox01
            {
                for (int j = 0; j < h; j++)
                {
                    result.array[i][j] = Z[i, j];
                }
            }
            //Z_bmp(result, Z);                                           //  Z -> bmp с масштабированием (bmp3 - маска)

              return result;
        }
Пример #32
0
 public Int2DVariableToken(VariableCode varCode, VariableData varData)
     : base(varCode, varData)
 {
     CanRestructure = false;
     array = varData.DataIntegerArray2D[VarCodeInt];
 }
Пример #33
0
 public override void In()
 {
     if (array != null)
         arrayList.Add(array);
     //counter++;
     array = new Int64[sizes[0], sizes[1]];
 }
Пример #34
0
 public override void Out()
 {
     //counter--;
     //arrayList.RemoveAt(arrayList.Count - 1);
     if (arrayList.Count > 0)
     {
         array = arrayList[arrayList.Count - 1];
         arrayList.RemoveAt(arrayList.Count - 1);
     }
     else
         array = null;
 }
Пример #35
0
 public StaticInt2DVariableToken(UserDefinedVariableData data)
     : base(VariableCode.VAR2D, data)
 {
     CanRestructure = false;
     int[] sizes = data.Lengths;
     IsStatic = true;
     array = new Int64[sizes[0], sizes[1]];
 }
Пример #36
0
        // Расшифровка
        // --------------------------------------------------------------------------------------------------------------------------------
        // --------------------------------------------------------------------------------------------------------------------------------
        // --------------------------------------------------------------------------------------------------------------------------------
        // --------------------------------------------------------------------------------------------------------------------------------
        // --------------------------------------------------------------------------------------------------------------------------------
        // --------------------------------------------------------------------------------------------------------------------------------
        //-----------------------------------------------------------------------------------------------------------------------------------
        //-----------------------------------------------------------------------------------------------------------------------------------
        public static Bitmap pi2_rshfr(Image[] img, int sN1, int sN2, int Diag, bool rd, bool SUB_rd, int pr_obr, int sdvg_x)
        {
            China(sN1, sN2);                                            // Вычисление формулы sN1, sN2 -> в глобальные n1, n2

            int[,] bmp_r = new int[sN2 + 3, sN1 + 3];                   // Массив точек в таблице 2pi
            int count = bmp_2pi(img, bmp_r, Diag, pr_obr, sdvg_x);      // Заполнение массива bmp_r

            int w = img[0].Width;
            int h = img[0].Height;
            Bitmap bmp1 = new Bitmap(img[1], w, h);                     // 1 фаза
            Bitmap bmp2 = new Bitmap(img[0], w, h);                     // 2 фаза
            Bitmap bmp3 = new Bitmap(img[2], w, h);                     // Маска
            Bitmap bmp  = new Bitmap( w, h);                            // Результат

            Z = new Int64[w, h];

            GLBL_FAZE(n1, n2, Diag);                                       // Заполнение массива glbl_faze[] (Все -1 кроме номеров полос)
                                                                           // для расшифровки glbl_faze1[] расширяется значениям номеров полос на допустимый диапазон
            rash_2pi(bmp1, bmp2, bmp3, bmp_r, pr_obr, sdvg_x, sN1, sN2, Diag, Z);  //  РАСШИФРОВКА (Заполнение Z[,])
            int x1 = 24, x2 = 460, y1 = 50;

            //GraphClass1.grfk(w, h, x, y, Z);
            Int64[] sub_line = new Int64[w];
            if (SUB_rd) { Z_sub(x1, x2, y1, Z, w, h, sub_line); }   //

            //Z_sub1(x1, x2, y1, Z, w, h, bmp3, rd);                          // Вычитание плоскости
            //GraphClass1.grfk(w, x, y, Z);
            int x = 1075, y = 600;
            Int64[] buf  = new Int64[w];  for (int i = 0; i < w; i++) { buf[i] = Z[i, y];  }  Graphic graphic = new Graphic(w, x, buf);   graphic.Show();   // График по x
            Int64[] buf1 = new Int64[h];  for (int i = 0; i < h; i++) { buf1[i] = Z[x, i]; }  Graphic graphic1 = new Graphic(h, y, buf1); graphic1.Show();  // График по y

            Z_bmp(bmp, bmp3, Z);                                           //  Z -> bmp с масштабированием (bmp3 - маска)

            return bmp;
        }