Esempio n. 1
0
        public void PlainPatternTest()
        {
            var pattern = PatternGenerator.CreatePattern(48, 5);

            Assert.That(pattern.Length == 5);
            Assert.That(pattern.Aggregate(1, (p, next) => p * next) == 48);
        }
Esempio n. 2
0
        public void FectaPatternTest(int lines)
        {
            var pattern = PatternGenerator.CreateFectaPattern(lines, 4);

            Assert.That(pattern.Length == 4);
            Console.WriteLine(string.Join("/", pattern));
        }
Esempio n. 3
0
        /// <summary>
        ///     Reset and start a new game.
        /// </summary>
        public void StartGame()
        {
            // Clear frozen blocks
            foreach (var block in _frozenBlocks)
            {
                OnBlockChanged(block, true);
            }
            _frozenBlocks.Clear();

            // Clear active tetrimino (if we have to do so)
            if (_activeTetrimino != null)
            {
                UpdateActiveTetrimino(true);
                _activeTetrimino = null;
            }

            // Fill in tetriminos
            var generatedTetriminos = PatternGenerator.GetPlayablePattern(_random).Reverse();

            foreach (var tetrimino in generatedTetriminos)
            {
                _pendingTetriminos.Push(tetrimino);
            }

            // Ready to start a new game
            _stopwatch.Reset();
            _stopwatch.Start();
            SpawnNextTetrimino();
            GameEnded = false;
        }
    void Awake()
    {
        tutorialSections = GetComponents <ITutorialSection>();
        patternGen       = new PatternGenerator();
        _objectHandler   = GetComponent <ObjectHandler>();
        _controller      = GetComponent <GameController>();
        if (_objectHandler == null)
        {
            Debug.LogError("No handler assigned to Game Controller");
        }
        if (_controller == null)
        {
            Debug.LogError("No controller assigned to Game Controller");
        }
        subscribeEvents();

        PlayGamesPlatform.DebugLogEnabled = true;
        PlayGamesPlatform.Activate();

        //IF TUTORIAL ENABLED
        if (PlayerPrefs.GetInt("playedOnce") == 0 || PlayerPrefs.GetInt("forceTut") != 0)
        {
            SaveTutValues(0, PlayerPrefs.GetInt("playedOnce"));
            nextTutorialSection();
        }
        else
        {
            _spawner.setTutorialEnded(true);
            tutorialText.SetActive(false);
            paused = false;
        }
    }
Esempio n. 5
0
            public string NextColour()
            {
                string colour = string.Format(PatternGenerator.NextPattern(index), intensityGenerator.NextIntensity(index));

                index += 1;
                return(colour);
            }
Esempio n. 6
0
        public string NextColour()
        {
            string colour = string.Format(PatternGenerator.NextPattern(this.index), this.intensityGenerator.NextIntensity(this.index));

            this.index++;
            return(colour);
        }
Esempio n. 7
0
        private IEnumerable <GameObject> FindObjectsInGaze(Vector2 gazePoint,
                                                           Camera camera)
        {
            var objectsInGaze = new List <GameObject>();
            var fovealAngle   = 2.0f;
            var distanceGazeOriginToScreen_inches = 24f; // ~ 60 cm
            var dpi = Screen.dpi > 0 ? Screen.dpi : 100;
            var fovealRadius_inches = Mathf.Tan(fovealAngle * Mathf.Deg2Rad) *
                                      distanceGazeOriginToScreen_inches;
            var fovealRadius_pixels =
                Mathf.RoundToInt(fovealRadius_inches * dpi);

            var points =
                PatternGenerator.CreateCircularAreaUniformPattern(gazePoint,
                                                                  fovealRadius_pixels, 4);
            IEnumerable <RaycastHit> hitInfos;

            if (HitTestFromPoint.FindMultipleObjectsInWorldFromMultiplePoints(
                    out hitInfos, points, camera,
                    MaximumDistance, LayerMask))
            {
                foreach (var raycastHit in hitInfos)
                {
                    objectsInGaze.Add(raycastHit.collider.gameObject);
                }
            }

            return(objectsInGaze);
        }
Esempio n. 8
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKey(KeyCode.LeftShift))
        {
            shiftOctave = 1;
        }
        else
        {
            shiftOctave = 0;
        }

        foreach (NoteName n in Enum.GetValues(typeof(NoteName)))
        {
            if (KeyboardInput.KeyDown(n))
            {
                //TrackGenerator.GenerateHarmonyTable(n, TableManager.GetTable(TableType.RatioBasedTable));
                PatternGenerator.CreatePattern();
            }

            if (KeyboardInput.KeyHeld(n))
            {
                attachedOscillator.PlayNote(KeyboardInput.NoteToStep(n), 4 + shiftOctave);
                return;
            }
        }

        attachedOscillator.PlayNote(-1, 0);
    }
