Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Auto Suggest #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

AH-Dietrich
Copy link
Contributor

Why: Currently users may have difficulty typing the name of the country correctly because the country data may have it stored differently than they expect. This may cause a user to leave the game to search the correct spelling online or to abandon their attempt.

What: Now after 2 keystrokes there will be a popup for autosuggested countries based on the country data. The autosuggest only happens after 2 keystrokes and limits suggestions to 3.

image with only 1 keystroke

image of autosuggest in night mode

image of autosuggest in light mode

@darekkay
Copy link

Related issue: #15

@tjiang11
Copy link

tjiang11 commented Feb 21, 2022

This seems like it could have implications wider than just forgiving misspellings and aliases. It becomes a lot easier if we can just type two characters and get a list of country names to stir our memory if we feel like we kind of remember what letters the country starts with, for example. The other issue is that aliases don't necessarily correspond in prefix of the first two letters. For example, Ivory Coast and Cote d'Ivoire, or UAE, and United Arab Emirates, DRC and Democratic Republic of the Congo, so it doesn't actually address the issue.

It would probably make more sense to just steadily add more aliases that are accepted to the database, since aliases rarely change anyway.

@darekkay
Copy link

It becomes a lot easier if we can just type two characters and get a list of country names to stir our memory if we feel like we kind of remember what letters the country starts with, for example

This is not a competitive game. If you don't want to rely on the autocomplete as a guide, don't type any letters and wait until you have the full country in your mind before typing. The downside of not having an auto-complete outweights your concern in my opinion. I don't want to think about the spelling of "Kazakhstan" and look it up somewhere else just because the game tells me it's not a country after my 3rd spelling attempt. That's frustrating and the oposite of fun. The similar game Worldle got the auto-complete right. But again, that's just my opinion, so maybe a poll would be good.

The other issue is that aliases don't necessarily correspond in prefix of the first two letters.

We can have both: aliases + autocomplete for aliases where the first two letters of an alias don't match the country name.

@AH-Dietrich
Copy link
Contributor Author

I think its necessary to have this autocomplete especially as a soundness check that the country you're inputting is a real country that this game accepts. I agree with what @darekkay is saying completely, but I do understand the concern @tjiang11 is brining up. I think it is more fun to have the autocomplete than to struggle with spelling a country.

@AH-Dietrich
Copy link
Contributor Author

@the-abe-train what are your thoughts on this?

@JuanM04
Copy link

JuanM04 commented Feb 23, 2022

I'll suggest using either <datalist /> or a library with autocomplete/comboboxes that support using the keyboard.

With the native HTML <datalist />, it would be something like this:

<input
  /* ...  */
  list="countries-list"
/>

<datalist id="countries-list">
  {countryData.map(({ properties: country }, i) => (
    <Fragment key={i}>
      {country.NAME === country.NAME_LONG ? (
        <option>{country.NAME}</option>
      ) : (
        <option>{country.NAME_LONG}</option>
      )}
    </Fragment>
  ))}
</datalist>

@the-abe-train
Copy link
Owner

I appreciate you all taking an interest in improving the game.

Personally, I'm not a fan of the auto-complete. Globle is inspired by the geography games on Sporcle that I played all the time in high school, and sometimes these days too. Those games didn't have a drop-down menu to help you with spelling, just a plain text box like Globle has now. Although I don't know why they built the game that way, it taught me not only about where the world's countries are but also how to spell them, and I'm grateful for that.

I don't think learning the spelling (or googling it, or using an autocomplete feature like most phone keyboards have) makes the game less enjoyable, but you're welcome to disagree. I'll leave this pull request open because I'm curious to hear more people's opinions and I am open to changing my mind, but in the meantime I don't plan to merge it.

Thank you for keeping the conversation civil.

@olliechick
Copy link
Contributor

It think the lack of autocomplete is a barrier to entry for some players - I think it would be good to have it on by default, but able to be turned off in settings.

