Live data from Hacker News

Show HN: A simple Wordle clone in 60 lines, using Hyperscript

arhamjain.com

31–40 of 53 posts

Re: Show HN: A simple Wordle clone in 60 lines, using Hyperscript

#31
post #9

This is awesome, but there's a slight bug in this implementation: Wordle won't count additional instances of a letter as wrong-position, it'll just flag them as wrong. For example, if the word is TRACE, and I guess TRACT, the first T will be green, but the second T should be black, not yellow. In this implementation, at the moment, TRACT would return GGGGY, but in Wordle it would be GGGGB. I actually made the same mi…

Oh wow, I never noticed that myself. I'll fix it once I'm at my computer, thanks for pointing it out! The fix will probably be something like if letter not in (.bg-warning in first .guess).innerText then add .bg-warning Haven't tested as I'm on my phone, but seems like a simple enough fix.

I don't think it's that simple. For HOUSE, guessing BEERS should get you WYWYW

Re: Show HN: A simple Wordle clone in 60 lines, using Hyperscript

#33

On Safari on iOS, at least, typing fast will accidentally zoom into that part of the page instead of registering it as a character press. But pretty neat implementation otherwise. Awesome work!

Yep, I have the wrong meta tag I believe:

        
That should fix it, I'll push a new version after fixing the word matching issue others have pointed out. I underestimated Wordle's complexity :)

Re: Show HN: A simple Wordle clone in 60 lines, using Hyperscript

#34
post #23

Not take away from the brevity of the code, but these 60 lines translate into 168KB of JavaScript.

_hyperscript_web.min.js is 84.1 KiB (86,093 bytes) and when zipped it's 22.1 KiB (22,641 bytes)

Looks like they doubled the size by accident, in the network debugger the first is a 302 that resolves to the actual file. It shows 84kb twice because of that.

Re: Show HN: A simple Wordle clone in 60 lines, using Hyperscript

#35
I'm confused. Hyperscript is supposed to be an alternative way to writing JSX, good for skipping the babel/transpile step. Such as the React h() function. For example:

    h('header', { id: 'my-header', className: 'header' },
      h('div', { className: 'logo' },
        h('a', { href: '/' }, 'mtsknn.fi')
      )
    )
Hyperscript.org doesn't seem to be related to this at all?

https://mtsknn.fi/blog/hyperscript-hyperior-alternative-to-j... https://dev.to/fromaline/hyperscript-the-hidden-language-of-...

Re: Show HN: A simple Wordle clone in 60 lines, using Hyperscript

#37
post #35

I'm confused. Hyperscript is supposed to be an alternative way to writing JSX, good for skipping the babel/transpile step. Such as the React h() function. For example: h('header', { id: 'my-header', className: 'header' }, h('div', { className: 'logo' }, h('a', { href: '/' }, 'mtsknn.fi') ) ) Hyperscript.org doesn't seem to be related to this at all? https://mtsknn.fi/blog/hyperscript-hyperior-alternative-to-j... http…

You are correct. Hyperscript.org is a companion library to htmx; they are totally different from the JSX Hyperscript.

Re: Show HN: A simple Wordle clone in 60 lines, using Hyperscript

#38
post #24

> build 80% of Wordle in a different language I have been trying to do the same thing! I was looking for projects on github that I could adapt to a new language. Sadly, most of them require a server. It seemed to me that this game could pretty easily just run on the client alone. I will dig into yours and see how it can be adapted to different languages too :)

I think wordle does just run indefinitely on the client. It has a word list in its JS which has the list of winning words in order, so you can see the upcoming ones. And the current word is somewhere in localstorage as well. Obviously not much fun if you poke around there too much, but my guess is it just checks the current date and indexes the words array and sets all the state from there.

Re: Show HN: A simple Wordle clone in 60 lines, using Hyperscript

#39
post #29
post #25

Earlier quoted context omitted.

Look at the source, it is written with that language/framework. I seems they want to pull a Substack. Color me unimpressed.

He used the framework, not named it.

Oh, my bad... Sorry for the noise.

@dang if you happen to read this, can you hide/flag the thread ?

Re: Show HN: A simple Wordle clone in 60 lines, using Hyperscript

#40

I found a bug. When there is a repeated character in the guess but not in the word, you’re given an incorrect color key. E.g. Word was GROUP I guessed SPOON Output was green O at location 3 and yellow at 4. Happened for a couple more guesses making me think there is another O eventually to realize there are no more spots and it’s a bug.

Sorry for that (and thanks to all the folks that pointed out the word matching code was wrong). I've pushed an updated version, it's 63 lines now.

Turns out, HN finds and reports bugs much faster than family and friends :)

Post reply on HN