Example #1
0
        private void MeasureLength(GamePosition v, List <GamePosition> ret)
        {
            var winValue = v.Value;

            for (int i = 0; i < 4; i++)
            {
                var dirPos = v;
                var dirNeg = v.MoveInverted((DirectionEnum)i);
                var dirArr = new List <GamePosition>();

                while (FindPointValue(dirPos) == winValue)
                {
                    dirArr.Add(dirPos);
                    dirPos = dirPos.Move((DirectionEnum)i);
                }

                while (FindPointValue(dirNeg) == winValue)
                {
                    dirArr.Add(dirNeg);
                    dirNeg = dirNeg.MoveInverted((DirectionEnum)i);
                }

                if (dirArr.Count() > ret.Count())
                {
                    ret.Clear();
                    ret.AddRange(dirArr);
                }
            }
        }
Example #2
0
        public IList <GamePosition> AddPoint(GamePosition v)
        {
            var ret = new List <GamePosition>();

            if (FindPoint(v) == null)
            {
                Points.Add(v);
                MeasureLength(v, ret);
            }
            return(ret);
        }
Example #3
0
        public int FindPointValue(GamePosition pos)
        {
            var ret   = 0;
            var point = FindPoint(pos);

            if (point != null)
            {
                ret = point.Value;
            }
            return(ret);
        }
Example #4
0
 public GamePosition FindPoint(GamePosition pos)
 {
     return(Points.FirstOrDefault(d => d.Match(pos)));
 }
Example #5
0
 internal bool Match(GamePosition pos)
 {
     return(X == pos.X && Y == pos.Y);
 }