Inheritance: MonoBehaviour
Exemple #1
0
        /// <summary>重置棋盘</summary>
        public void ResetGrid()
        {
            int[] card1 = { 1, 2, 3, 4, 5, 6, 7, 8, -1, -2, -3, -4, -5, -6, -7, -8 };//正:蓝,负:红
            card = card1;
            List <int> list = new List <int>();

            //Step 1.加入字串Apple、Banana、Blueberry、Cherry、Grape
            foreach (var i in card)
            {
                list.Add(i);
            }

            //Step 2.打亂順序
            MyCollections.shuffle(ref list);

            for (int i = 0; i < 16; i++)
            {
                card[i] = list[i];
            }
            //放入数组
            int tmp = 0;

            for (int i = 0; i < max; i++)
            {
                for (int j = 0; j < max; j++)
                {
                    grid[i, j]      = card[tmp];
                    grid_flag[i, j] = -1;
                    card[tmp]       = card[tmp];
                    tmp++;
                }
            }
        }
Exemple #2
0
        public DataTable AddMyCollections([FromBody] MyCollections json)
        {
            DataTable dt = null;

            try
            {
                if (json.id > 0 && json.userid > 0)
                {
                    EPData    ep    = new EPData();
                    ValidInfo valid = ep.AddMyCollectionByCP(json);
                    if (valid.valid)
                    {
                        dt = GetTable("true", "");
                    }
                }
                else
                {
                    dt = GetTable("false", "参数错误");
                }
            }
            catch (Exception ex)
            {
                dt = GetTable("false", ex.Message);
                Log.WriteError(ex, "我的收藏(SettMyCollections)");
            }
            return(dt);
        }
Exemple #3
0
        /// <summary>重置棋盘</summary>
        public void ResetGrid()
        {
            List <int> list = new List <int>();

            //Step 1.加入字串Apple、Banana、Blueberry、Cherry、Grape
            foreach (var i in card)
            {
                list.Add(i);
            }

            //Step 2.打亂順序
            MyCollections.shuffle(ref list);


            //放入数组
            int tmp = 0;

            for (int i = 0; i < max; i++)
            {
                for (int j = 0; j < max; j++)
                {
                    grid[i, j]      = list[tmp];
                    grid_flag[i, j] = -1;
                    tmp++;
                }
            }
        }
Exemple #4
0
        public string ExecuteParallelTxt(string filepath, string resultfile_prefix, double[] radius_values, int cores)
        {
            List <List <double> > rbnn_r_batches = MyCollections.Split <double>(
                radius_values,
                (int)Math.Ceiling((decimal)radius_values.Length / (decimal)cores))
                                                   .Select(x => x.ToList()).ToList();

            ExecEachValInOwnThread(GConfig.TOOL_RBNN_PATH, filepath, rbnn_r_batches);

            string resultfilepath = CombineToOneFileAndDeleteOthers(filepath, resultfile_prefix, cores);

            return(resultfilepath);
        }
        private static void Execute()
        {
            Thread.CurrentThread.Name = "Main";

            int         loopend = DesiredChunks.Count;
            List <Task> tasks   = new List <Task>();

            for (int i = 0; i < loopend; i++)
            {
                int  a    = DesiredChunks[i][0];
                int  b    = DesiredChunks[i][1];
                Task task = new Task(() => {
                    new SlemenikDownloader().DownloadData(a, b);
                });
                Console.WriteLine(Thread.CurrentThread.Name);
                tasks.Add(task);
            }

            // partition to batch size of 8 for 8 core processors.
            List <List <Task> > batches = MyCollections.Partition <Task>(tasks.ToArray(), 8).ToList();

            foreach (var batch in batches)
            {
                Console.WriteLine("Batch start");
                foreach (Task t in batch)
                {
                    t.Start();
                }
                foreach (Task t in batch)
                {
                    t.Wait();
                }
            }


            Console.WriteLine("Task finished");
        }
        public ValidInfo AddMyCollectionByCP(MyCollections coll)
        {
            ValidInfo     valid  = new ValidInfo();
            SqlConnection sqlcon = new SqlConnection(con);

            try
            {
                SqlCommand cmd = new SqlCommand("", sqlcon);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@userid", SqlDbType.Int).Value           = coll.userid;
                cmd.Parameters.Add("@collectiontype", SqlDbType.Int).Value   = coll.collectiontype;
                cmd.Parameters.Add("@contentid", SqlDbType.Int).Value        = coll.contentid;
                cmd.Parameters.Add("@contenturl", SqlDbType.VarChar).Value   = coll.contenturl;
                cmd.Parameters.Add("@imageurl", SqlDbType.VarChar).Value     = coll.imageurl;
                cmd.Parameters.Add("@title", SqlDbType.VarChar).Value        = coll.title;
                cmd.Parameters.Add("@descriptions", SqlDbType.VarChar).Value = coll.descriptions;
                cmd.Parameters.Add("@outvalid", SqlDbType.Bit).Direction     = ParameterDirection.Output;
                sqlcon.Open();
                cmd.ExecuteNonQuery();
                sqlcon.Dispose();
                sqlcon.Close();
                string outvalid = cmd.Parameters["@outvalid"].Value == null ? "false" : cmd.Parameters["@outvalid"].Value.ToString().ToLower();
                if (outvalid == "true")
                {
                    valid.valid = true;
                }
            }
            catch (Exception ex)
            {
                sqlcon.Dispose();
                sqlcon.Close();
                throw ex;
            }

            return(valid);
        }
