【问题标题】:What kind of algorithm is behind the Akinator game?Akinator 游戏背后的算法是什么样的?
【发布时间】:2012-11-18 22:26:42
【问题描述】:

Akinator app 只需问几个问题就能猜出一个字符,这总是让我感到惊讶。所以我想知道什么样的算法或方法让它做到这一点?这类算法有名称吗?我可以在哪里阅读更多关于它们的信息?

【问题讨论】:

    标签: algorithm statistics machine-learning artificial-intelligence


    【解决方案1】:

    是的,这类算法有一个名称——在machine learning 字段中称为classification algorithmsDecision trees 是分类算法的一个例子。

    在这个分类问题中,算法的特征就是问题的答案。

    可以通过多种方式确定下一个应该问哪个问题 - 例如,尝试最大化下一个问题的预测(或平均值)entropy

    【讨论】:

    • 我会在阿米特的回复中补充一点,你应该不会感到惊讶,很少有问题能够找到这个角色。我看到的屏幕截图有 5 个答案可能性。只问8个问题,就可以区分出8^5 = 2^15 = 32768个字符,足以覆盖绝大多数人想到的字符。
    • @HerrKaputt - 理论上是的,但请记住存在“噪音” - 人们可能会误解或对同一个问题赋予不同的意义(强烈同意/弱同意)。 (这就是为什么简单的二分搜索在这些情况下会失败,您需要更多基于统计的东西,这正是分类算法的目标)
    • @HerrKaputt 排列的数量应该是5^8 而不是8^5,但是,只有两个选项而不是五个。 “不知道”是忽略一个问题,而“可能”的变体只是使“是”和“否”的答案变弱。所以8个问题的排列数只有2^8,也就是256
    • @dualed:我们离话题越来越远了——但没有理由忽略“我不知道”或将“可能”与“是”一样使用。例如,想一想“你的角色有没有建模过”这个问题——“我不知道”的答案将帮助代理识别出你可能不是在谈论Bar Refaeli
    • @amit 我知道这是有原因的,但是在完成“游戏”时的分析部分中,您可以看到 Akinator 实际上确实忽略了“不知道”的答案,并且它只有存储“是”和“否”答案。
    【解决方案2】:

    这个游戏有时被称为20 个问题。上面有一些关于 SO 的问题,例如:

    【讨论】:

      【解决方案3】:

      算法的主要特点:

      • 自学
      • 错误-放纵
      • 下一道题的智能系统选择

      Akinator 博弈算法模型称为“基于模糊逻辑的专家系统”。

      这不是决策树,因为决策树没有容错性。

      前段时间我在C#上写过一篇,你可以通过链接找到它:https://github.com/ukushu/AkinatorEngine

      您可以在 wiki 上阅读更多信息:

      https://en.wikipedia.org/wiki/Expert_system

      https://ru.wikipedia.org/wiki/Экспертная_система

      【讨论】:

        【解决方案4】:

        我不知道 Akinator 到底使用了什么算法,但是在这里我已经开源了一个实现相同效果的算法:https://github.com/srogatch/ProbQA

        基本上我们使用N(Questions) 乘以N(Answer Options) 乘以N(Targets) 的立方体,参见https://github.com/srogatch/ProbQA/blob/master/ProbQA/PqaCore/CpuEngine.decl.h

        我们通过应用带有独立假设的贝叶斯公式来训练立方体,请参阅https://github.com/srogatch/ProbQA/blob/master/ProbQA/PqaCore/CEEvalQsSubtaskConsider.cpp

        由于代码针对 AVX2 和多线程进行了高度优化,因此可能难以阅读。阅读相同的 CUDA 代码可能更容易:https://github.com/srogatch/ProbQA/blob/master/ProbQA/PqaCore/CudaEngineGpu.cu

        此算法的应用程序也可通过website to recommend a game 获得。

        【讨论】:

          【解决方案5】:

          我认为这就像一个专家系统,具有 B-Tree 结构。

          【讨论】:

            【解决方案6】:

            我有一个小项目要为“找到你的品味”构建一个动态测验,我想与你分享:


            const quizData =
            {
              "title": "Quiz about Foo", "questions": [
            
                { "text": "Tea or Coffee ?", "answers": [["Coffee","coffee"], ["Tea","tea"]] },
                { "text": "What type of coffee do you like ?", "parentanswer": "coffee", "answers": [["Arabic","arabic_coffee"], ["Turkish","turkish-coffee"], ["Espresso","espresso-coffee"], ["Black","black-coffee"]] },
                   { "text": "What type of tea do you like ?", "parentanswer": "tea", "answers": [["Green","green-tea"], ["Red","red-tea"], ["Earl","earl-tea"]] },
                   { "text": "Do you like it stronge ?", "parentanswer": "black-coffee", "answers": [["Yes","stronge-coffee"], ["No","notstronge-coffee"]] },
                   { "text": "Do you like it light ?", "parentanswer": "stronge-coffee", "answers": [["Yes","light-coffee"], ["No","notlight-coffee"]] },
              ],
              "products":[
              { "name": "Japanese Green Tea" , "characteristic": "tea,green-tea"},
              {"name":"Organic Sencha Green Tea" , "characteristic": "tea,green-tea"},
              {"name":"Yogi Tea" , "characteristic": "tea,green-tea"},
            
              {"name":"South African Rooibos" , "characteristic": "tea,red-tea"},
              {"name":"Lipton" , "characteristic": "tea,red-tea"}, 
            
              {"name":"Alrifai" , "characteristic": "coffee,arabic-coffee"},
              {"name":"Baja"  , "characteristic": "coffee,arabic-coffee"},
            
              {"name":"Tim Hortons"  , "characteristic": "coffee,black-coffee,stronge-coffee"},
              {"name":"Starbucks"  , "characteristic": "coffee,black-coffee,light-coffee"},
              {"name":"Espresso Craft Blend"  , "characteristic": "coffee,  espresso-coffee"},
            
              {"name":"Baja"  , "characteristic": "coffee,  turkish-coffee"},
              
              ]
            };
            
            Vue.component('question', {
              template: `
            <div v-if="question" class=" m-2" >
                <h3 class="text-primary">Find your taste</h3> <br/> 
            
              <h4>Question {{ questionNumber }} :</h4><br/>
              <h3 class="text-primary">{{ question.text }} </h3> <br/> 
             
                <div @change="submitAnswer" class=" btn-group-toggle"  >
                
                <label class="btn btn-outline-primary m-2" v-for="(mcanswer,index) in question.answers" >
                 <input :value="mcanswer" type="radio" name="currentQuestion" :id="'answer'+index" v-model="answer"  > {{mcanswer[0]}}
                </label> 
              
                </div>  
              
            </div>
            `,
              data() {
                return {
                  answer: ''
                }
              },
              props: ['question', 'question-number'],
              methods: {
                submitAnswer: function (e) {
                  app.handleAnswer(this);
                }
              },
            });
            
            const app = new Vue({
              el: '#quiz',
              data() {
                return {
                  resultsStage: false,
                  title: '',
                  questions: [],
                  products:[],
                  currentQuestion: 0,
                  answers: [],
                  correct: 0,
                  result: '',
                  counter: 0
                }
              },
              created() {
                this.title = quizData.title;
                this.questions = quizData.questions;
                this.products = quizData.products;
              },
              methods: {
                handleAnswer(e) { 
                  this.answers[this.currentQuestion] = e.answer[0];
                 
                  var i ;
                  for(i=0; this.currentQuestion < this.questions.length; i++)
                  { 
                    //find child question for selected answer
                    if(typeof(this.questions[i].parentanswer)!='undefined')
                    {
                      if(e.answer[1] === this.questions[i].parentanswer)
                      {
                        this.result +=  e.answer[1] + ',';
                        this.currentQuestion=i;
                        this.counter++;
                        break;
                      }
                    }
                    //no child for this question => end of quiz
                    if(i+1 == this.questions.length)
                    {
                      this.result +=  e.answer[1];
                      this.handleResults();
                      this.resultsStage = true;
                      break;
                    }
                  } 
            
            
                },
                handleResults() {
                 // window.location.href = "http://hadict.com"+this.result + "/?sl=ar";
                  var i ;
             var hasResult=false;
             for(i=0; i < this.products.length; i++)
             { 
               if( this.products[i].characteristic==this.result)
               {   
                this.result = this.products[i].name; 
                hasResult=true;
                break;
               } 
               
             }
             if(!hasResult)
             {
              this.result="no result";  
             }
               
                }
              }
            })
            <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
            <div id="quiz">
                <div v-if="!resultsStage">
                  <question :question="questions[currentQuestion]" :question-number="counter+1"></question>
                </div>
            
                <div v-if="resultsStage">
                  <div
                    style="justify-content: space-between;display: flex;flex-direction: column;align-items: center;margin: 10px;">
                    <h3 class="text-primary">Done</h3>
                    <h3 class="text-primary">Your best drink is : </h3>  
                    <h3 class="text-primary">{{result}}</h3>
                  </div>
                </div>
              </div>

            【讨论】:

              【解决方案7】:

              Akinator 使用更多的二叉树。所以,根节点是第一个问题。这是内在和内在的。很可能,Akinator 还会获取您所在的位置并链接问题。我开发了自己的 Akinator,名为 Ankusha。我使用了模式匹配算法。说 Ankusha 的工作方式非常复杂。您可以从此 github 链接获取源代码。 Ankusha-The Mind Reader Ankusha 在五个问题内完成了猜测。他向你证实了他猜到的电影。如果您单击“否”,则会询问接下来的五个问题。此迭代持续到 21 个问题。它是一个 Python 3.7 程序,需要强制安装 PIL 和 pygame 模块。请尝试一下。

              注意:请确保在继续安装应用程序之前阅读文件 README.md。所有许可证均在 GNU GPLv3(GNU 通用公共许可证 3.0 版)下完成。

              【讨论】:

              • “Ankusha 在五个问题内完成了猜测。” “数据库”中 9 部电影的 5 个问题?
              猜你喜欢
              • 2010-09-15
              • 1970-01-01
              • 1970-01-01
              • 2020-09-22
              • 2012-10-02
              • 1970-01-01
              • 2016-12-29
              • 2020-10-09
              相关资源
              最近更新 更多