Esempio n. 9
0
        /// <summary>
        /// TimerInitialisation
        /// </summary>
        private async void InitAll()
        {
            StripeTimer          = new DispatcherTimer();
            StripeTimer.Interval = TimeSpan.FromMilliseconds(refreshCycle);
            StripeTimer.Tick    += StripeRefresh_Tick;

            SweepTimer          = new DispatcherTimer();
            SweepTimer.Interval = TimeSpan.FromMilliseconds(3000);
            SweepTimer.Tick    += Sweep_Tick;

            GPIOvar = GpioController.GetDefault(); /* Get the default GPIO controller on the system */
            await InitSpi();                       /* Initialize the SPI controller                */

            CSadrLEDD = new SPIAddressObject(SPIAddressObject.eCSadrMode.SPIdedicated, null, null, 0);
            RGBstripe = new LED_APA102(SPIinterface_Demo, CSadrLEDD);
            // Bei der Instanziierung wird erstes LED-Objekt erstellt.

            for (int i = 0; i < StripeLen - 1; i++)
            {
                RGBstripe.AddLED(RGBDefines.Black);
            }

            // LED-Demo
            StripePattern = new PatternGenerator(StripeLen, 1);
            StripePattern.AddCurve(PatternGenerator.eCurveType.Sine);
            StripePattern.AddCurve(PatternGenerator.eCurveType.Pulse);
            StripePattern.AddCurve(PatternGenerator.eCurveType.Cosine);
            StripePattern.AddCurve(PatternGenerator.eCurveType.Triangle);
            StripePattern.AddCurve(PatternGenerator.eCurveType.Sawtooth);

            StripeTimer.Start();
            btn_StartDemo(new object(), new RoutedEventArgs());
        }
        public void StringPatternGenerator_C_with_StartValue_with_Increment()
        {
            var sut = new PatternGenerator("{C:33,3}");

            Assert.AreEqual("33", sut.GetValue());
            Assert.AreEqual("36", sut.GetValue());
            Assert.AreEqual("39", sut.GetValue());
        }
        public void StringPatternGenerator_C__startvalue_negative__negative_increment()
        {
            var sut = new PatternGenerator("{C:-3,-2}");

            Assert.AreEqual("-3", sut.GetValue());
            Assert.AreEqual("-5", sut.GetValue());
            Assert.AreEqual("-7", sut.GetValue());
        }
        public void StringPatternGenerator_C_simple()
        {
            var sut = new PatternGenerator("{C}");

            Assert.AreEqual("1", sut.GetValue());
            Assert.AreEqual("2", sut.GetValue());
            Assert.AreEqual("3", sut.GetValue());
        }
        public void StringPatternGenerator_C_with_StartValue()
        {
            var sut = new PatternGenerator("{C:33}");

            Assert.AreEqual("33", sut.GetValue());
            Assert.AreEqual("34", sut.GetValue());
            Assert.AreEqual("35", sut.GetValue());
        }
        public void StringPatternGenerator_C__startvalue_negative__positive_increment()
        {
            var sut = new PatternGenerator("{C:-3,+2}");

            Assert.Equal("-3", sut.GetValue());
            Assert.Equal("-1", sut.GetValue());
            Assert.Equal("1", sut.GetValue());
            Assert.Equal("3", sut.GetValue());
        }
Esempio n. 15
0
        private IEnumerable <Vector3> _GetFlowerPointsPattern()
        {
            PatternGenerator flowerPattern = new PatternGenerator(
                new Function2D(a => a, v => v.Y, new Range(-(float)Math.PI, (float)Math.PI)),
                new Function2D(p => 3 + 2 * (float)Math.Sin(8 * p), v => v.X * (float)Math.Sin(v.Y), new Range(-(float)Math.PI, (float)Math.PI)),
                new Function2D(p => 18, v => v.Y, new Range(0, 1)));

            return(flowerPattern.GetPoints(200));
        }
