Ejemplo n.º 1
0
        public override int Foresee(IntField image, int x, int y)
        {
            pattern horzProbe = findPattern(image, x - _horzLookback, y - _horzThickness + 1, _horzLookback, _horzThickness);
            pattern vertProbe = findPattern(image, x - _vertThickness + 1, y - _vertLookback, _vertThickness, _vertLookback);

            if (horzProbe == pattern.Dirty && vertProbe == pattern.Dirty)
            {
                return(MostFrequentForeseer.MostFrequent(image, x, y, _freqThickness, _freqThickness));
            }

            bool haveH = horzProbe == pattern.CleanHorz || vertProbe == pattern.CleanHorz;
            bool haveV = horzProbe == pattern.CleanVert || vertProbe == pattern.CleanVert;

            if (haveH && !haveV)
            {
                return(MostFrequentForeseer.MostFrequent(image, x, y, _horzLookback, _horzThickness));
            }
            if (haveV && !haveH)
            {
                return(MostFrequentForeseer.MostFrequent(image, x, y, _vertThickness, _vertLookback));
            }

            if (horzProbe == pattern.Solid)
            {
                return(MostFrequentForeseer.MostFrequent(image, x, y, _horzLookback, _horzThickness));
            }
            else
            {
                return(MostFrequentForeseer.MostFrequent(image, x, y, _vertThickness, _vertLookback));
            }
        }
Ejemplo n.º 2
0
        public static void generatePatterns(int len)
        {
            towers = new tower[brickCombinations[len]];
            int i = 0;

            foreach (string s in brickPatterns[len])
            {
                pattern p = new pattern();
                p.layout = s;
                p.length = s.Length;
                p.cracks = new int[p.length - 1];
                int l = 0;
                foreach (char c in s)
                {
                    if (l == s.Length - 1)
                    {
                        continue;
                    }
                    if (l == 0)
                    {
                        p.cracks[l] = (int)Char.GetNumericValue(c);
                    }
                    else
                    {
                        p.cracks[l] = (int)Char.GetNumericValue(c) + p.cracks[l - 1];
                    }
                    l++;
                }
                towers[i].pattern = p;
                towers[i].amount  = 1;
                i++;
            }

            generateStates(len);
        }
Ejemplo n.º 3
0
 void Start()
 {
     tform      = player.GetComponent <Transform>();
     spawning   = pattern_obj.gameObject.GetComponent <pattern>();
     End        = ui_End.gameObject.GetComponent <End>();
     best_score = score_manager.LoadScore();
 }