@olliechick
Copy link
Contributor

I would suggest changing the getSuggestions function to this to avoid displaying the autocomplete when a county's name is selected from the autocomplete.

  function getSuggestions(value: string) {
    const inputValue = value.trim();
    const inputLength = inputValue.length;
    
    if (inputLength >= minGuessLength) {
      const countryNames = countryData.map(country => country.properties.NAME)
      const suggestions = countryData.filter(country => {
        const countryName = country.properties.NAME.toLowerCase()
        return countryName.slice(0, inputLength) === inputValue.toLowerCase()
      });
      console.log(inputValue, countryNames)
      if (suggestions.length === 1 && countryNames.includes(inputValue)) {
        return [];
      } else {
        return suggestions.slice(0, suggestionLimit);
      }
    }
    return [];
  }

@Bo-Duke
Copy link

Bo-Duke commented Feb 23, 2022

As the game is only available in english, it would be great to have autocomplete to help for that. I don't really care about learning how to spell country names in an other language as much as where they are.

Also, keyboard spelling-check can also complicate things if you speak another language. (For exemple Senegal is auto-corrected to Sénégal if you use a French keyboard, which is not a valid country name for the game.)

@mgratch
Copy link

mgratch commented Mar 7, 2022

I actually just forked this to create the same PR. I think autocomplete would be huge help. Though I understand there are certain accessibility issues related to the game, the issues related to spelling doesn't have to be one of them. Regardless of the decision that is made, thank you for this wonderful game. My entire family loves it -- including our 7 year old.

@olliechick
Copy link
Contributor

This solves #36

@gawi
Copy link
Contributor

gawi commented Apr 24, 2022

Personally, I'm not in favor of auto complete. That's way too much hinting. Also, knowing how to spell the country name is part of the game. If you're stuck, you can always use Google to find out the exact spelling.

Liechtenstein, right?

@escalonn
Copy link

i agree with the idea that the game is better when hints like how to spell the name are not readily available. accessibility for those without english as a first language is the best argument i can see for having this be a toggleable non-default option.

@chau-intl
Copy link

Why not make auto-complete a setting just like colour blind mode?

I definitely play this game for the geography part and not for the spelling. English is not my native language and the need to have a secondary map with English names on it just to make an entry makes the game less interesting for me. Then just make a setting to toggle displaying of country names directly on the globe 😉

@mhelfer-optum
Copy link

I think this would be a huge advantage to the game and make it a lot more enjoyable. I end up having to Google the country spelling anyway, which sometimes shows me a map of nearby countries thus spoiling subsequent guesses. Due to the polarity of including this feature I agree with @chau-intl that it should just be an option in the settings, turned off by default.

@gawi
Copy link
Contributor

gawi commented May 24, 2022

The problem is that we are sometime one-letter off the real country name. We'd like Globle to be more tolerant and accept slightly incorrect name. The solution of auto-complete has the inconvenient of proposing countries and thus defeats one of the objective of the game which is to learn countries.

Another solution to this problem would be to perform a distance analysis between the entry and the country names, if the edit distance is smaller than some arbitrary value (2?), then a pop-up "Did you mean (correctly spelled country name)" appears and user has to confirm. Confirmation is necessary to avoid implicit bad guesses. for example, if you type "Irak" (instead of "Iraq"), you don't want the game to assume you meant "Iran".

@gawi
Copy link
Contributor

gawi commented May 28, 2022

See PR #101.

@the-abe-train
Copy link
Owner

If you're following this PR, please check out #101. It's an interesting solution and I would much rather go with that one for the reasons @gawi mentioned.

@EmiratesDrawResults
Copy link

I think this is a great improvement to the game's interface! As someone who has struggled with spelling the name of countries correctly in the past, I appreciate the new auto-suggest feature that will help me out. Especially with a country like Emirates, which could be spelled in different ways. This will definitely save me time and make my experience playing the game much smoother. Thank you for implementing this feature!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.