示例#1
0
 public NyARCode(int i_width, int i_height)
 {
     width  = i_width;
     height = i_height;
     pat    = new int[4, height, width, 3]; // static int pat[AR_PATT_NUM_MAX][4][AR_PATT_SIZE_Y*AR_PATT_SIZE_X*3];
     patBW  = new short[4, height, width];  // static int patBW[AR_PATT_NUM_MAX][4][AR_PATT_SIZE_Y*AR_PATT_SIZE_X*3];
 }
示例#2
0
 public Player(int InID, string InName, int[,,,] InSkill, int[][][] InAchievement)
 {
     ID          = InID;
     Name        = InName;
     Skill       = InSkill;
     Achievement = InAchievement;
 }
示例#3
0
        public override void write(Object obj1, BOutput bout1, long version)
        {
            BOutputBin bout = (BOutputBin)bout1;
            BBufferBin bbuf = bout.bbuf;

            int[,,,] arr = (int[, , , ])obj1;

            // lengths
            int n3 = arr.GetLength(0);
            int n2 = arr.GetLength(1);
            int n1 = arr.GetLength(2);
            int n0 = arr.GetLength(3);

            bbuf.putLength(n3);
            bbuf.putLength(n2);
            bbuf.putLength(n1);
            bbuf.putLength(n0);

            // write
            for (int i3 = 0; i3 < n3; i3++)
            {
                for (int i2 = 0; i2 < n2; i2++)
                {
                    for (int i1 = 0; i1 < n1; i1++)
                    {
                        for (int i0 = 0; i0 < n0; i0++)
                        {
                            bbuf.putInt(arr[i3, i2, i1, i0]);
                        }
                    }
                }
            }
        }
示例#4
0
        private static void PlayRandomMove(int[, , ,] Cells, int Bc, int Br, out int Cc, out int Cr)
        {
            List <int> CellCol = new List <int>();
            List <int> CellRow = new List <int>();

            for (int ci = 0; ci < 3; ci++)
            {
                for (int cj = 0; cj < 3; cj++)
                {
                    if (Cells[Bc, Br, ci, cj] == 0)
                    {
                        CellCol.Add(ci);
                        CellRow.Add(cj);
                    }
                }
            }

            if (CellCol.Count == 0)
            {
                Cc = -1;
                Cr = -1;
                return;
            }

            Random rnd   = new Random();
            int    index = rnd.Next(0, CellCol.Count);

            Cc = CellCol[index];
            Cr = CellRow[index];
        }
    //Players
    //0 = Null
    //1 = 1
    //2 = 2
    //Duh!..

    //Blocks
    //0 = Nothing
    //1 = Ship part
    //2 = Destroyed ship part
    //3 = Splash

    // Use this for initialization

    /*void GetStats () {
     *      GameObject statsCarrier = GameObject.Find ("StatsCarrier");
     *      if (statsCarrier) {
     *              stats = statsCarrier.GetComponent<StatsCarrier>();
     *              aiAmount = stats.aiAmount;
     *              shipAmount = stats.shipAmount;
     *              size = stats.size;
     *      }
     * }*/
    void Start()
    {
        //GetStats ();
        if (aiAmount == 1)
        {
            ai          = (NormalAI)gameObject.AddComponent("NormalAI");
            ai.aiPlayer = 2;
        }
        if (aiAmount == 2)
        {
            NormalAI ai = (NormalAI)gameObject.AddComponent("NormalAI");
            ai.aiPlayer = 2;
            ai          = (NormalAI)gameObject.AddComponent("NormalAI");
            ai.aiPlayer = 1;
        }

        center               = size / 2;
        activePlayer         = 1;
        shipIndex            = new int[2];
        battlefieldGenerated = new bool[2];
        shipsLeft            = new int[2];
        coordinates          = new int[3, (int)size.x, (int)size.y, (int)size.z];
        blocksPos            = new Vector3[3, Mathf.RoundToInt(size.x * size.y * size.z)];
        blocks               = new GameObject[3, blocksPos.Length];
        shipBlocks           = new GameObject[3, blocksPos.Length];
        battlefieldGenerated[activePlayer - 1] = true;
        bcol = GetComponent <BoxCollider>();
        GenerateBattlefield(activePlayer);
        shipIndex[0] = shipAmount;
        shipIndex[1] = shipAmount;

        Camera.main.transform.position = center + new Vector3(0, 0, -size.z * 2);
    }
