Ain't it funny how the knight moves?

by mpnagleon 1/20/2023, 10:19 PMwith 203 comments

by quickthrower2on 1/20/2023, 11:10 PM

I think the instructions should be:

Move to the square indicated below the board without moving to a square the queen can capture and without capturing the queen. Once accomplished a new square will be indicated. Repeat until all possible squares are done.

by naeton 1/20/2023, 10:59 PM

The fact that it doesn't highlight where you've moved already makes it no fun.

Edit: the directions weren't super clear. I see that you're actually supposed to go to every square in a specific order (first G8, then F8, E8, etc), not just visit them all in any order. That means you have to do a bunch of laborious trips around the queen to go to certain squares since you won't have enough room to maneuver directly there.

by mckeedon 1/21/2023, 1:33 AM

I mapped out the structure of the board as a graph of which squares you can get to from which other squares. It's surprisingly stringy without all the squares forbidden by the queen placement.

https://i.imgur.com/8OuQcu8.png

by Trufaon 1/21/2023, 1:38 AM

Ok, shameless plug. I did a pretty “popular” version of this.

https://knight-queen-game.netlify.app/

by dragontameron 1/20/2023, 11:03 PM

Hmm, a weird version of a Knight's Tour.

https://en.wikipedia.org/wiki/Knight%27s_tour

It seems like in this version / webpage, you're allowed to revisit squares however. It'd be nice if it highlighted what squares "Counted", because the words are quite ambiguous. A graphical representation of what is being counted / not counted would be very helpful.

----------------

EDIT: Ah, I got it. The location on the left is the next spot you're supposed to go to. The puzzle is quite easy once I understood the interface.

The interface needs a "Next square: h5" or something. I really didn't get it for the longest time.

by greon 1/20/2023, 11:37 PM

Here's how many moves it takes to get everywhere from a middle square as the knight.

https://www.reddit.com/r/chess/comments/1x7t58/visual_repres...

by mdanielon 1/21/2023, 2:32 AM

If you'd like "easy mode," such that the queen's squares are highlighted:

  ((sq) => { let board = document.querySelector('div.m-auto'); sq.forEach(s => board.querySelector('[data-squareid="'+s+'"]').style.backgroundColor='red'); })(["d8", "d7", "d6", "d4", "d3", "d2", "d1", "e6", "f7", "g8", "c6", "b7", "a8", "c5", "b5", "a5", "e5", "f5", "g5", "h5", "c4", "b3", "a2", "e4", "f3", "g2", "h1"])
I found that to be the middle ground between "you still have to plan" versus the amount of energy I was spending trying keep track of the forbidden squares

by nick0garveyon 1/20/2023, 11:38 PM

This took me 14:02 on the first try. Definitely got faster as time went on but I found myself getting stuck on a few squares for no good reason. Starting from the destination and working toward the source helped.

by voreon 1/20/2023, 10:54 PM

I wish it could keep track of where the knight has already been.

by darepublicon 1/20/2023, 11:08 PM

The play on the Seger lyrics "night moves" with a chess knight was done earlier in an old ytmnd I remember

by y-curiouson 1/20/2023, 11:03 PM

I love the amount of chess nerds on Hacker News. If anyone is in the East Bay of SF and likes chess, I run a chess club in Walnut Creek, hit me up!

by xiphias2on 1/20/2023, 11:54 PM

How does the knight move?

https://youtu.be/5lZEt6oz5MQ

https://youtu.be/wfDCLEAU9hE

by kjgkjhfkjfon 1/21/2023, 6:45 AM

The knight move in chess seems a bit strange at first, but it makes sense when you realize that the knight can move to squares that lie on a circle around it.

by hughdbrownon 1/27/2023, 9:14 PM

Shortest path solution using breadth-first search

https://gist.github.com/hughdbrown/5c14ec41c30532807afaeba9c...

Same result as the solver below:

https://github.com/rubenvannieuwpoort/funnyhowtheknightmoves...

except for this path:

a3 c2 e3 g4 h2

a3 c2 e3 f1 h2

by 4by4by4on 1/20/2023, 11:38 PM

As a teenager I had a chess lesson with Ben Finegold and I practiced this puzzle for weeks on a physical board.

He also mentioned this riddle off hand which I had a ton of fun solving. https://fivethirtyeight.com/features/how-about-a-nice-game-o...

by sebzim4500on 1/21/2023, 12:30 AM

7:31, I found the UI kind of annoying. I kept accidentally selecting the text on the edge and then wasted time trying to deselect it.

by TheRealPomaxon 1/21/2023, 12:52 AM

This has terrible instructions.

by Scubabear68on 1/20/2023, 11:34 PM

..

When you just don't seem to have as much to lose?

Strange how the night moves.

With autumn closin' in.

by salvipeteron 1/23/2023, 7:08 AM

If you drop the sequential restriction, this becomes a pretty neat shortest path problem, essentially the same as LeetCode 847, but the simple dynamic programming approach does not work here (too much memory needed). It can be transformed to TSP, though, which gives an optimal solution (using Concorde) of just 46 moves: http://directory.iit.bme.hu/~salvi/archive/snippets/knight/k...

by rustybolton 1/21/2023, 2:00 PM

Felt like writing a solver for it: https://github.com/rubenvannieuwpoort/funnyhowtheknightmoves...

by logicalleeon 1/20/2023, 11:44 PM

For me the instructions are pretty clear: every square "right to left, top to bottom" - except don’t land anywhere the queen can take you, and don’t take the queen. (i.e. somehow move to the upper-right, then one to the left and so forth going through the rows and columns backards and down, like reading right to left down a page.)

