Hacker News new | ask | show | jobs
by closedl00p 714 days ago
Hi, nice snappy interface (even after making the HN front page...) and I like the gentle highlighting of possible moves for a piece.

In two games against the bot I _think_ I had the luck to run into a corner case bug with the rules engine: in the position shown in this screenshot https://ibb.co/dQ3HsM4 I'd rolled a 4-6, but the UI would not let me move my piece on 9 four spaces to hit the opponent on 5 -- the UI only wanted to let me move that piece six spaces.

I can imagine how this bug could happen-- all my pieces except this one are in my inner table, so it looks like my piece on 9 is the only piece that can legally use the rolled six, and you're required to fully use your roll if possible... except in this particular case, once I move that piece four spots, I'd be fully in my inner table and could use the six to bear off a piece.

[sidenote: I realize I don't know the best 2024 way to host a temporary image for posting on a text-only forum like HN... but imgbb looked reasonable...]

2 comments

Thanks for reporting this and including a screenshot. I appreciate it.

I've just resolved this on the server and in the web client (now v1.3.5p1, displayed at the lower right when the game loads).

While we're on the topic of ancient link-based sharing websites, here's a pastebin of the Typescript code I wrote years ago that I just dug up to see if it'd handle this case. It does! It uses an actually-pretty-fast backtracking implementation to check for valid moves - validating Backgammon moves is a harder problem than you'd think, especially doing so quickly enough to effectively run monte tree search with. Even with all the thought I've put into it, I still don't have a quick explanation I can give a human trying to learn that game what the valid moves are, especially in the endgame and with blocked moves.

https://pastebin.com/QeSdnQpM

And the test cases I have for it: https://pastebin.com/vmMEjSMz