JavaScript 20-Questions like classification system

Viewed 20

I've been assigned to create a 20 questions/Akinator-like game where you answer [y/n] and I want to create a large range of answers. How would I make a system that can change the next question asked based on the answer to the previous one? I added a picture to explain it better: project guidelines

Any advice would be great.

1 Answers

A query-friendly system would be nice for storage, with each part of an animals classification data as a field. It should be possible to dynamically build a query based on the answers, adding to it as the game continues. Using plaintext storage may make it easier to bundle the DB with the packaged app, and it won't be insanely massive so it should be reasonable to parse on start and serialize at the end if anything changes.

For the questions you could use a list of the chosen classifications and just loop through prompting "Is it a ?". While there's multiple results use them to decide which options to remove from the copy of the question list being used for the current run - e.g. nothing left that has the classification mammal, so remove that possibility.

The questioning may be faster if it was based in part on the scientific animal classification system of kingdom, class, order, etc. This doesn't include whether they can be a "pet" though, so you would have to manually add that unless you can automate it.

If you'd like to automate generating a DB it would be possible to "scrape" a Wiki-based site to generate a data set to then parse and serialize as the DB. They have tools built-in to the wiki framework, so it takes time to figure out how, but it's pretty simple overall.

Related