Esempio n. 16
0
 /* Method to generate a new pattern. Uses the method from
  * PatternGenerator.cs */
 public void InitializePattern(int length)
 {
     pattern = PatternGenerator.GeneratePattern(length);
     displayEvent.Invoke(pattern, length);
     patternLength      = length;
     playerMatchPattern = false;
     PuzzleMatcher.instance.ClearPlayerArrays();
     StartCoroutine(WaitForPatternMatch());
 }
 public void StringPatternGenerator_A_fixed_len()
 {
     var sut = new PatternGenerator("x{A:3}x");
     for (int n = 0; n < 10000; n++)
     {
         var s = sut.GetValue();
         Assert.True(Regex.IsMatch(s, "^x[A-Z]{3}x$"));
     }
 }
        public void StringPatternGenerator_C_combination()
        {
            var sut = new PatternGenerator("_{C}_{C:+11}_{C:110,10}_");

            Assert.AreEqual("_1_11_110_", sut.GetValue());
            Assert.AreEqual("_2_12_120_", sut.GetValue());
            Assert.AreEqual("_3_13_130_", sut.GetValue());
            Assert.AreEqual("_4_14_140_", sut.GetValue());
        }
        public void StringPatternGenerator_A_random_len()
        {
            var sut = new PatternGenerator("x{A:3-6}x");

            for (int n = 0; n < 10000; n++)
            {
                var s = sut.GetValue();
                Assert.IsTrue(Regex.IsMatch(s, "^x[A-Z]{3,6}x$"));
            }
        }
Esempio n. 20
0
        private Pattern GenerateSmartPattern(int lines)
        {
            var bins = TypeCode == "RACE_ORDER"
                ? PatternGenerator.CreateFectaPattern(lines, Legs.Length)
                : PatternGenerator.CreateSmartPattern(lines,
                                                      Legs.ToDictionary(l => l.LegOrder, l => l.Selections.Length));
            var pattern = new Pattern(bins.ToArray());

            SmartPickPatterns[lines] = pattern;
            return(pattern);
        }
        public void StringPatternGenerator_aaa()
        {
            var sut = new PatternGenerator("xcccx");

            for (int n = 0; n < 10000; n++)
            {
                var s = sut.GetValue();
                Assert.IsTrue(s.Length == 5);
                Assert.IsTrue(Regex.IsMatch(s, "^x[a-z]{3}x$"));
            }
        }
        public void StringPatternGenerator_C_startvalue_negative_value()
        {
            var sut = new PatternGenerator("{C:-3}");

            Assert.AreEqual("-3", sut.GetValue());
            Assert.AreEqual("-2", sut.GetValue());
            Assert.AreEqual("-1", sut.GetValue());
            Assert.AreEqual("0", sut.GetValue());
            Assert.AreEqual("1", sut.GetValue());
            Assert.AreEqual("2", sut.GetValue());
            Assert.AreEqual("3", sut.GetValue());
        }
Esempio n. 23
0
    // Start is called before the first frame update
    void Start()
    {
        path    = GetComponent <Path>();
        pattern = GetComponent <PatternGenerator>();

        spawnNote();
        SetStartLine();
        if (spawnBackground)
        {
            SpawnBackGroundNote();
        }
    }
Esempio n. 24
0
        public void FindPattern(IReadOnlyCollection <string> data)
        {
            // Arrange
            var finder = new PatternGenerator();

            // Act
            var result = finder.LoadStrings(data).FindPattern().ToString();

            // Assert
            var count = data.Count(x => Regex.IsMatch(x, result));

            Assert.AreEqual(data.Count, count, result);
        }
        public void StringPatternGenerator_A()
        {
            HashSet<char> chars = new HashSet<char>();

            var sut = new PatternGenerator("{A}");
            for (int n = 0; n < 10000; n++)
            {
                var s = sut.GetValue();
                Assert.True(Regex.IsMatch(s, "^[A-Z]$"));
                chars.Add(s[0]);
            }

            Assert.Equal(26, chars.Count);
        }
        public void StringPatternGenerator_A()
        {
            HashSet <char> chars = new HashSet <char>();

            var sut = new PatternGenerator("{A}");

            for (int n = 0; n < 10000; n++)
            {
                var s = sut.GetValue();
                Assert.IsTrue(Regex.IsMatch(s, "^[A-Z]$"));
                chars.Add(s[0]);
            }

            Assert.AreEqual(26, chars.Count, "Should have all a..z");
        }
