Example #1
0
    private void InitializeAI(BetAmount betAmount)
    {
        AIUnit ai = ai_units.Find(p => (p.m_BetAmount == betAmount));

        mInfo = new List <QuestionAnswerInfo>();

        int correctNum = Random.Range(ai.m_QuestionToAnswer.MinQuestionsToBeAnswered, ai.m_QuestionToAnswer.MaxQuestionsToBeAnswered + 1);

        int TimeToAnswer = 0;

        for (int i = 0; i < MULTIPLAYER_QUESTION_NUMBER; i++)
        {
            QuestionAnswerInfo tInfo = new QuestionAnswerInfo();

            int answerInWithin = Random.Range(ai.MinTimeToAnswer, ai.MaxTimeToAnswer);

            tInfo.AnsweredInTime = answerInWithin;

            TimeToAnswer = (i == 0) ? maxAllowedTime - answerInWithin : TimeToAnswer - answerInWithin;

            tInfo.TimeToAnswerQuestion = TimeToAnswer;//UnityEngine.Random.Range(ai.MinTimeToAnswer, ai.MaxTimeToAnswer);

            mInfo.Add(tInfo);
        }

        FisherYatesShuffle obj = new FisherYatesShuffle(5);

        obj.ShuffleList();
        List <int> correctIndex = obj.ShuffledList;

        for (int i = 0; i < correctNum; i++)
        {
            mInfo[correctIndex[i]].isCorrectAnswer = true;
        }
    }
Example #2
0
        public void TestShuffle()
        {
            FisherYatesShuffle fisherYatesShuffle = new FisherYatesShuffle(N, StartFrom);

            PrintIntegerList(fisherYatesShuffle.ShuffledList);
            fisherYatesShuffle.ShuffleList();
            PrintIntegerList(fisherYatesShuffle.ShuffledList);
        }
Example #3
0
    public BaseQuestion GetUIQuestion(int questionIndex, int answerButtons = 4)
    {
        ConfusionTouch questionType = ConfusionTouchList[questionIndex];

        AnswerInfos.Clear();

        CurrentColorID = AnswerID.None;

        int colors = EnumUtil.GetValues <ColorEnum>().Count;

        //Initializing a Question
        BaseQuestion bq = new BaseQuestion();

        bq.IgnoreClickCount       = true;
        bq.IgnoreClickTime        = true;
        bq.HasSequenceAnswer      = false;
        bq.HasBoolValue           = false;
        bq.HasTimerValue          = true;
        bq.HasSequentialQuestions = true;
        bq.Pattern         = QPattern.ConfusionTouch;
        bq.QuestionType    = QuestionType.Base;
        bq.TimeForQuestion = 0;
        bq.Options         = new List <AnswerSpriteHolder>();
        for (int i = 0; i < answerButtons; i++)
        {
            AnswerSpriteHolder answer = new AnswerSpriteHolder();
            bq.Options.Add(answer);
        }
        //

        //Getting a random color for the question
        int randomColorIndex = (int)Random.Range(0, colors);

        //Shuffle
        FisherYatesShuffle shuffle = new FisherYatesShuffle(colors);

        shuffle.ShuffleList();
        List <int> colorIndex = shuffle.ShuffledList;

        //Setting up button info for later assignment and setting up current answerID Color for the current question
        for (int i = 0; i < answerButtons; i++)
        {
            ConfusionTouchAnswerInfo answerInfo = GetNewAnswerButton();
            AnswerInfos.Add(answerInfo);
        }

        SetAnswerForQuestion();
        SetAnswerID((ColorEnum)randomColorIndex);

        //Assignment to answer buttons
        SetAnswerOption(ref bq, (ColorEnum)randomColorIndex, questionType);

        return(bq);
    }
Example #4
0
    private void Shuffle <T>(ref T[] iArray)
    {
        FisherYatesShuffle shuffle = new FisherYatesShuffle(iArray.Length, 0);

        shuffle.ShuffleList();
        List <int> shuffleList  = shuffle.ShuffledList;
        List <T>   shuffledList = new List <T>();

        for (int i = 0; i < shuffleList.Count; i++)
        {
            shuffledList.Add(iArray[shuffleList[i]]);
        }
        iArray = shuffledList.ToArray();
    }
Example #5
0
    private void Shuffle <T>(ref List <T> ilist)
    {
        FisherYatesShuffle shuffle = new FisherYatesShuffle(ilist.Count, 0);

        shuffle.ShuffleList();
        List <int> shuffleList  = shuffle.ShuffledList;
        List <T>   shuffledList = new List <T>();

        for (int i = 0; i < shuffleList.Count; i++)
        {
            shuffledList.Add(ilist[shuffleList[i]]);
        }
        ilist = shuffledList;
    }