/// <summary>
        /// MatchMismatchToMarkCutDown calculates the mark cutdown for a mismatch between
        /// two squares represented by their indices.
        /// </summary>
        /// <param name="numberOfHighlightedSquares">Number of highlighted squares</param>
        /// <param name="answerIndex">Index of correct square</param>
        /// <param name="recallIndex">Index of wrongly recalled square</param>
        /// <param name="highlightedSquares">Highlighted square sequence</param>
        /// <param name="recalledSquares">Recalled square dequence</param>
        /// <returns>mark cutdown</returns>
        private static int MatchMismatchToMarkCutDown(
            int answerIndex,
            int recallIndex,
            List <IndexAndPosition> highlightedSquares,
            List <IndexAndPosition> recalledSquares)
        {
            int numberOfHighlightedSquares = highlightedSquares.Count;

            // Get the position for answerIndex
            Position2D answerPos = MatchIndexToPositionFromAnswer(answerIndex, highlightedSquares);

            // Get the position for recallIndex
            Position2D recallPos = MatchIndexToPositionFromRecall(recallIndex, recalledSquares);

            double distance = Position2D.Distance2D(answerPos, recallPos);

            int costOfMismatch = 8 + (int)(distance / 40);

            // Make sure cost of mismatch < cost of gap
            int costOfGap = MatchGapToMarkCutDown(numberOfHighlightedSquares);

            if (costOfMismatch < costOfGap)
            {
                return(costOfMismatch);
            }
            else
            {
                return(costOfGap);
            }
        }
Пример #2
0
            public void WHEN_UsingDistance2DOrigintoQ1_THEN_DistanceIsWithinMargin()
            {
                testPosition2D1 = new Position2D(0, 0);
                testPosition2D2 = new Position2D(1, 1);

                double expectedDistance = Position2D.Distance2D(testPosition2D1, testPosition2D2);
                double actualDistance   = 1.414214;

                Assert.IsTrue(Math.Abs(actualDistance - expectedDistance) < distance2DMarginOfError, "Exceeded margin of error");
            }
Пример #3
0
            public void WHEN_UsingDistance2DOnTheSamePoints_THEN_Distanceis0()
            {
                testPosition2D1 = new Position2D(0, 0);
                testPosition2D2 = new Position2D(0, 0);

                double expectedDistance = Position2D.Distance2D(testPosition2D1, testPosition2D2);
                double actualDistance   = 0;

                Assert.IsTrue(Math.Abs(expectedDistance - actualDistance) <= distance2DMarginOfError);
            }
Пример #4
0
        /// <summary>
        /// Calculates the pointinging score of a player in the Balloons mini-game
        /// by taking the average of the player's time to click, distance of
        /// successful click, number of clicks in a round, and the size of the
        /// successful click
        /// </summary>
        /// <returns>The pointinging score of the player in the Balloons mini-game.
        /// </returns>
        /// <remarks>The returned value is ≥ 0.</remarks>
        public static void EvaluateBalloonsScore()
        {
            double     balloonClickScore             = 0;
            double     balloonDistanceScore          = 0;
            double     multipleClicksScore           = 0;
            double     balloonSuccessClickScore      = 0;
            double     distanceFromCenter            = 0;
            double     balloonRoundsPlayedMultiplier = 0;
            Position2D destinationPoint;
            Position2D clickPosition;
            int        numberOfRounds = balloonsData.Rounds.Count;

            // Evaluate the score based on round record:
            foreach (BalloonsRound balloonsRound in balloonsData.Rounds)
            {
                balloonDistanceScore = 0;
                // Calculate score depending on amount of time it took to click on the balloon
                balloonClickScore = MatchDestinationClickTimeToScoreBalloons(balloonsRound.DestinationClickTime);

                // Calculate score depending on number of clicks before successful click
                multipleClicksScore = MatchMultipleClicksToScore(balloonsRound.Clicks.Count + 1);

                // x,y position of center of destination balloon
                destinationPoint = balloonsRound.DestinationPoint;
                // x,y, position of clickPosition set to successful click position
                clickPosition = balloonsRound.SuccessClickPoint;
                // Calculate score depending on the distance that the successful click was from the center of the balloon
                distanceFromCenter = Position2D.Distance2D(clickPosition, destinationPoint);
                // Add score to balloonDistanceScore
                balloonDistanceScore += MatchDistanceToScore(distanceFromCenter);

                // Calculate score depending on the distance of unsuccessful clicks were from the center of the balloon
                foreach (TimeAndPosition unsuccessfulClick in balloonsRound.Clicks)
                {
                    // x,y position of unsuccessfulclick
                    clickPosition         = unsuccessfulClick.Position;
                    distanceFromCenter    = Position2D.Distance2D(clickPosition, destinationPoint);
                    balloonDistanceScore += MatchDistanceToScore(distanceFromCenter);
                }

                // Find the average distance score
                balloonDistanceScore = balloonDistanceScore / (balloonsRound.Clicks.Count + 1);

                // Find the average of balloonClickScore, balloonDistanceScore and multipleClicksScore
                balloonSuccessClickScore += (balloonDistanceScore + multipleClicksScore + balloonClickScore) / 3;
            }

            if (numberOfRounds == 0)
            {
                balloonsScore = 0;
            }

            else
            {
                // Calculate the average score in the entire game
                if (numberOfRounds == 0)
                {
                    balloonClickScore = 0;
                }
                else
                {
                    balloonsScore = (int)(balloonSuccessClickScore / numberOfRounds);
                }

                // To ensure that the player has a consistent and accurate score,
                // Their current score is multiplied by a value depending on the number of rounds played
                balloonRoundsPlayedMultiplier = MatchRoundsPlayedToScore(numberOfRounds);
                balloonsScore = (int)(balloonsScore * balloonRoundsPlayedMultiplier);
            }

            // Update the subScore record for (Flciking, Balloons):
            UpdateSubScoreForBalloons();
        }