@@ -9,13 +9,13 @@ Add the following dependency to your pom.xml:
99<dependency >
1010 <groupId >com.github.markozajc</groupId >
1111 <artifactId >akiwrapper</artifactId >
12- <version >1.5.2 </version >
12+ <version >1.6 </version >
1313</dependency >
1414```
1515#### Gradle
1616Add the following dependency to your build.gradle:
1717``` gradle
18- implementation group: 'com.github.markozajc', name: 'akiwrapper', version: '1.5.2 '
18+ implementation group: 'com.github.markozajc', name: 'akiwrapper', version: '1.6 '
1919```
2020
2121## Usage
@@ -28,44 +28,52 @@ If you, for example, wish to use a different language that the default English,
2828something other than characters, you may use the following setup:
2929``` java
3030Akiwrapper aw = new AkiwrapperBuilder ()
31- .setLanguage(Language . GERMAN )
32- .setGuessType(GuessType . PLACE )
33- .build();
31+ .setLanguage(Language . GERMAN )
32+ .setGuessType(GuessType . PLACE )
33+ .build();
3434```
3535(keep in mind that not all language-guesstype combinations are supported, though all languages support ` CHARACTER ` )
3636
37- You'll likely want to set up a question-answer loop afterwards. Fetch questions with
37+ You'll typically want to set up a question-answer loop afterwards. Fetch questions with
3838``` java
3939Question question = aw. getQuestion();
4040```
4141
42- Display the question to the user , collect their answer, and feed it to Akinator with
42+ Display the question to the player , collect their answer, and feed it to Akinator with
4343``` java
4444aw. answer(Answer . YES );
4545```
4646
47- If the player wishes to undo their previous answer, you can let Akinator know with
47+ If the player wishes to undo their previous answer, you can let do that with
4848``` java
4949aw. undoAnswer();
5050```
51+ You can undo answers all the way to the first question.
5152
52- Akinator will propose a list of guesses after each answer, coupled with their determined probabilities. You can get all
53- guesses above a certain probability with
53+ Akinator will occasionally try guessing what the player is thinking about.
5454``` java
55- aw. getGuessesAboveProbability(0.85f ); // 85% seems to be the sweet spot, though you're free to use anything you want
55+ var guess = aw. suggestGuess()
56+ if (guess != null ) {
57+ // ask the player to confirm or reject the guess
58+ if (playerConfirmedGuess) {
59+ aw. confirmGuess(guess); // let Akinator know that the guess is right
60+ return ; // finish the game
61+
62+ } else {
63+ aw. rejectLastGuess(); // let Akinator know that the guess is not right - this also gives us a new question
64+ }
65+ }
66+ ;
5667```
57- Let the player review each guess, but keep track of the declined ones, as Akinator will send you the same guesses over
58- and over if he feels like it.
68+ When a guess is available, the player should be asked to confirm it. If the guess is confirmed, we finish the game and
69+ optionally let Akinator know. If the guess is rejected, we let Akinator know and continue. Akiwrapper also keeps track
70+ of rejected guesses for you, so ` suggestGuess() ` never returns the same guess.
5971
60- At some point Akinator will run out of questions to ask. This is indicated by ` aw.getCurrentQuestion() ` equalling null.
61- If and when this happens, fetch and propose all remaining guesses (this time without a probability filter) with
62- ``` java
63- aw. getGuesses()
64- ```
65- and propose each one to the player. This also marks the absolute end of the game.
72+ At some point (normally after question #80 ) Akinator will run out of questions to ask. This is indicated by
73+ ` aw.isExhausted() ` . After there are no questions left, the last guess should be retrieved and shown to the player.
6674
6775Unless you provide your own UnirestInstance to AkiwrapperBuilder, you should make sure to shut down the singleton
68- instance that Akiwrapper uses by default after you're done with Akiwrapper:
76+ instance that Akiwrapper uses by default after you're done with Akiwrapper (calling ` System.exit() ` also works) :
6977``` java
7078UnirestUtils . shutdownInstance();
7179```
0 commit comments