Exemple #7
0
        static void Main(string[] args)
        {
            List <List <int> > chunks = GConfig.GET_PICKED_CHUNKS();

            List <List <int> > list = new List <List <int> >();

            string[] augs = Directory.GetFiles(Path.Combine(GConfig.WORKSPACE_DIR, GConfig.AUGMENTATION_SUBDIR));
            foreach (string s in augs)
            {
                if (File.Exists(s))
                {
                    Regex rx = new Regex(@"[0-9]{3}[_]{1}[0-9]{2,3}",
                                         RegexOptions.Compiled | RegexOptions.IgnoreCase);
                    Match  matches = rx.Match(s);
                    string chunk   = matches.Value;

                    string[]   parts   = chunk.Split("_");
                    List <int> element = new List <int>();
                    element.Add(int.Parse(parts[0]));
                    element.Add(int.Parse(parts[1]));
                    list.Add(element);
                }
            }

            List <List <int> > filteredChunks = new List <List <int> >();

            foreach (List <int> chunk in chunks)
            {
                bool kurac = true;
                for (int i = 0; i < list.Count; i++)
                {
                    if (list[i][0] == chunk[0] && list[i][1] == chunk[1])
                    {
                        kurac = false;
                        break;
                    }
                }
                if (!kurac)
                {
                    continue;
                }

                filteredChunks.Add(chunk);
            }
            chunks = filteredChunks;



            List <Task> tasks = new List <Task>();

            Console.WriteLine($"Processing {chunks.Count} chunks.");
            foreach (List <int> chunk in chunks)
            {
                Program prg = new Program();
                prg.TxtDatasetFileName = chunk[0] + "_" + chunk[1] + ".txt";
                prg.DmrFileName        = $"pcd{chunk[0]}_{chunk[1]}";
                prg.SamplesFileName    = $"{chunk[0]}_{chunk[1]}augmentation_result.txt";

                Task t = new Task((exec_env) => {
                    try
                    {
                        Program exec_env_prg = (Program)exec_env;
                        Tools.Time(exec_env_prg.UnfilteredSampleObjects);
                        Tools.Time(exec_env_prg.FilterOverlappingObjects);
                        Tools.Time(exec_env_prg.FilterUndergroundPoints);

                        exec_env_prg.samples = exec_env_prg.samples.Take(GConfig.ObjectsToAdd).ToList();

                        Tools.Time(exec_env_prg.ComputeRbnnMinVals);
                        Tools.Time(exec_env_prg.SaveResults);
                    }
                    catch (Exception ex) {
                        Console.WriteLine("Failed executing " + ((Program)exec_env).TxtDatasetFileName + ex.StackTrace + ex.Message);
                    }
                }, prg);
                tasks.Add(t);
            }

            List <List <Task> > batches = MyCollections.Partition <Task>(tasks.ToArray(), 5).ToList();

            foreach (var batch in batches)
            {
                foreach (Task t in batch)
                {
                    t.Start();
                }
                foreach (Task t in batch)
                {
                    t.Wait();
                }
            }

            Console.WriteLine("Program finished. Press the ANY key to continue...");
            Console.ReadLine();
        }
        static void Main(string[] args)
        {
            string[] filepaths = Directory.GetFiles(lazfolder, "*.laz");
            string[] dmrpaths  = Directory.GetFiles(dmrfolder);


            List <Task> tasks = new List <Task>();

            foreach (string path in filepaths)
            {
                string current_path = path;
                Task   task         = new Task(() =>
                {
                    CoreProcedure procedure = new CoreProcedure(current_path);
                    procedure.PreprocessLaz();
                });
                tasks.Add(task);
            }

            // partition to batch size of 8 for 8 core processors.
            List <List <Task> > batches = MyCollections.Partition <Task>(tasks.ToArray(), 8).ToList();

            foreach (var batch in batches)
            {
                foreach (Task t in batch)
                {
                    t.Start();
                }
                foreach (Task t in batch)
                {
                    t.Wait();
                }
                foreach (Task t in batch)
                {
                    t.Dispose();
                }
            }



            tasks = new List <Task>();
            foreach (string dmr in dmrpaths)
            {
                if (dmr.Contains("pcd"))
                {
                    continue;
                }
                string current_dmr = dmr;
                Task   task        = new Task((object dmr_state) =>
                {
                    CoreProcedure procedure = new CoreProcedure((string)dmr_state);
                    procedure.Dmr2Pcd();
                }, current_dmr);
                tasks.Add(task);
            }

            batches = MyCollections.Partition <Task>(tasks.ToArray(), 8).ToList();
            foreach (var batch in batches)
            {
                foreach (Task t in batch)
                {
                    t.Start();
                }
                foreach (Task t in batch)
                {
                    t.Wait();
                }
            }
        }