I gave up after 4 minutes. It's really tough and I only got partway through the second row. I play OK chess (slightly above average on lichess) but it is a really tough visualization exercise.

for anyone who did it to completion, how long did it take? did you speed up by the end?

by monroewalkeron 1/21/2023, 1:19 AM

So many unnecessarily negative comments.. I enjoyed this, thank you for making it

by raydiatianon 1/21/2023, 7:52 AM

The design for this app is atrocious for anybody who has played online chess.

“This is a valid move. This is a valid move.”

reads rules.

“They couldn’t paint one measly Queen black? Exit”

You know if you know. The queen is white. I’m going to occupy the diagonal.

by hardwaregeekon 1/21/2023, 3:33 AM

After a couple tries got it done in 16 minutes or so. Probably laughably bad for anyone good at chess but it was a fun and enlightening challenge. About midway through I had a sudden click and figured out the pattern to hit the right squares. I don’t know how to put it into words but I believe there’s a three move combo that helps you move off of one set of squares and onto the other set. And my intuition got a lot better towards the end, even getting the last squares almost by accident. Funny how that happens

by xg15on 1/21/2023, 11:45 AM

Instead of just giving the next square you're supposed to jump to, how about just highlighting all the squares on the board that you already visited? I think that would make the game both easier to understand and give the player an incentive to complete it (the "gotta catch em all" effect)

Edit: ... or maybe not: https://news.ycombinator.com/item?id=34461415

by luxuryballson 1/20/2023, 11:13 PM

clicks help

ha ha I’m not doing that

by GistNoesison 1/21/2023, 1:59 PM

Inspired by some other comments here, I added a way to help visualize the graph (see screenshot and code) : https://gist.github.com/unrealwill/07069676a577f6dfbc3555369...

Once you can visualize the knights graph in your head, you just have to run Dijsktra in your head.

by curiousllamaon 1/20/2023, 11:33 PM

Love it. Anyone found a strategy better than “choose a path that will get you there that has a square in the largest quadrant, and jump from there”?

by jpmoralon 1/20/2023, 11:33 PM

Nice challenge. Can someone help me understand why other posters want highlighting for visited squares?

by sireaton 1/21/2023, 2:08 PM

Good exercise! 5:29 on the first try (FM),

3:27 on 2nd try once I realized we have to move the knight to non attacked squares from top right to left bottom

At first I thought I had to implement the knights walk by myself so wasted about 30 seconds on understanding the instructions.

by tmtvlon 1/21/2023, 2:19 AM

Instructions unclear, reread Through the Looking-Glass, and What Alice Found There.

by whstlon 1/21/2023, 2:11 AM

This reminds me of one of the final puzzles in the 90s aventure game Gabriel Knight:

https://youtu.be/fPByLdCYPpo?t=33989

(spoiler alert, it's the last part)

by thenerdheadon 1/21/2023, 3:01 AM

Workin' on our knight moves.

Tryin' to make some front page hacker news.

Workin' on our knight moves.

by travisjungrothon 1/21/2023, 5:52 AM

In case anyone else goes nuts trying to write a program for a knight's tour with the additional queen constraint from this game: you can't get to B7. Obvious if you actually look at the board.

by heroiccocoaon 1/21/2023, 2:18 AM

https://www.youtube.com/watch?v=SrQlpY_eGYU

It's not meant to be easy, I'm 1800 bullet on lichess and struggling

by TurkishPoptarton 1/20/2023, 11:01 PM

How to get it to C8? Gah!

by bfungon 1/21/2023, 7:49 AM

Tangent, but more meme marketing name suggestion: how does the knight move?

https://youtu.be/wfDCLEAU9hE

by cochleari_majoron 1/21/2023, 3:38 AM

Here is one possible solution using fewest moves (I think) https://tinyurl.com/noitaint

by dan-robertsonon 1/21/2023, 1:05 AM

Took me ~25 minutes which was annoying. As I type this, my brain is worried that the individual keys I type are not knight’s moves away from each other.

by chedokuon 1/21/2023, 11:34 AM

if you like this chess puzzle, you may be interested in https://chedoku.com/#dailypuzzle

Here is a video of me solving the puzzle: https://www.youtube.com/watch?v=ZrCxZkZDskc

by amriksohataon 1/21/2023, 9:13 AM

All taken from the original Indian game of chess, where the Knight was the Elephant and had certain moves it could make.

by chadlavion 1/20/2023, 11:13 PM

I didn't read the instructions at first and was confused why it wouldn't let me take the queen

by bjt2n3904on 1/21/2023, 2:56 AM

A really clever puzzle, UI issues aside. Reminds me of programming the knights tour back in college.

by jslakroon 1/21/2023, 9:09 PM

Knight movements on chess always makes me think in the glider on Conway's game of life

by phnofiveon 1/21/2023, 8:50 AM

High score: 2:44 to scroll down and realize what in the heck I was supposed to be doing

by aoeusnth1on 1/21/2023, 4:25 AM

I did this and now my brain is humming and my blood pumping. Thanks.

by soperjon 1/20/2023, 11:30 PM

I feel like I wasted 18:40 seconds.

by moglitoon 1/21/2023, 1:21 AM

No leaderboard? Finished in 8:41.

by mabboon 1/20/2023, 11:53 PM

Well that took me 28 minutes.

I love it.

by antiheroon 1/21/2023, 12:51 AM

This is the most boring game ever and I’m not sure why anyone would play it.

by etothepiion 1/21/2023, 1:24 AM

22:04