Example #1
0
        public Spell chooseSpell(List<Position> data)
        {
            if (data.Count < 2) return null;

            PositionStatistics stats = new PositionStatistics(data);

            if (stats.Width() < 100 || stats.Height() < 100) return null;

            double xScale = ((double) BRAIN_PIXELS / (stats.Width()));
            double yScale = ((double) BRAIN_PIXELS / (stats.Height()));

            int[] newData = new int[BRAIN_PIXELS * BRAIN_PIXELS];

            for (int i = 0; i < newData.Length; i++)
            {
                newData[i] = 0;
            }

            for (int i = 1; i < data.Count; i++)
            {
                var position = data[i-1];
                int x = scaleCoordinate(position.point.X, stats.xMin, xScale);
                int y = scaleCoordinate(position.point.Y, stats.yMin, yScale);

                var nextPosition = data[i];
                int nextX = scaleCoordinate(nextPosition.point.X, stats.xMin, xScale);
                int nextY = scaleCoordinate(nextPosition.point.Y, stats.yMin, yScale);

                setDataPoint(newData, x, y);
                setDataPoint(newData, nextX, nextY);

                // Set any in-between points
                if (nextX - x != 0)
                {
                    double slope = ((double)nextY - y) / (nextX - x);
                    for (int j = 1; x + j < nextX; j++)
                    {
                        int newX = x + j;
                        int newY = y + ((int)(j * slope));
                        setDataPoint(newData, newX, newY);
                    }
                }

                if (nextY - y != 0)
                {
                    double slope = ((double)nextX - x) / (nextY - y);
                    for (int j = 1; y + j < nextY; j++)
                    {
                        int newY = y + j;
                        int newX = x + ((int)(j * slope));
                        setDataPoint(newData, newX, newY);
                    }
                }
            }

            var spell = calculateSpell(data, newData);

            return spell;
        }
Example #2
0
        protected override bool verifyTrigger(List<Position> positions)
        {
            bool verified = base.verifyTrigger(positions);
            if (verified)
            {
                // Verify that the start and end points are near the bottom, to avoid confusion with Tarantallegra
                var stats = new PositionStatistics(positions);

                if ((Math.Abs(stats.Start().point.Y - stats.yMin) > Math.Abs(stats.Start().point.Y - stats.yMax))
                    || (Math.Abs(stats.End().point.Y - stats.yMin) > Math.Abs(stats.End().point.Y - stats.yMax)))
                {
                    verified = false;
                }
            }

            return verified;
        }
Example #3
0
        protected bool wandIsPaused(List<Position> positions)
        {
            bool paused = false;
            //PositionStatistics stats = new PositionStatistics(positions);
            var lastFive = positions.GetRange(positions.Count - 5, 5);
            var lastFiveStats = new PositionStatistics(lastFive);

            if (lastFiveStats.Diagonal() < 10)
            {
                paused = true;
                //Console.WriteLine("Paused. Diagonal: " + lastFiveStats.Diagonal());
            }
            //paused = true;
            return paused;
        }
Example #4
0
        protected virtual bool verifyTrigger(List<Position> positions)
        {
            PositionStatistics stats = new PositionStatistics(positions);

            StrokeDirection direction = StrokeDecomposer.determineDirection(stats.Start(), stats.End());
            double distance = stats.Diagonal();
            double relativeStartAndEndDistance = stats.FractionOfTotal(stats.Start(), stats.End());

            /*
            if (this.GetType() == typeof(Ascendio))
            {
                Console.WriteLine(
                    "Confidence: " + confidence
                    + " direction: " + direction
                    + " (" + stats.Start().point.ToString() + " -> " + stats.End().point.ToString() + ")"
                    + " distance: " + distance + " (" + relativeStartAndEndDistance + ")");
            }
            */

            bool verified = false;

            foreach (StrokeDirection dir in acceptableDirectionsFromStartToEndPoint)
            {
                if (dir == direction)
                {
                    verified = true;
                }
            }

            verified = verified && confidence >= minConfidence;

            verified = verified && distance >= 400.0;
            verified = verified && (relativeStartAndEndDistance * 100) >= minPercentOfTotalBetweenStartAndEndPoints;
            verified = verified && (relativeStartAndEndDistance * 100) <= maxPercentOfTotalBetweenStartAndEndPoints;

            return verified;
        }