コード例 #1
0
ファイル: Task.cs プロジェクト: mc17uulm/Heisenberg
 public void CreateCircles(LatinSquare LTT, int c)
 {
     int[] column = LTT.GetColumn(c);
     for (int j = 0; j < column.Length; j++)
     {
         int Amp  = 1;
         int Size = 1;
         if (column[j] <= 3)
         {
             Amp  = Config.TargetAmplitudes[0];
             Size = Config.TargetWidths[column[j] - 1];
         }
         else
         {
             Amp  = Config.TargetAmplitudes[1];
             Size = Config.TargetWidths[column[j] - 4];
         }
         List <Target> Targets = new List <Target>();
         int           n       = Config.CircleSize;
         for (int k = 0; k < n; k++)
         {
             Vector3 v = new Vector3(Convert.ToSingle(((double)Amp / 2) * Math.Sin(k * ((double)360 / n) * (Math.PI / 180))), Convert.ToSingle(((double)Amp / 2) * Math.Cos(k * ((double)360 / n) * (Math.PI / 180))), 0);
             Targets.Add(new Target(k, v));
         }
         this.Circles.Add(new Circle(j, Amp, Size, this.SortCircle(Targets)));
     }
 }
コード例 #2
0
ファイル: Processing.cs プロジェクト: mc17uulm/Heisenberg
    void OnEnable()
    {
        Index = 0;

        Config.init();
        Debug.Log("UserID: " + Config.UserId);
        Session.Initalize();

        LaserPointer = GetComponent <SteamVR_LaserPointer>();

        Rounds = 0;

        LTC = new LatinSquare(8);
        LTT = new LatinSquare(Config.TargetAmplitudes.Length * Config.TargetWidths.Length);

        Tasks = CreateTasks(LTC, LTT);

        UpdateTask();
        HideTimer();

        State = State.START;

        ShowCommand("Start");
        Tunnel.IsInitalized();
    }
コード例 #3
0
ファイル: Processing.cs プロジェクト: mc17uulm/Heisenberg
    public static List <Task> CreateTasks(LatinSquare LTC, LatinSquare LTT)
    {
        /**string file = Path.Combine(Application.streamingAssetsPath, "latinsquares.txt");
         * for (int r = 0; r <= 12; r++) {*/
        int[] column = LTC.GetColumn(Config.UserId % 8);
        int   start  = (Config.UserId * LTC.GetSize()) % LTT.GetSize();
        //int[] column = LTC.GetColumn(r % 8);
        //int start = (r * LTC.GetSize()) % LTT.GetSize();
        List <Task> Tasks = new List <Task>();

        for (int i = 0; i < column.Length; i++)
        {
            // Get states from LatinSquare for Tasks
            int          state = column[i];
            BodyPosition Body  = state <= 4 ? BodyPosition.SITTING : BodyPosition.STANDING;
            ArmPosition  Arm   = new List <int>()
            {
                1, 2, 5, 6
            }.IndexOf(state) != -1 ? ArmPosition.STRECHED : ArmPosition.APPLIED;
            DOF dof = state % 2 == 0 ? DOF.THREE : DOF.SIX;

            Task tmp = new Task(i, Body, Arm, dof);
            tmp.CreateCircles(LTT, (i * column.Length) % LTT.GetSize());
            Debug.Log(tmp.PrintCommand(i));

            /**if (!File.Exists(file)) {
             *   using (StreamWriter w = File.CreateText(file)) {
             *       w.WriteLine("UserId: " + r + " | TaskNo. " + i + " | Command: " + tmp.PrintCommand(i));
             *   }
             * } else {
             *   using (StreamWriter w = File.AppendText(file)) {
             *       w.WriteLine("UserId: " + r + " | TaskNo. " + i + " | Command: " + tmp.PrintCommand(i));
             *   }
             * }*/

            Tasks.Add(tmp);

            start = start < LTC.GetSize() ? start + 1 : 0;
            //}
        }

        return(Tasks);
    }
コード例 #4
0
ファイル: Program.cs プロジェクト: taigaa/CodeIQ
        static void Main(string[] args)
        {
            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();


            //var elements = new[] { 0, 1, 2 };
            //var elements = new[] { 0, 1, 2, 3 };
            //var elements = new[] { 0, 1, 2, 3, 4 };
            //var elements = new[] { 0, 1, 2, 3, 4, 5 };
            var elements = new[] { 'u', 's', 'e', 'r' };
            //var elements = new[] { 'a', 'l', 'e', 'r', 't' };

            //var squares = LatinSquare.GetStandardLatinSquare(elements);
            var squares = LatinSquare.GetLatinSquare(elements);

            // 単語として意味をなさないものを除く

            /*
             * 【{a, e, l, s, t}の辞書】
             * steal = 盗む
             * stela = 記念碑
             * telas = スペインの織物
             * teals = コガモ(複数形)
             * elast = 柔軟弾力を意味する接頭辞
             * least = 最小
             * laste = lassen(溶接する)というオランダ語の仮定法(出典)
             * astel = 差し矢
             */
            //var dictionary = new string[] { "steal", "stela", "telas", "teals", "elast", "least", "laste", "astel" };
            //var dictionary = new string[] { "user", "rues", "ruse", "sure" };
            var dictionary = new string[] { "user", "erus", "resu", "sure" };

            // 行でチェック
            var lineChecked = squares.Select(ss => ss.Where(s => dictionary.Contains(new String(s.ToArray())))
                                             .Where(s => s.Count() != 0))
                              .Where(ss => ss.Count() == squares.ElementAt(0).Count());

            // 列でチェック
            var rowCheckd = lineChecked.Select(ss => LatinSquare.GetRowColumnChangeArray(ss))
                            .Select(ss => ss.Where(s => dictionary.Contains(new String(s.ToArray())))
                                    .Where(s => s.Count() != 0))
                            .Where(ss => ss.Count() == squares.ElementAt(0).Count());

            // 結果表示
            foreach (var square in rowCheckd)
            {
                foreach (var line in square)
                {
                    foreach (var element in line)
                    {
                        Console.Write("{0}", element);
                    }
                    Console.WriteLine();
                }
                Console.WriteLine();
            }


            sw.Stop();
            Console.WriteLine("経過時間 = {0}", sw.Elapsed);

            Console.ReadLine();
        }