Ejemplo n.º 4
0
        private void GetNeedlesFromPatternId()
        {
            string url         = "https://api.ravelry.com/patterns/";
            string json        = ".json";
            var    patternList = from a in db.patterns select a;

            foreach (pattern p in patternList.ToList <pattern>())
            {
                var            newUrl  = url + p.id + json;
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(newUrl);
                request.Method      = "GET";
                request.ContentType = "application/json";
                request.Headers["Authorization"] = "Basic " + Convert.ToBase64String(Encoding.Default.GetBytes("A557BB258D37DE039AC3:VVaoS9R2Lvwhy_ToXF9AtyyBN9czTkD8IyTK7bvU"));

                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                using (Stream responseStream = response.GetResponseStream())
                {
                    StreamReader         reader = new StreamReader(responseStream, Encoding.UTF8);
                    JavaScriptSerializer js     = new JavaScriptSerializer();
                    var obj = js.Deserialize <dynamic>(reader.ReadToEnd());

                    pattern _pattern     = new pattern();
                    var     needle_sizes = obj["pattern"]["pattern_needle_sizes"];
                    {
                        if (needle_sizes != null)
                        {
                            //want to get all potential needles
                            foreach (var needle_size in needle_sizes)
                            {
                                var _pattern_needle_size = new pattern_needle_size();
                                _pattern_needle_size.pattern_id     = p.id;
                                _pattern_needle_size.needle_size_id = needle_size["id"];

                                var needle_id = needle_size["id"];

                                if (db.pattern_needle_size.Any(x => x.needle_size_id == _pattern_needle_size.needle_size_id && x.pattern_id == p.id))
                                {
                                }
                                else
                                {
                                    db.pattern_needle_size.Add(_pattern_needle_size);
                                    try
                                    {
                                        db.SaveChanges();
                                    }
                                    catch (DbUpdateException ex)
                                    {
                                        string test = ex.Message;
                                        throw;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 5
0
 public static bool overlapsCracks(pattern a, pattern b)
 {
     foreach (int i in a.cracks)
     {
         foreach (int j in b.cracks)
         {
             if (i == j)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
        public object[] findAllInRangeSync (pattern, range)
        {
            var ignoreCase = false;
            var unicode = false;

            if (pattern.source)
            {
                ignoreCase = pattern.flags.includes('i');
                unicode = pattern.unicode;
                pattern = pattern.source;
            }

            const result = findAllSync.call(this, pattern, ignoreCase, unicode, range)
          if (typeof result === 'string')
            {
                throw new Error(result);
            }
        private static IEnumerable<ReportEntry> ProcessRule(XDocument docToValidate, rule rule,
            XmlNamespaceManager namespaceManager,
            pattern pattern, string phase)
        {
            var result = new List<ReportEntry>();
            XElement ruleRoot = null;
            if (!string.IsNullOrEmpty(rule.context))
            {
                if (rule.context == "/" && docToValidate.Document != null)
                    ruleRoot = docToValidate.Document.Root;
                else
                    ruleRoot = docToValidate.XPathSelectElement(rule.context, namespaceManager);
            }
            result.AddRange(ProcessRuleRoot(rule, ruleRoot, namespaceManager, rule.context, phase));

            if (rule.extends != null && !string.IsNullOrEmpty(rule.extends.rule))
            {
                foreach (rule subRule in pattern.rule.Where(r => r.@abstract && r.id == rule.extends.rule))
                {
                    result.AddRange(ProcessRuleRoot(subRule, ruleRoot, namespaceManager, rule.context, phase));
                }
            }
            return result;
        }
Ejemplo n.º 8
0
 _regex = new Regex(pattern, RegexOptions.Compiled);
Ejemplo n.º 9
0
 public Tracker(double X, double Y, pattern flightPath) : base(X, Y, flightPath)
 {
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Creates a new RegExp object from a regular expression pattern and flags.
 /// </summary>
 /// <param name="pattern">The pattern string of the regular expression.</param>
 /// <param name="flags">The flags for the regular expression this must be a string which may
 /// contain one or more of the following characters: m, i, g, x or s.</param>
 ///
 /// <remarks>
 /// <para>The characters in the <paramref name="flags"/> string are interpreted as
 /// follows:</para>
 /// <list type="bullet">
 /// <item><description>m (multiline): If this is set, the '^' and '$' characters in the pattern matches the
 /// beginning and end of lines in the target string respectively, instead of the beginning and
 /// end of the entire string.</description></item>
 /// <item><description>i (ignoreCase): If this is set, any alphabetic character in the pattern string
 /// matches both its uppercase and lowercase forms in the target string.</description></item>
 /// <item><description>
 /// g (global): If this is set, the
 /// <see cref="ASString.match(String, ASAny)" qualifyHint="true"/> method of the String
 /// class returns an array of all matches of the regular expression in the target string
 /// instead of only the first match, the
 /// <see cref="ASString.replace(String, ASAny, ASAny)" qualifyHint="true"/> method of the
 /// String class replaces all matches of the regular expression in the target string instead
 /// of replacing only the first match, and the <see cref="exec"/> method
 /// will set the <see cref="lastIndex"/> property to the index of the character immediately
 /// after the matched substring. All other native methods that accept RegExp arguments do not
 /// use this flag.
 /// </description></item>
 /// <item><description>s (dotall): If this is set, the '.' character in the pattern string matches any
 /// character in the target string, including newlines. If this is not set, the dot character
 /// does not match newlines.</description></item>
 /// <item><description>
 /// x (extended): If this is set, any white space and/or new lines in the pattern string are
 /// ignored; except in character classes, when escaped with a backslash, inside the curly
 /// braces of numeric quantifiers and before, in between or after the special character(s)
 /// that occur after the '(' in a special group construct (such as <c>'(?=...)'</c>).
 /// </description></item>
 /// </list>
 /// </remarks>
 public ASRegExp(string pattern, string flags = "") => _init(pattern, flags);
Ejemplo n.º 11
0
 void Start()
 {
     CommenView_img = CommenView.GetComponent <Image>();
     //  SKill1_CommenView_img = skill1CommenView.GetComponent<Image>();
     patterns = transform.GetComponent <pattern>();
 }
Ejemplo n.º 12
0
        public static Entity Deserialize(string code, string type, GameController game)
        {
            string[] des    = code.Split(',');
            Entity   result = null;

            if (type == "enemy")
            {
                if (des[0] == "bullet")
                {
                    result = new Bullet(Convert.ToDouble(des[1]), Convert.ToDouble(des[2]));
                    (result as Bullet).direction = -1;
                    return(result);
                }
                else if (des[0] == "asteroid")
                {
                    result = new Asteroid(Convert.ToDouble(des[2]), Convert.ToDouble(des[3]));
                    (result as Asteroid).health = Convert.ToInt32(des[1]);
                    return(result);
                }
                else if (des[0] == "formation")
                {
                    pattern flight = pattern.Straight;
                    foreach (pattern val in Enum.GetValues(typeof(pattern)))
                    {
                        if (des[3] == val.ToString())
                        {
                            flight = val;
                            break;
                        }
                    }

                    return(new Formation(Convert.ToDouble(des[1]), Convert.ToDouble(des[2]), flight));
                }
                else if (des[0] == "ai")
                {
                    result = new AI(Convert.ToDouble(des[1]), Convert.ToDouble(des[2]), pattern.Straight);
                    return(result);
                }
                else if (des[0] == "mine")
                {
                    result = new Mine(Convert.ToDouble(des[1]), Convert.ToDouble(des[2]), pattern.Straight);
                    return(result);
                }
                else if (des[0] == "tracker")
                {
                    result = new Tracker(Convert.ToDouble(des[1]), Convert.ToDouble(des[2]), pattern.Straight);
                    return(result);
                }
                else if (des[0] == "powerup")
                {
                    PowerUp p = PowerUp.Empty;
                    foreach (PowerUp val in Enum.GetValues(typeof(PowerUp)))
                    {
                        if (des[3] == val.ToString())
                        {
                            p = val;
                            break;
                        }
                    }
                    result = new Powerup(Convert.ToDouble(des[1]), Convert.ToDouble(des[2]), p);
                }
                else if (des[0] == "boss")
                {
                }
                else
                {
                    throw new Exception("Enemy type Unknown.");
                }
            }
            else if (type == "player")
            {
                result = new Player(Convert.ToDouble(des[0]), Convert.ToDouble(des[1]), Convert.ToInt32(des[3]), Convert.ToInt32(des[4]), game, "SHIP_IMAGE");



                foreach (PowerUp val in Enum.GetValues(typeof(PowerUp)))
                {
                    if (des[2] == val.ToString())
                    {
                        (result as Player).powerup = val;
                        break;
                    }
                }

                if (des[5] == "True")
                {
                    (result as Player).isPoweredUp = true;
                }
                else
                {
                    (result as Player).isPoweredUp = false;
                }

                if (des[7] == "True")
                {
                    (result as Player).cheating = true;
                }
                else
                {
                    (result as Player).cheating = false;
                }

                (result as Player).powerUpCounter = Convert.ToDouble(des[6]);
            }
            else if (type == "playerBullet")
            {
                result = new Bullet(Convert.ToInt32(des[1]), Convert.ToInt32(des[2]));
                (result as Bullet).direction = 1;
                return(result);
            }
            return(result);
        }
Ejemplo n.º 13
0
        public static Entity Deserialize(string code, string type, GameController game)
        {
            string[] des    = code.Split(',');
            Entity   result = null;

            if (type == "enemy")
            {
                if (des[0] == "bullet")
                {
                    result = new Bullet(Convert.ToInt32(des[1]), Convert.ToInt32(des[2]));
                    (result as Bullet).direction = -1;
                    return(result);
                }
                else if (des[0] == "asteroid")
                {
                    result = new Asteroid(Convert.ToInt32(des[2]), Convert.ToInt32(des[3]));
                    (result as Asteroid).health = Convert.ToInt32(des[1]);
                    return(result);
                }
                else if (des[0] == "formation")
                {
                }
                else if (des[0] == "boss")
                {
                }
                else if (des[0] == "powerup")
                {
                }
                else if (des[0] == "ai")
                {
                    pattern flight = pattern.Straight;
                    if (des[3] == "Cos")
                    {
                        flight = pattern.Cos;
                    }
                    else if (des[3] == "Sin")
                    {
                        flight = pattern.Sin;
                    }
                    else if (des[3] == "Tan")
                    {
                        flight = pattern.Tan;
                    }
                    else if (des[3] == "Straight")
                    {
                        flight = pattern.Straight;
                    }

                    result = new AI(Convert.ToInt32(des[1]), Convert.ToInt32(des[2]), flight);
                    return(result);
                }
                else
                {
                    throw new Exception("Enemy type Unknown.");
                }
            }
            else if (type == "player")
            {
                result = new Player(Convert.ToInt32(des[0]), Convert.ToInt32(des[1]), Convert.ToInt32(des[3]), Convert.ToInt32(des[4]), game);
                if (des[2] == "Power")
                {
                    (result as Player).powerup = powerup.Power;
                }
            }
            else if (type == "playerBullet")
            {
                result = new Bullet(Convert.ToInt32(des[1]), Convert.ToInt32(des[2]));
                (result as Bullet).direction = 1;
                return(result);
            }
            return(result);
        }
Ejemplo n.º 14
0
 foreach (var matchResult in Match(pattern, original))
 {
     return(ToSingle(SymbolSubstitute(value, matchResult.Context.Captures)));
Ejemplo n.º 15
0
 public Formation(double X, double Y, pattern f) : base(X, Y, f)
 {
     this.original_Y = Y;
     this.Flightpath = f;
 }
Ejemplo n.º 16
0
 array = LoadSections(pattern, extend);
Ejemplo n.º 17
0
 foreach (var(pattern, result) in patterenMap)
Ejemplo n.º 18
0
 public Tracker(Point location, pattern flightPath) : base(location, flightPath)
 {
 }
Ejemplo n.º 19
0
 public Formation(Point location, pattern passFlight) : base(location, passFlight)
 {
     this.original_Y = loc.Y;
     Flightpath      = passFlight;
 }
Ejemplo n.º 20
0
 public AI(Point location, pattern passFlight) : base(location)
 {
     Flightpath = passFlight;
 }
Ejemplo n.º 21
0
 public Mine(double X, double Y, pattern flightPath) : base(X, Y, flightPath)
 {
     velocity = new Vector(1, 1);
     maxSpeed = 2.5f;
 }
Ejemplo n.º 22
0
 Regex : new Regex(pattern, RegexOptions.CultureInvariant | RegexOptions.Compiled | RegexOptions.Multiline),
Ejemplo n.º 23
0
 public AI(double X, double Y, pattern flightpath) : base(X, Y)
 {
 }
Ejemplo n.º 24
0
 public object[] findSync (pattern, range)
 {
     return this.findInRangeSync(pattern, DEFAULT_RANGE)
 }
Ejemplo n.º 25
0
        //  List<int> vec_bs;

        public Room()
        {
            thepattern = new pattern();
            // thepattern.vec_bs = new List<int>(10000);
            // thepattern.vec_bs = new List<int>(5*16*10);
            thepattern.vec_bs  = new List <int>(5 * 16 * 10);
            thepattern.int_bnk = new List <int>(10);
            thepattern.int_prg = new List <int>(10);

            thepattern.int_vs  = new List <int>(10);
            thepattern.int_sl2 = new List <int>(10);


            for (int i = 0; i < 10; i++)
            {
                thepattern.int_vs.Add(0);
                thepattern.int_sl2.Add(0);
                thepattern.int_bnk.Add(0);
                thepattern.int_prg.Add(0);
            }

            for (int i = 0; i < (5 * 16 * 10); i++)
            {
                // Debug.WriteLine("LOOP" + i);
                thepattern.vec_bs.Add(0);
                //  thepattern.vec_bs.Add(0);
            }



            uniformGrid1.Columns       = 16;
            uniformGrid1.Rows          = 5;
            uniformGrid1.ColumnSpacing = 4;
            uniformGrid1.RowSpacing    = 4;
            uniformGrid1.Orientation   = Orientation.Horizontal;

            uniformGrid2.Columns = 3;
            uniformGrid2.Rows    = 1;

            uniformGrid2.ColumnSpacing = 4;
            uniformGrid2.RowSpacing    = 4;
            uniformGrid2.Orientation   = Orientation.Horizontal;

            uniformGrid1.Visibility = Visibility.Collapsed;
            uniformGrid2.Visibility = Visibility.Collapsed;


            for (int i = 0; i < 5; i++)
            {
                for (int j = 0; j < 16; j++)
                {
                    {
                        bu[i, j] = new MyToggle();
                        //bu[i, j].Background = new SolidColorBrush(Windows.UI.Colors.DarkBlue);
                        // bu[i, j].Content = "T";
                        //   bu[i, j].Click += HandleButtonClick;
                        bu[i, j].Checked   += HandleToggleButtonChecked;
                        bu[i, j].Unchecked += HandleToggleButtonUnChecked;
                        // bu[i, j].Tag = i;
                        //bool isOver = bu[i, j].IsPointerOver;

                        clientDict.Add(bu[i, j], new Tuple <int, int>(i, j));
                        bu[i, j].HorizontalAlignment = HorizontalAlignment.Stretch;
                        bu[i, j].VerticalAlignment   = VerticalAlignment.Stretch;
                        bu[i, j].IsThreeState        = false;
                        // b.IsThreeState = true;
                        uniformGrid1.Children.Add(bu[i, j]);
                    }
                }
            }
            bu[1, 1].state = 1;
            bu[1, 1].update();

            for (int i = 0; i < 3; i++)
            {
                slider[i]        = new Slider();
                slider[i].Header = "Volume";
                slider[i].Width  = 600;
                // slider[i].Height = 1000;
                sliderclientDict.Add(slider[i], i);
                slider[i].Orientation         = Orientation.Vertical;
                slider[i].HorizontalAlignment = HorizontalAlignment.Stretch;
                slider[i].VerticalAlignment   = VerticalAlignment.Stretch;

                slider[i].ValueChanged += Slider_ValueChanged;
                uniformGrid2.Children.Add(slider[i]);
            }
            //for (int i = 0; i < 2; i++) {
            //    prgButton[i] = new Button();
            //prgButton[i].HorizontalAlignment = HorizontalAlignment.Stretch;
            //prgButton[i].VerticalAlignment = VerticalAlignment.Stretch;
            //prgButton[i].Click += HandleprgButtonClicked;
            ////   saveSlot[i].Unchecked += HandleChannelSelUnChecked;
            //prgButton[i].Tag = i;
            //    //
            //    bnkButton[i] = new Button();
            //    bnkButton[i].HorizontalAlignment = HorizontalAlignment.Stretch;
            //    bnkButton[i].VerticalAlignment = VerticalAlignment.Stretch;
            //    bnkButton[i].Click += HandlebnkButtonClicked;
            //    //   saveSlot[i].Unchecked += HandleChannelSelUnChecked;
            //    bnkButton[i].Tag = i;

            //}
        }
Ejemplo n.º 26
0
 public PatternTextTemplateCheck(string pattern) => _regex = new Regex(pattern, RegexOptions.Compiled);
Ejemplo n.º 27
0
 foreach (var(pattern, value) in rules)
Ejemplo n.º 28
0
 at is InnerLocation inner?this.TryMatch(pattern, inner)
     : Enumerable.Empty <(RegexMatch, Location, Location)>();
Ejemplo n.º 29
0
 Init(pattern, RegexOptions.None, s_defaultMatchTimeout, addToCache : false);
Ejemplo n.º 30
0
        public double original_X; // x value when the bullet is made

        //constructor to set up pattern and get inital position
        public Wandering_Bullet(double X, double Y, pattern path) : base(X, Y)
        {
            this.path  = path;
            original_Y = Y;
            original_X = X;
        }
Ejemplo n.º 31
0
 Assert.AreEqual(result, m.Eval(pattern, correct));
Ejemplo n.º 32
0
 new return Regex(pattern);