public WandTracker()
        {
            this.positions  = new List <Position>();
            this.decomposer = new StrokeDecomposer(1023, 1023, 4);
            this.brain      = new Brain();

            spells = new List <Spell>();
        }
Exemple #2
0
        public WandTracker()
        {
            this.positions  = new List <Position>();
            this.decomposer = new StrokeDecomposer(1023, 1023, 4);
            this.brain      = new Brain();

            spells = new List <Spell>();

            /*
             * StrokeDecomposerTest test = new StrokeDecomposerTest();
             * if (!test.testDetermineStroke())
             * {
             *  throw new Exception("testDetermineStroke failed!");
             * }
             * else
             * {
             *  Console.WriteLine("testDetermineStroke passed");
             * }
             */
        }
        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);
        }
        public Boolean testDetermineStroke()
        {
            Boolean pass = true;

            List <StrokeDirection> strokes = new List <StrokeDirection>();

            strokes.Add(StrokeDirection.Bumbled);

            List <StrokeDirection> toMatch = new List <StrokeDirection>();

            toMatch.Add(StrokeDirection.Right);
            pass = pass && !StrokeDecomposer.strokesMatch(strokes, toMatch);

            strokes.Clear();
            strokes.Add(StrokeDirection.Bumbled);
            strokes.Add(StrokeDirection.Right);
            pass = pass && StrokeDecomposer.strokesMatch(strokes, toMatch);

            strokes.Clear();
            strokes.Add(StrokeDirection.Bumbled);
            strokes.Add(StrokeDirection.Left);
            pass = pass && !StrokeDecomposer.strokesMatch(strokes, toMatch);

            strokes.Clear();
            strokes.Add(StrokeDirection.Right);
            pass = pass && StrokeDecomposer.strokesMatch(strokes, toMatch);

            strokes.Clear();
            strokes.Add(StrokeDirection.Bumbled);
            strokes.Add(StrokeDirection.Right);
            strokes.Add(StrokeDirection.Bumbled);
            pass = pass && StrokeDecomposer.strokesMatch(strokes, toMatch);

            strokes.Clear();
            strokes.Add(StrokeDirection.Bumbled);
            strokes.Add(StrokeDirection.Left);
            strokes.Add(StrokeDirection.Right);
            strokes.Add(StrokeDirection.Bumbled);
            pass = pass && StrokeDecomposer.strokesMatch(strokes, toMatch);

            toMatch.Clear();
            toMatch.Add(StrokeDirection.UpToTheRight);
            toMatch.Add(StrokeDirection.DownToTheRight);
            toMatch.Add(StrokeDirection.Left);

            strokes.Clear();
            strokes.Add(StrokeDirection.Bumbled);
            strokes.Add(StrokeDirection.Right);
            pass = pass && !StrokeDecomposer.strokesMatch(strokes, toMatch);

            strokes.Clear();
            strokes.Add(StrokeDirection.Bumbled);
            strokes.Add(StrokeDirection.UpToTheRight);
            strokes.Add(StrokeDirection.DownToTheRight);
            strokes.Add(StrokeDirection.Left);
            pass = pass && StrokeDecomposer.strokesMatch(strokes, toMatch);

            strokes.Clear();
            strokes.Add(StrokeDirection.UpToTheRight);
            strokes.Add(StrokeDirection.DownToTheRight);
            strokes.Add(StrokeDirection.Left);
            pass = pass && StrokeDecomposer.strokesMatch(strokes, toMatch);

            strokes.Clear();
            strokes.Add(StrokeDirection.UpToTheRight);
            strokes.Add(StrokeDirection.DownToTheRight);
            strokes.Add(StrokeDirection.Right);
            pass = pass && !StrokeDecomposer.strokesMatch(strokes, toMatch);

            strokes.Clear();
            strokes.Add(StrokeDirection.Up);
            strokes.Add(StrokeDirection.Left);
            strokes.Add(StrokeDirection.UpToTheRight);
            strokes.Add(StrokeDirection.DownToTheRight);
            strokes.Add(StrokeDirection.Left);
            strokes.Add(StrokeDirection.UpToTheRight);
            strokes.Add(StrokeDirection.Down);
            pass = pass && StrokeDecomposer.strokesMatch(strokes, toMatch);

            strokes.Clear();
            strokes.Add(StrokeDirection.Up);
            strokes.Add(StrokeDirection.Left);
            strokes.Add(StrokeDirection.UpToTheRight);
            strokes.Add(StrokeDirection.Bumbled);
            strokes.Add(StrokeDirection.DownToTheRight);
            strokes.Add(StrokeDirection.Bumbled);
            strokes.Add(StrokeDirection.Left);
            strokes.Add(StrokeDirection.UpToTheRight);
            strokes.Add(StrokeDirection.Down);
            pass = pass && StrokeDecomposer.strokesMatch(strokes, toMatch);

            return(pass);
        }