Akinator游戏背后有什么样的算法?

时间:2012-11-30 16:59:38

标签: algorithm statistics machine-learning artificial-intelligence

Akinator app只能通过几个问题来猜测一个角色,这让我很惊讶。所以我想知道什么样的算法或方法让它做到这一点?是否有该类算法的名称,我在哪里可以阅读更多关于它们的信息?

7 个答案:

答案 0 :(得分:19)

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

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

决定接下来应该问哪个问题可以通过各种方式完成 - 例如,尝试从下一个问题中最大化预测(或平均值)entropy

答案 1 :(得分:5)

答案 2 :(得分:3)

算法的主要特点:

  • 自育
  • 错误放纵
  • 下一个问题的智能系统选择

Akinator游戏算法模型被称为"基于模糊逻辑的专家系统"。

这不是决策树,因为它没有错误 - 放纵。

我之前在C#上写了一篇,您可以通过链接找到它:https://github.com/ukushu/AkinatorEngine

答案 3 :(得分:2)

我不知道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使用。

答案 4 :(得分:1)

我认为这就像是一个B-Tree结构的专家系统。

答案 5 :(得分:1)

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


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>

答案 6 :(得分:0)

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

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