Esempio n. 27
0
        private void GeneratePatternButton_Click(object sender, RoutedEventArgs e)
        {
            Block[,] template;

            try
            {
                template = To2D(currentTemplate.ToArray());
            }
            catch (ArgumentException)
            {
                MessageBox.Show("Unable to generate a square array. Is the template empty?",
                                "Error",
                                MessageBoxButton.OK, MessageBoxImage.Error
                                );
                return;
            }

            var tetriminos = PatternGenerator.GetPattern(template);

            if (tetriminos.Count == 0)
            {
                MessageBox.Show("Unable to find a solution.",
                                "Warning",
                                MessageBoxButton.OK, MessageBoxImage.Warning, MessageBoxResult.OK
                                );
            }
            foreach (Tetrimino tetrimino in tetriminos)
            {
                foreach (Block block in tetrimino.Blocks)
                {
                    template[block.Position.Y, block.Position.X].FilledBy = block.FilledBy;
                }
            }
            RefreshCurrentResultDisplay(template);

            var orderedTetriminos =
                PatternSorter.GetSortedTetriminos(tetriminos, template.GetLength(1), template.GetLength(0));
            var order = new int?[template.GetLength(0), template.GetLength(1)];

            RefreshCurrentOrderedDisplay(orderedTetriminos, order);

            currentTemplate.Clear();
            currentRow.Clear();
            currentRowId = 0;
            currentColId = 0;
            RefreshCurrentRowDisplay();
            RefreshCurrentTemplateDisplay();
        }
Esempio n. 28
0
        private IEnumerable <IDrawable> _GetForest(int xVal)
        {
            PatternGenerator p = new PatternGenerator(
                new Function2D(x => xVal, v => v.Y, new Range(0, 1)),
                new Function2D(x => 1, v => v.Y, new Range(0, 1)),
                new Function2D(z => - z, v => v.Y, new Range(-10, 0)));

            IEnumerable <IDrawable> trees = p.GetPoints(5)
                                            .Select(point => new SceneActor(_models["christmasTree"], point, Color.Green,
                                                                            new ReflectanceFactors(new Vector3((float)0.01, (float)0.01, (float)0.01),
                                                                                                   new Vector3((float)0.5, (float)0.5, (float)0.5),
                                                                                                   new Vector3((float)0.1, (float)0.1, (float)0.1),
                                                                                                   50)));

            return(trees);
        }
        public void StringPatternGenerator_X()
        {
            HashSet <char> chars = new HashSet <char>();

            var sut = new PatternGenerator("{X}");

            for (int n = 0; n < 10000; n++)
            {
                var s = sut.GetValue();
                Assert.IsTrue(s.Length == 1);
                Assert.IsTrue(Regex.IsMatch(s, "^[0-9A-F]$"));
                chars.Add(s[0]);
            }

            Assert.AreEqual(16, chars.Count, "Should have all 0-9 A-F");
        }
        public void StringPatternGenerator_a_composite()
        {
            HashSet <char> chars = new HashSet <char>();

            var sut = new PatternGenerator("a {a}");

            for (int n = 0; n < 10000; n++)
            {
                var s = sut.GetValue();
                Assert.IsTrue(s.Length == 3);
                Assert.IsTrue(Regex.IsMatch(s, "^a [a-z]$"));
                chars.Add(s[2]);
            }

            Assert.AreEqual(26, chars.Count, "Should have all a..z");
        }
        public void StringPatternGenerator_a()
        {
            HashSet <char> chars = new HashSet <char>();

            var sut = new PatternGenerator("{a}");

            for (int n = 0; n < 10000; n++)
            {
                var s = sut.GetValue();
                Assert.IsTrue(s.Length == 1);
                Assert.IsTrue(Regex.IsMatch(s, "^[a-z]$"));
                chars.Add(s[0]);
            }

            Assert.AreEqual(26, chars.Count);
        }
