public void ComplexEntropyTest()
 {
     var knowledgeBase = new Dictionary<string, AnswerStatistic>
         {
             {
                 "1", new AnswerStatistic
                     {
                         AnswerCount = 1,
                         AnsweredQuestionsById = new Dictionary<string, QuestionStatistic>
                             {
                                 {"1", new QuestionStatistic {ChoicesFrequencies = new[] {1, 5, 1, 1}}},
                                 {"2", new QuestionStatistic {ChoicesFrequencies = new[] {1, 1, 1, 1}}},
                                 {"3", new QuestionStatistic {ChoicesFrequencies = new[] {1, 5, 1, 1}}}
                             }
                     }
             },
             {
                 "2", new AnswerStatistic
                     {
                         AnswerCount = 1,
                         AnsweredQuestionsById = new Dictionary<string, QuestionStatistic>
                             {
                                 {"1", new QuestionStatistic {ChoicesFrequencies = new[] {1, 1, 1, 1}}},
                                 {"2", new QuestionStatistic {ChoicesFrequencies = new[] {5, 1, 1, 1}}},
                                 {"3", new QuestionStatistic {ChoicesFrequencies = new[] {5, 1, 1, 1}}}
                             }
                     }
             }
         };
     var genie = new Genie(knowledgeBase, 4);
     var answeredQuestions = new List<AnsweredQuestion>();
     var nextQuestionId = genie.GetNextQuestionId(answeredQuestions, genie.GetAnswerGuesses(answeredQuestions));
     Assert.AreEqual("3", nextQuestionId);
 }
Exemple #2
0
 public static PlayerState GetPlayerState(HttpSessionStateBase session, Genie genie)
 {
     var state = session[playerStateName];
     if (state == null)
     {
         var answeredQuestions = new List<AnsweredQuestion>();
         var answerGuesses = genie.GetAnswerGuesses(answeredQuestions);
         var currQuestionId = genie.GetNextQuestionId(answeredQuestions, answerGuesses);
         var newState = new PlayerState
             {
                 AnswerGuesses = answerGuesses,
                 AnsweredQuestions = answeredQuestions,
                 CurrentQuestionId = currQuestionId
             };
         session[playerStateName] = newState;
         return newState;
     }
     return (PlayerState) state;
 }
 public void LastQuestionRemainsTest()
 {
     var knowledgeBase = new Dictionary<string, AnswerStatistic>
         {
             {"1", new AnswerStatistic
                 {
                     AnswerCount = 1,
                     AnsweredQuestionsById = new Dictionary<string, QuestionStatistic>
                         {
                             {"1", new QuestionStatistic {ChoicesFrequencies = new[] {5, 1}}},
                             {"2", new QuestionStatistic {ChoicesFrequencies = new[] {1, 1}}}
                         }
                 }}
         };
     var genie = new Genie(knowledgeBase, 2);
     var answeredQuestions = new List<AnsweredQuestion>
         {
             new AnsweredQuestion {Choise = 1, QuestionId = "1"}
         };
     var nextQuestionId = genie.GetNextQuestionId(answeredQuestions, genie.GetAnswerGuesses(answeredQuestions));
     Assert.AreEqual("2", nextQuestionId);
 }