令我惊讶的是,Akinator 应用程序 只需问几个问题就能猜出一个角色。所以我想知道什么样的算法或方法让它做到这一点?这类算法有名称吗?我在哪里可以阅读有关它们的更多信息?
Akinator 的算法不是决策树,因为决策树没有错误放纵 + 没有下一题选择的智能系统
它也不是基于神经网络的。因为 akinator 从 2007-08-31 就存在了,当时神经网络还没有被广泛使用
算法主要特点:
Akinator博弈算法算法被称为“模糊逻辑专家系统”或“基于模糊逻辑的专家系统”。
我前段时间写过一篇关于C#的文章,你可以通过链接找到它:https://github.com/ukushu/AkinatorEngine
您可以在 wiki 上阅读更多信息:
这个游戏有时被称为20 个问题。有一些关于SO的问题,例如:
我不知道 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
该算法的应用也可作为推荐游戏的网站。
我觉得这就像一个专家系统,具有B-Tree结构。
我有一个小项目来构建一个“找到你的品味”的动态测验,我想与你分享:
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>
通过贝叶斯定理可以实现 Akinator 效应。我发现这篇非常有趣的文章:使用贝叶斯定理通过 Python 构建 Akinator。
Ankusha-读心者 安库莎在五个问题内完成了猜测。他和你确认了他猜的电影。如果您单击“否”,则会询问接下来的五个问题。此迭代持续到二十一个问题。它是一个Python 3.7程序,需要强制安装PIL和pygame模块。请一定要尝试一下。
注意:请确保在继续安装应用程序之前阅读文件 README.md。所有许可证均根据 GNU GPLv3(GNU 通用公共许可证版本 3.0)完成。