Esempio n. 32
0
        private void _AddTreesWithLamps(Scene scene, int xVal, int incX, Color lightColor, Model lamp)
        {
            PatternGenerator sin = new PatternGenerator(
                new Function2D(a => xVal + incX, v => v.Y, new Range(0, 1)),
                new Function2D(a => (float)Math.Sin(a), v => v.Y, new Range(0, (float)Math.PI * 8)),
                new Function2D(a => - a, v => v.Y, new Range(-10, 0)));

            scene.AddIllumination(new Illumination(lamp,
                                                   sin.GetPoints(100), lightColor,
                                                   new ReflectanceFactors(Vector3.Zero, Vector3.One, Vector3.One, 10)));


            foreach (IDrawable tree in _GetForest(xVal))
            {
                scene.AddObject(tree);
            }
        }
 public void StringPatternGenerator_C__startvalue_negative__positive_increment()
 {
     var sut = new PatternGenerator("{C:-3,+2}");
     Assert.AreEqual("-3", sut.GetValue());
     Assert.AreEqual("-1", sut.GetValue());
     Assert.AreEqual("1", sut.GetValue());
     Assert.AreEqual("3", sut.GetValue());
 }
 public KinectPatternStart(IActivatable lightProvider, Scene scene, KinectPlugin kinectPlugin, int bodyIndex)
     : base(lightProvider, scene, 0, 0, GetBasePattern(), bodyIndex+1)
 {
     _ordering = GetOrdering(scene, new Vector3D());
     _bodyIndex = bodyIndex;
     _plugin = kinectPlugin;
     _patternGen = new PatternGenerator(scene);
     _patternGen.AvailableOrderings = new List<string>{SpatialOrderingTypes.Expand};
     _patternGen.Params.PatternLengthMin = .5;
     _patternGen.Params.PatternLengthMax = 1;
     _patternGen.Params.ColorsMin = 2;
     kinectPlugin.GestureUpdateHandler += HandleGestureUpdate;
 }
 public void StringPatternGenerator_C__startvalue_negative__negative_increment()
 {
     var sut = new PatternGenerator("{C:-3,-2}");
     Assert.Equal("-3", sut.GetValue());
     Assert.Equal("-5", sut.GetValue());
     Assert.Equal("-7", sut.GetValue());
 }
 public GenerativePatternProvider(Scene scene)
 {
     _scene = scene;
     _patternGenerator = new PatternGenerator(scene);
 }
 public void StringPatternGenerator_C_combination()
 {
     var sut = new PatternGenerator("_{C}_{C:+11}_{C:110,10}_");
     Assert.Equal("_1_11_110_", sut.GetValue());
     Assert.Equal("_2_12_120_", sut.GetValue());
     Assert.Equal("_3_13_130_", sut.GetValue());
     Assert.Equal("_4_14_140_", sut.GetValue());
 }
 public void StringPatternGenerator_C_startvalue_negative_value()
 {
     var sut = new PatternGenerator("{C:-3}");
     Assert.Equal("-3", sut.GetValue());
     Assert.Equal("-2", sut.GetValue());
     Assert.Equal("-1", sut.GetValue());
     Assert.Equal("0", sut.GetValue());
     Assert.Equal("1", sut.GetValue());
     Assert.Equal("2", sut.GetValue());
     Assert.Equal("3", sut.GetValue());
 }
 public void StringPatternGenerator_C_with_StartValue()
 {
     var sut = new PatternGenerator("{C:33}");
     Assert.Equal("33", sut.GetValue());
     Assert.Equal("34", sut.GetValue());
     Assert.Equal("35", sut.GetValue());
 }
 public void StringPatternGenerator_C_with_StartValue_with_Increment()
 {
     var sut = new PatternGenerator("{C:33,3}");
     Assert.Equal("33", sut.GetValue());
     Assert.Equal("36", sut.GetValue());
     Assert.Equal("39", sut.GetValue());
 }
 public void StringPatternGenerator_C_simple()
 {
     var sut = new PatternGenerator("{C}");
     Assert.Equal("1", sut.GetValue());
     Assert.Equal("2", sut.GetValue());
     Assert.Equal("3", sut.GetValue());
 }
        public void StringPatternGenerator_X()
        {
            HashSet<char> chars = new HashSet<char>();

            var sut = new PatternGenerator("{X}");
            for (int n = 0; n < 10000; n++)
            {
                var s = sut.GetValue();
                Assert.True(s.Length == 1);
                Assert.True(Regex.IsMatch(s, "^[0-9A-F]$"));
                chars.Add(s[0]);
            }

            Assert.Equal(16, chars.Count);
        }
 public void StringPatternGenerator_aaa()
 {
     var sut = new PatternGenerator("xcccx");
     for (int n = 0; n < 10000; n++)
     {
         var s = sut.GetValue();
         Assert.True(s.Length == 5);
         Assert.True(Regex.IsMatch(s, "^x[a-z]{3}x$"));
     }
 }
        public void StringPatternGenerator_a_composite()
        {
            HashSet<char> chars = new HashSet<char>();

            var sut = new PatternGenerator("a {a}");
            for (int n = 0; n < 10000; n++)
            {
                var s = sut.GetValue();
                Assert.True(s.Length == 3);
                Assert.True(Regex.IsMatch(s, "^a [a-z]$"));
                chars.Add(s[2]);
            }

            Assert.Equal(26, chars.Count);
        }
        public void StringPatternGenerator_a()
        {
            HashSet<char> chars = new HashSet<char>();

            var sut = new PatternGenerator("{a}");
            for (int n = 0; n < 10000; n++)
            {
                var s = sut.GetValue();
                Assert.IsTrue(s.Length == 1);
                Assert.IsTrue(Regex.IsMatch(s, "^[a-z]$"));
                chars.Add(s[0]);
            }

            Assert.AreEqual(26, chars.Count, "Should have all a..z");
        }