What kind of algorithm is behind the Akinator game?

It always amazed me how the Akinator app could guess a character by asking just several questions. So I wonder what kind of algorithm or method let it do that? Is there a name for that class of algorithms and where can I read more about them?

7 Answers

Yes, there is a name for these class of algorithms - it is called classification algorithms in the field of machine learning. Decision trees is one example for classification algorithm.

In this classification problem, the features for the algorithm are the answers to the question.

Deciding which question should be asked next can be done in various ways - for example by trying to maximize the predicted (or mean) entropy from the next question.

7

This game is sometimes known as 20 Questions. There are some questions on SO on it, e.g.:

Main characteristics of algorithm:

  • Self-educating
  • Mistakes-indulgence
  • Intelligent system of next question choose

Akinator game algorithm model is called "Expert system based on Fuzzy logic".

And this is NOT Decision trees, because Decision trees have no mistakes-indulgence.

I had wrote one some time ago on C#, you can find it by link:

additional info you can read on wiki:

I don't know what exactly algorithm Akinator uses, but here I have put open-source an algorithm that achieves the same effect:

Basically we use a cube of N(Questions) times N(Answer Options) times N(Targets) , see .

We train the cube by applying Bayesian formula with independence assumption, see

Because the code is highly optimized for AVX2 and multi-threading, it may be hard to read. It may be easier to read the CUDA code for the same:

An application of this algorithm is also available as a website to recommend a game.

I think this is like an expert system, with B-Tree structure.

0

i have a small project to build a dynamic quiz for 'find your taste' and i want to share it with you :


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" > <h3>Find your taste</h3> <br/> <h4>Question {{ questionNumber }} :</h4><br/> <h3>{{ question.text }} </h3> <br/> <div @change="submitAnswer" > <label 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 = ""+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=""></script> <div> <div v-if="!resultsStage"> <question :question="questions[currentQuestion]" :question-number="counter+1"></question> </div> <div v-if="resultsStage"> <div> <h3>Done</h3> <h3>Your best drink is : </h3> <h3>{{result}}</h3> </div> </div> </div>

Akinator uses more of binary trees. So, the root node is the first question. This goes on inner and inner. Probably, Akinator also gets the location where you are and links the questions. I have developed my own Akinator named as Ankusha. I have used a pattern matching algorithm. It's quite complicated to say the way Ankusha works. You can get the source code from this github link. Ankusha-The Mind Reader Ankusha finishes the guess within five questions. He confirms the movie he guessed with you. If you click on 'No', next five questions are asked. This iteration continues up to twenty one questions. It is a Python 3.7 program, which requires the PIL and pygame module to be installed compulsorily. Please do try it out.

NOTE: Make sure that you read the file README.md before proceeding with the installation of the app. All licences are done under the GNU GPLv3 (GNU General Public Licence version 3.0).

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like