示例#6
0
        private static void FindAvailableBoards(int[, , ,] Cells, int player, List <int> availableBc, List <int> availableBr)
        {
            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    bool isAv = false;
                    for (int ci = 0; ci < 3; ci++)
                    {
                        for (int cj = 0; cj < 3; cj++)
                        {
                            if (Cells[i, j, ci, cj] == 0)
                            {
                                isAv = true;
                                break;
                            }
                        }
                        if (isAv)
                        {
                            break;
                        }
                    }

                    if (isAv)
                    {
                        availableBc.Add(i);
                        availableBr.Add(j);
                    }
                }
            }
        }
示例#7
0
        static void Main(string[] args)
        {
            int[,,,] array =
            {
                {
                    { { 0x0, 0x1 }, { 0x2, 0x3 } },
                    { { 0x4, 0x5 }, { 0x6, 0x7 } }
                },
                {
                    { { 0x8, 0x9 }, { 0xA, 0xB } },
                    { { 0xC, 0xD }, { 0xE, 0xF } }
                },
            };
            for (int i = 0; i < 2; i++)
            {
                for (int j = 0; j < 2; j++)
                {
                    for (int k = 0; k < 2; k++)
                    {
                        for (int z = 0; z < 2; z++)
                        {
                            Console.Write(array[i, j, k, z]);
                        }
                        Console.Write("\n");
                    }
                    Console.Write("\n");
                }
                Console.Write("\n");
            }

            //Delay
            Console.ReadLine();
        }
示例#8
0
        public virtual void SetInt(int[,,,] v, BAsyncResult <Object> asyncResult)
        {
            BRequest_RemoteArrayTypes4dim_setInt req = new BRequest_RemoteArrayTypes4dim_setInt();

            req.vValue = v;
            transport.sendMethod(req, asyncResult);
        }
 public void Awake()
 {
     zobrist = new Zobrist();
     zobrist.FillZobristArray();
     historyMoves = new int[8, 8, 8, 8];
     killerMoves  = new Vector2Int[maxDepth + 1, 2][];
 }
示例#10
0
 private static void EnterMatrixEntries(int[,,,] array)
 {
     Console.WriteLine("Now start entering values for the matrix one row after the other");
     for (var i = 0; i < array.GetLength(0); i++)
     {
         for (var j = 0; j < array.GetLength(1); j++)
         {
             for (var k = 0; k < array.GetLength(2); k++)
             {
                 for (var l = 0; l < array.GetLength(3); l++)
                 {
                     try
                     {
                         var input = int.Parse(Console.ReadLine());
                         array[i, j, k, l] = input;
                     }
                     catch (Exception) // once user tries anything fishy, i generate random values
                     {
                         Console.WriteLine("You wanted to crash the program but you failed. I will generate random values");
                         RandomNumberGen(Matrix4D);
                         Console.WriteLine("Now enter the next number for the matrix");
                     }
                 }
                 if (i < array.GetLength(0))
                 {
                     Console.WriteLine("Now the next row");                         // only print when all rows have not been filled
                 }
             }
         }
         Console.WriteLine();
     }
 }
示例#11
0
        static void Main(string[] args)
        {
            int[,] arr1 = new int[2, 3] {
                { 1, 2, 3 }, { 4, 5, 6 }
            };
            int[,] arr2 = new int[, ] {
                { 1, 2, 3 }, { 4, 5, 6 }
            };
            int[,] arr3 = { { 1, 2, 3 }, { 4, 5, 6 } };

            int[,,] arr4 =
            {
                { {  1,  2,  3 }, {  4,  5,  6 } },
                { {  7,  8,  9 }, { 10, 11, 12 } },
                { { 13, 14, 15 }, { 16, 17, 18 } }
            };

            int[,,,] arr5 =
            {
                {
                    { {  1,  2,  3 }, {  4,  5,  6 } },
                    { {  7,  8,  9 }, { 10, 11, 12 } },
                    { { 13, 14, 15 }, { 16, 17, 18 } }
                },
                {
                    { {  1,  2,  3 }, {  4,  5,  6 } },
                    { {  7,  8,  9 }, { 10, 11, 12 } },
                    { { 13, 14, 15 }, { 16, 17, 18 } }
                }
            };
        }
