3 ms·
Built this game in React in ~ 20 hrs. Thought I'd share a few things I learned: 1. You can disable React Dev Tools in Prod, by including this script before Rea
by pcmaffey 9y ago
Built this game in React in ~ 20 hrs. Thought I'd share a few things I learned:
1. You can disable React Dev Tools in Prod, by including this script before React loads. Because this game is 100% client side, fiddling with component state made cheating much too easy.
`
if (typeof window.__REACT_DEVTOOLS_GLOBAL_HOOK__ === 'object') {
__REACT_DEVTOOLS_GLOBAL_HOOK__.inject = function() {};
}
`
2. A good dictionary of English words is not easy to come by. I first tried a 25k word list, and then when I play tested for the first time, half the words I spelled weren't in there. Looking around, larger lists were in the 300k range. Eventually I found one at 70k words... I'm hashing it for easy search of words, though it makes for a slightly heftier initial load (I was hoping for 40-50k words), and it still doesn't include plurals.
I'd thought about using a spell-check API, but wanted the game to be playable offline...especially if I make it into a mobile app (not sure yet).
3. There's a fun little bonus round you unlock if you score enough points. This wasn't at all part of my initial concept, but I realized it'd be neat to use the words spelled during the game to create something (it still needs work, but as they say, constraint is the mother of creativity).
- sushid 9y agoRegarding #2, shouldn't you be using a prefix tree? And even if you're using a hash, you can remove the s suffix and check to see if it's a word (i.e. check if it's a word first, if not, remove the 's' and check again). There are edge cases of course, but at this point it's probably better to have a few false positives than a bunch of false negatives.
- pcmaffey 9y ago[searches "prefix tree"] Sweet! Thanks for the tip, that does indeed look like what I should be using. As for plurals, that's not a bad idea. But I think the # of false positives would be > false negatives.
- sushid 9y agoQuite possible. How about importing the Scrabble dictionary? Looks like there are implementation on Github that's easily <1 MB. Loved the game, btw.