示例#12
0
        private static String buildLCS(int[,,,] b, char[] X, int[] ind)
        {
            for (int i = 0; i < RANK; i++)
            {
                if (ind[i] == 0)
                {
                    return("");
                }
            }

            int L = (int)b.GetValue(ind);

            if (L == RANK)
            {
                for (int i = 0; i < RANK; i++)
                {
                    ind[i]--;
                }
                int idx = ind[0];
                return(buildLCS(b, X, ind) + X[idx]);
            }
            if (L >= 0 && L < RANK)
            {
                ind[L]--;
                return(buildLCS(b, X, ind));
            }
            throw new Exception();
        }
示例#13
0
        /// <summary>
        /// Converts a 4 dimensional dataSet to a 3 dimensional dataSet
        /// </summary>
        /// <param name="dataSet">The dataSet to fold</param>
        /// <returns></returns>
        public int[, ,] ConvertTo3D(int[, , ,] dataSet)
        {
            //A 3d matrix of only days and hours and minutes
            int[, ,] dMatrix = new int[7, 24, 60];
            int MinuteTotal = 0;

            for (int Day = 0, dayEnd = dataSet.GetUpperBound(0) + 1, dayInMonth = DateUtility.DaysInMonth(monthInReview, yearInReview); (Day < dayEnd && Day < dayInMonth); Day++)
            {
                for (int Hour = 0, hourEnd = dataSet.GetUpperBound(1) + 1; Hour < hourEnd; Hour++)
                {
                    for (int Minute = 0, minuteEnd = dataSet.GetUpperBound(2) + 1; Minute < minuteEnd; Minute++)
                    {
                        MinuteTotal = 0;
                        for (int Second = 0, secondEnd = dataSet.GetUpperBound(3) + 1; Second < secondEnd; Second++)
                        {
                            MinuteTotal += dataSet[Day, Hour, Minute, Second];
                        }
                        DateTime checker = new DateTime(yearInReview, monthInReview, Day + 1, Hour, Minute, 0);
                        MinuteTotal /= 60; //seconds in a minute
                        dMatrix[(int)checker.DayOfWeek, Hour, Minute] = MinuteTotal;
                    }//Minutes
                } //Hours
            }     //Days
            return(dMatrix);
        }
示例#14
0
        private static int[,,,] Iterate(int[,,,] grid)
        {
            var expandedGrid = Expand(grid);

            var newGrid = new int[
                grid.GetLength(0) + 2,
                grid.GetLength(1) + 2,
                grid.GetLength(2) + 2,
                grid.GetLength(3) + 2
                          ];

            ForEach(newGrid, (i, j, k, l, v) =>
            {
                var numActiveNeighbours = CountActiveNeighbours(expandedGrid, i, j, k, l);
                if (expandedGrid[i, j, k, l] == 0 && numActiveNeighbours == 3)
                {
                    newGrid[i, j, k, l] = 1;
                }
                if (expandedGrid[i, j, k, l] == 1 && (numActiveNeighbours == 2 || numActiveNeighbours == 3))
                {
                    newGrid[i, j, k, l] = 1;
                }
            });

            return(newGrid);
        }
示例#15
0
文件: 0.cs 项目: qifanyyy/CLCDSA
    public void Solve()
    {
        int nt = ReadInt();

        for (int tt = 1; tt <= nt; tt++)
        {
            int n = ReadInt();
            m = ReadInt();

            var a = new int[4];
            for (; n > 0; n--)
            {
                a[ReadInt() % m]++;
            }

            mem = new int[a[0] + 1, a[1] + 1, a[2] + 1, a[3] + 1];
            for (int i = 0; i <= a[0]; i++)
            {
                for (int j = 0; j <= a[1]; j++)
                {
                    for (int k = 0; k <= a[2]; k++)
                    {
                        for (int l = 0; l <= a[3]; l++)
                        {
                            mem[i, j, k, l] = -1;
                        }
                    }
                }
            }

            Console.WriteLine(tt);
            writer.WriteLine("Case #{0}: {1}", tt, Fun(a, 0));
        }
    }
示例#16
0
        static void Main(string[] args)
        {
            var K = int.Parse(Console.ReadLine());

            S = Console.ReadLine();
            var L = S.Length;

            DP       = new int[L, L, L + 1, 2];
            Complete = new bool[L, L, L + 1, 2];
            for (int i = 0; i < L; i++)
            {
                for (int j = 0; j < L; j++)
                {
                    for (int k = 0; k < L; k++)
                    {
                        for (int l = 0; l < 2; l++)
                        {
                            DP[i, j, k, l]       = l == 1 ? int.MinValue : int.MaxValue;
                            Complete[i, j, k, l] = false;
                        }
                    }
                }
            }
            Console.WriteLine(rec(0, L - 1, K, 1) != int.MinValue ? $"OK\n{DP[0, L - 1, K, 1]}" : "NG");
        }
示例#17
0
 private static void Show4DMatrix(int[,,,] array)
 {
     try
     {
         for (var i = 0; i < array.GetLength(0); i++)
         {
             Console.WriteLine(" [");
             for (var j = 0; j < array.GetLength(1); j++)
             {
                 for (var k = 0; k < array.GetLength(2); k++)
                 {
                     for (var l = 0; l < array.GetLength(3); l++)
                     {
                         Console.Write($"   { array[i, j, k, l] }");
                     }
                     Console.WriteLine();
                 }
             }
             Console.WriteLine(" ]\n");
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
示例#18
0
        static void Main()
        {
            int[,,,] array =
            {
                {
                    { { 0x0, 0x1 }, { 0x2, 0x3 } },
                    { { 0x4, 0x5 }, { 0x6, 0x7 } }
                },
                {
                    { { 0x8, 0x9 }, { 0xA, 0xB } },
                    { { 0xC, 0xD }, { 0xE, 0xF } }
                }
            };


            for (int i = 0; i < 2; i++)
            {
                for (int j = 0; j < 2; j++)
                {
                    for (int k = 0; k < 2; k++)
                    {
                        for (int l = 0; l < 2; l++)
                        {
                            Console.Write("{0:X} ", array[i, j, k, l]);
                        }
                        Console.Write("\n");
                    }
                    Console.Write("\n");
                }
                Console.Write("\n");
            }

            // Delay.
            Console.ReadKey();
        }
示例#19
0
        private static int CountActive(int[,,,] grid)
        {
            var count = 0;

            ForEach(grid, (i, j, k, l, v) => count += v);
            return(count);
        }
示例#20
0
        static int DFS(int[,,,] dp, int x1, int y1, int x2, int y2, int[] ws, int[] hs, int[][] xys)
        {
            if (dp[x1, y1, x2, y2] >= 0)
            {
                return(dp[x1, y1, x2, y2]);
            }

            int max = 0;

            for (int i = 0; i < xys.Length; i++)
            {
                int x = xys[i][2];
                int y = xys[i][3];
                if (x1 < x && x < x2 && y1 < y && y < y2)
                {
                    int tmp = DFS(dp, x1, y1, x - 1, y - 1, ws, hs, xys)
                              + DFS(dp, x + 1, y1, x2, y - 1, ws, hs, xys)
                              + DFS(dp, x1, y + 1, x - 1, y2, ws, hs, xys)
                              + DFS(dp, x + 1, y + 1, x2, y2, ws, hs, xys);
                    for (int j = x1; j <= x2; j++)
                    {
                        tmp += ws[j];
                    }
                    for (int j = y1; j <= y2; j++)
                    {
                        tmp += hs[j];
                    }
                    tmp--;
                    max = Max(max, tmp);
                }
            }
            dp[x1, y1, x2, y2] = max;
            return(dp[x1, y1, x2, y2]);
        }
示例#21
0
        public virtual int[] SendArraysInt(int[,] arr2, int[,,] arr3, int[,,,] arr4)
        {
            BSyncResult <int[]> asyncResult = new BSyncResult <int[]>();

            SendArraysInt(arr2, arr3, arr4, BAsyncResultHelper.ToDelegate <int[]>(asyncResult));
            return(asyncResult.GetResult());
        }
示例#22
0
        public virtual void SetInt(int[,,,] v)
        {
            BSyncResult <Object> asyncResult = new BSyncResult <Object>();

            SetInt(v, BAsyncResultHelper.ToDelegate <Object>(asyncResult));
            asyncResult.GetResult();
        }
示例#23
0
        private static void MatrixSquared(int[,,,] array)
        {
            var arrayCopy       = (int[, , , ])array.Clone();
            var rowCount        = array.GetLength(2);
            var columnCount     = array.GetLength(3);
            var copyColumnCount = arrayCopy.GetLength(3);

            if (rowCount == copyColumnCount)
            {
                var arrayProduct = new int[1, 1, 4, 4];
                for (var i = 0; i < rowCount; i++)
                {
                    for (var j = 0; j < copyColumnCount; j++)
                    {
                        var sum = 0;
                        for (var k = 0; k < columnCount; k++)
                        {
                            var a = array[0, 0, i, k];
                            var b = arrayCopy[0, 0, k, j];
                            sum += a * b;
                        }
                        arrayProduct[0, 0, i, j] = sum;
                    }
                }
                Console.WriteLine("Here is the square of the matrix above");
                DisplayMatrix(arrayProduct);
            }
            else
            {
                Console.WriteLine("The matrix must have the same number of rows as columns");
            }
        }
示例#24
0
        private static void MatrixDeterminant(int[,,,] array)
        {
            if (array.GetLength(2) != array.GetLength(3))
            {
                Console.WriteLine("Determinant can only be calculated only for square matrices! \nEqual rows and columns");
            }
            else
            {
                var determinant = array[0, 0, 0, 0] * (array[0, 0, 1, 1] * (array[0, 0, 2, 2] * array[0, 0, 3, 3] - array[0, 0, 2, 3] * array[0, 0, 3, 2])
                                                       - array[0, 0, 1, 2] * (array[0, 0, 2, 1] * array[0, 0, 3, 3] - array[0, 0, 2, 3] * array[0, 0, 3, 1])
                                                       + array[0, 0, 1, 3] * (array[0, 0, 2, 1] * array[0, 0, 3, 2] - array[0, 0, 2, 2] * array[0, 0, 3, 1]))
                                  // second column
                                  - array[0, 0, 0, 1] * (array[0, 0, 1, 0] * (array[0, 0, 2, 2] * array[0, 0, 3, 3] - array[0, 0, 2, 3] * array[0, 0, 3, 2])
                                                         - array[0, 0, 1, 2] * (array[0, 0, 2, 0] * array[0, 0, 3, 3] - array[0, 0, 2, 3] * array[0, 0, 3, 0])
                                                         + array[0, 0, 1, 3] * (array[0, 0, 2, 0] * array[0, 0, 3, 2] - array[0, 0, 2, 2] * array[0, 0, 3, 0]))
                                  //third column
                                  + array[0, 0, 0, 2] * (array[0, 0, 1, 0] * (array[0, 0, 2, 1] * array[0, 0, 3, 3] - array[0, 0, 2, 3] * array[0, 0, 3, 1])
                                                         - array[0, 0, 1, 1] * (array[0, 0, 2, 0] * array[0, 0, 3, 3] - array[0, 0, 2, 3] * array[0, 0, 3, 0])
                                                         + array[0, 0, 1, 3] * (array[0, 0, 2, 0] * array[0, 0, 3, 1] - array[0, 0, 2, 1] * array[0, 0, 3, 0]))
                                  //fourth column
                                  - array[0, 0, 0, 3] * (array[0, 0, 1, 0] * (array[0, 0, 2, 1] * array[0, 0, 3, 2] - array[0, 0, 2, 2] * array[0, 0, 3, 1])
                                                         - array[0, 0, 1, 1] * (array[0, 0, 2, 0] * array[0, 0, 3, 2] - array[0, 0, 2, 2] * array[0, 0, 3, 0])
                                                         + array[0, 0, 1, 2] * (array[0, 0, 2, 0] * array[0, 0, 3, 1] - array[0, 0, 2, 1] * array[0, 0, 3, 0]));

                Console.WriteLine($"The determinant of the matrix is {determinant}.");
            }
        }
示例#25
0
        /// <summary>
        /// Converts a 4 dimensional dataSet to a 3 dimensional dataSet
        /// </summary>
        /// <param name="dataSet">The dataSet to fold</param>
        /// <param name="day">The day to focus</param>
        /// <param name="hour">The hour to focus</param>
        /// <returns></returns>
        public int[, ,] ConvertTo3D(int[, , ,] dataSet, int dayofmonth, int hour)
        {
            if (dayofmonth < 0 || dayofmonth > DateUtility.DaysInMonth(monthInReview, yearInReview))
            {
                throw new ArgumentOutOfRangeException("dayofmonth", "Cannot be less than 0 or greater than " + DateUtility.DaysInMonth(monthInReview, yearInReview));
            }
            if (dayofmonth > 0)
            {
                dayofmonth--;
            }
            //A 3d matrix of only days and hours and minutes
            int[, ,] dMatrix = new int[1, 1, 60];
            int MinuteTotal = 0;

            if (hour < 0)
            {
                throw new ArgumentOutOfRangeException("hour", "Cannot be less than 0");
            }
            if (hour > 24)
            {
                throw new ArgumentOutOfRangeException("hour", "Cannot be greater than 24");
            }
            for (int Minute = 0; Minute < 60; Minute++)
            {
                MinuteTotal = 0;
                for (int Second = 0; Second < 60; Second++)
                {
                    MinuteTotal += dataSet[dayofmonth, hour, Minute, Second];
                }
                dMatrix[0, 0, Minute] = MinuteTotal / 60;//seconds in a minute
            }//Minutes
            return(dMatrix);
        }
示例#26
0
    //初始化
    void Init()
    {
        //计算行列数
        size     = 20;
        grids    = new Grid[size, size];
        allgrids = new int[size, size, size, size];
        objs     = new GameObject[size, size];
        //起始坐标
        Vector3 startPos =
            new Vector3(plane.localScale.x * -5, 0, (float)plane.localScale.z * -5);

        //生成参考物体(Cube)
        for (int i = 0; i < size; i++)
        {
            for (int j = 0; j < size; j++)
            {
                grids [i, j] = new Grid(i, j);
                GameObject item = (GameObject)Instantiate(reference,
                                                          new Vector3(i * 0.5f, 0, j * 0.5f) + startPos + new Vector3((float)0.2, (float)0.0, (float)0.2),
                                                          Quaternion.identity);
                item.transform.GetChild(0).GetComponent <Reference> ().x = i;
                item.transform.GetChild(0).GetComponent <Reference> ().y = j;
                objs [i, j] = item;
            }
        }
    }
示例#27
0
文件: ArrayTests.cs 项目: jnm2/corefx
        public static void CreateInstance_Type_IntArray()
        {
            string[] stringArray = (string[])Array.CreateInstance(typeof(string), new int[] { 10 });
            Assert.Equal(stringArray, new string[10]);

            stringArray = (string[])Array.CreateInstance(typeof(string), new int[] { 0 });
            Assert.Equal(stringArray, new string[0]);

            int[] intArray1 = (int[])Array.CreateInstance(typeof(int), new int[] { 1 });
            VerifyArray(intArray1, 1, new int[] { 1 }, new int[] { 0 }, new int[] { 0 }, false);
            Assert.Equal(intArray1, new int[1]);

            int[,] intArray2 = (int[, ])Array.CreateInstance(typeof(int), new int[] { 1, 2 });
            VerifyArray(intArray2, 2, new int[] { 1, 2 }, new int[] { 0, 0 }, new int[] { 0, 1 }, false);
            intArray2[0, 1] = 42;
            Assert.Equal(42, intArray2[0, 1]);

            int[,,] intArray3 = (int[, , ])Array.CreateInstance(typeof(int), new int[] { 1, 2, 3 });
            VerifyArray(intArray3, 3, new int[] { 1, 2, 3 }, new int[] { 0, 0, 0 }, new int[] { 0, 1, 2 }, false);
            intArray3[0, 1, 2] = 42;
            Assert.Equal(42, intArray3[0, 1, 2]);

            int[,,,] intArray4 = (int[, , , ])Array.CreateInstance(typeof(int), new int[] { 1, 2, 3, 4 });
            VerifyArray(intArray4, 4, new int[] { 1, 2, 3, 4 }, new int[] { 0, 0, 0, 0 }, new int[] { 0, 1, 2 }, false);
            intArray4[0, 1, 2, 3] = 42;
            Assert.Equal(42, intArray4[0, 1, 2, 3]);
        }
示例#28
0
        //选择图片
        private void chooseImg_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog op = new Microsoft.Win32.OpenFileDialog();

            op.InitialDirectory = @"c:\";
            op.RestoreDirectory = true;
            op.Filter           = "图片文件|*.jpg;*.bmp;*.png";
            op.ShowDialog();
            path.Text = op.FileName;
            if (op.FileName == "")
            {
                return;
            }
            img0.Source = new BitmapImage(new Uri(op.FileName, UriKind.Absolute));
            Bitmap bmp = new Bitmap(op.FileName);

            System.Drawing.Color pixelColor;
            map  = new int[4, bmp.Width, bmp.Height, 3];
            x0   = bmp.Width / 2;
            y0   = bmp.Height / 2;
            maxR = x0 < y0 ? x0 : y0 - 3;
            r    = bmp.Height;
            c    = bmp.Width;
            for (int i = 0; i < c; ++i)
            {
                for (int j = 0; j < r; ++j)
                {
                    pixelColor      = bmp.GetPixel(i, j);
                    map[0, i, j, 0] = pixelColor.R;
                    map[0, i, j, 1] = pixelColor.G;
                    map[0, i, j, 2] = pixelColor.B;
                }
            }
        }
示例#29
0
    private int[,,,] matrix;   //holds values of matrix itself

    //create r*c matrix and fill it with data passed to this constructor
    public Matrix(int[,,,] int_array)
    {
        matrix        = int_array;
        row_matrix    = matrix.GetLength(2);
        column_matrix = matrix.GetLength(3);

        Console.WriteLine("Contructor which sets matrix size {0}x{1} and fill it with initial data executed.", row_matrix, column_matrix);
    }
示例#30
0
        static private void ValueTheChessboardNaive(int[,] points, int[,,,] qiju, int[,] a1, int[,] a2)
        {
            int i, j, k;
            int win;

            /******************根据评分规则对每一个空格评分***************/
            for (i = 0; i < size; i++)     // col
            {
                for (j = 0; j < size; j++) // row
                {
                    if (points[i, j] == 0)
                    {
                        win = 0;
                        for (k = 0; k < 4; k++)  // direction
                        {
                            if (qiju[i, j, k, 0] + qiju[i, j, k + 4, 0] >= 4)
                            {
                                win += 10000;
                            }
                            else if (qiju[i, j, k, 0] + qiju[i, j, k + 4, 0] == 3)
                            {
                                win += 1000;
                            }
                            else if (qiju[i, j, k, 0] + qiju[i, j, k + 4, 0] == 2)
                            {
                                win += 100;
                            }
                            else if (qiju[i, j, k, 0] + qiju[i, j, k + 4, 0] == 1)
                            {
                                win += 10;
                            }
                        }
                        a1[i, j] = win;         // black
                        win      = 0;
                        for (k = 0; k < 4; k++) // direction
                        {
                            if (qiju[i, j, k, 1] + qiju[i, j, k + 4, 1] >= 4)
                            {
                                win += 10000;
                            }
                            else if (qiju[i, j, k, 1] + qiju[i, j, k + 4, 1] == 3)
                            {
                                win += 1000;
                            }
                            else if (qiju[i, j, k, 1] + qiju[i, j, k + 4, 1] == 2)
                            {
                                win += 100;
                            }
                            else if (qiju[i, j, k, 1] + qiju[i, j, k + 4, 1] == 1)
                            {
                                win += 10;
                            }
                        }
                        a2[i, j] = win;  // white
                    }
                }
            }
        }
示例#31
0
 static NPC()
 {
     NPC.MoonLordAttacksArray = NPC.InitializeMoonLordAttacks();
     NPC.MoonLordAttacksArray2 = NPC.InitializeMoonLordAttacks2();
     NPC.MoonLordCountdown = 0;
     NPC.immuneTime = 20;
     NPC.maxAI = 4;
     NPC.goldCritterChance = 150;
     NPC.killCount = new int[540];
     NPC.waveKills = 0f;
     NPC.waveCount = 0;
     NPC.taxCollector = false;
     NPC.spawnSpaceX = 3;
     NPC.spawnSpaceY = 3;
     NPC.gravity = 0.3f;
     NPC.maxAttack = 20;
     NPC.attackNPC = new int[NPC.maxAttack];
     NPC.fireFlyFriendly = 0;
     NPC.fireFlyChance = 0;
     NPC.fireFlyMultiple = 0;
     NPC.butterflyChance = 0;
     NPC.golemBoss = -1;
     NPC.plantBoss = -1;
     NPC.crimsonBoss = -1;
     NPC.sWidth = 1920;
     NPC.sHeight = 1080;
     NPC.spawnRangeX = (int)((double)(NPC.sWidth / 16) * 0.7);
     NPC.spawnRangeY = (int)((double)(NPC.sHeight / 16) * 0.7);
     NPC.safeRangeX = (int)((double)(NPC.sWidth / 16) * 0.52);
     NPC.safeRangeY = (int)((double)(NPC.sHeight / 16) * 0.52);
     NPC.activeRangeX = (int)((double)NPC.sWidth * 2.1);
     NPC.activeRangeY = (int)((double)NPC.sHeight * 2.1);
     NPC.townRangeX = NPC.sWidth;
     NPC.townRangeY = NPC.sHeight;
     NPC.noSpawnCycle = false;
     NPC.activeTime = 750;
     NPC.defaultSpawnRate = 600;
     NPC.defaultMaxSpawns = 5;
     NPC.savedTaxCollector = false;
     NPC.savedGoblin = false;
     NPC.savedWizard = false;
     NPC.savedMech = false;
     NPC.savedAngler = false;
     NPC.savedStylist = false;
     NPC.downedBoss1 = false;
     NPC.downedBoss2 = false;
     NPC.downedBoss3 = false;
     NPC.downedQueenBee = false;
     NPC.downedSlimeKing = false;
     NPC.downedGoblins = false;
     NPC.downedFrost = false;
     NPC.downedPirates = false;
     NPC.downedClown = false;
     NPC.downedPlantBoss = false;
     NPC.downedGolemBoss = false;
     NPC.downedMartians = false;
     NPC.downedFishron = false;
     NPC.downedHalloweenTree = false;
     NPC.downedHalloweenKing = false;
     NPC.downedChristmasIceQueen = false;
     NPC.downedChristmasTree = false;
     NPC.downedChristmasSantank = false;
     NPC.downedAncientCultist = false;
     NPC.downedMoonlord = false;
     NPC.downedTowerSolar = false;
     NPC.downedTowerVortex = false;
     NPC.downedTowerNebula = false;
     NPC.downedTowerStardust = false;
     NPC.ShieldStrengthTowerSolar = 0;
     NPC.ShieldStrengthTowerVortex = 0;
     NPC.ShieldStrengthTowerNebula = 0;
     NPC.ShieldStrengthTowerStardust = 0;
     NPC.TowerActiveSolar = false;
     NPC.TowerActiveVortex = false;
     NPC.TowerActiveNebula = false;
     NPC.TowerActiveStardust = false;
     NPC.LunarApocalypseIsUp = false;
     NPC.downedMechBossAny = false;
     NPC.downedMechBoss1 = false;
     NPC.downedMechBoss2 = false;
     NPC.downedMechBoss3 = false;
     NPC.spawnRate = NPC.defaultSpawnRate;
     NPC.maxSpawns = NPC.defaultMaxSpawns;
     NPC.travelNPC = false;
     NPC.cavernMonsterType = new int[2, 3];
     NPC.ignorePlayerInteractions = 0;
 }