logoalt Hacker News

Beating myself at chess

42 pointsby zdwlast Tuesday at 3:03 PM20 commentsview on HN

Comments

Recursinglast Saturday at 9:27 PM

For people interested in making their own, I highly recommend reading through https://github.com/thomasahle/sunfish/blob/master/sunfish.py , a surprisingly readable and surprisingly strong chess engine in 111 lines of Python

https://www.chessprogramming.org/ is also really interesting, see e.g. https://www.chessprogramming.org/Sunfish and https://www.chessprogramming.org/Quiescence_Search

show 1 reply
foglemanlast Saturday at 10:55 PM

I'm just here to comment on the CGA color palette on this website, lol.

I always hated that video mode, but it looks good here when the magenta and cyan are limited just to links and headers!

apetresclast Saturday at 8:32 PM

Bug report: I got to a late-middlegame position and then the bot crashed because it tried to castle illegally (after its queenside rook had already moved):

``` Uncaught Error: Invalid move: {"from":"e8","to":"c8"} at Chess.move (chess.js:2530:23) at cm-chessboard/:75:23 ```

There didn't seem to be a way to recover besides refreshing.

dado3212last Saturday at 8:35 PM

Would maybe benefit from a "Checkmate!" or other finish screen, but cool project! Though I agree that it beating you may be more based on your skill level than its, given how it keeps pushing pawns.

recursivecaveatlast Saturday at 9:22 PM

The ai source code doesn't seem to have alpha-beta pruning yet. If you add that plus some basic move-ordering (killer move heuristic is easy, powerful, and has a cool name) that will let it search a lot deeper. One nice thing about such improvements is they converge to the same result, just faster, so unlike tweaking the evaluation function you can be pretty sure that you're improving it.

petermcneeleylast Saturday at 8:34 PM

It is very humbling to write your own chess engine.

show 1 reply
mettamagelast Saturday at 9:13 PM

I was surprised how quickly I created a chess engine with Claude code a few months ago. It worked quite well. It was bad at recognizing certain chess patterns so I created a lot of tests for the chess engine.

show 1 reply
yyyklast Saturday at 11:54 PM

Note most modern Chess engines use UCI instead of Winboard protocol. But either is fine really.

_ache_last Saturday at 8:56 PM

It is terrible in the opening and a little better in the middle game (if you didn't win already, I mean if you played 4-5 random moves).

I think you can improve it a lot by taking into account its own position. I mean, moving forward isn't very important want you are under the menace of a checkmate somewhere else.

show 2 replies
tux3yesterday at 12:24 AM

It's a fun little AI, but I have another bug report. This time my move is the one that made it crash!

    Uncaught Failed to apply player move! cm-chessboard:69:55
    promotion result 
    Object { type: "pieceSelected", square: "c8", piece: "wq" }
    cm-chessboard:111:37
    Uncaught Error: Invalid move: {"from":"d7","to":"c8","promotion":"q"}
I had forked a rook and king with a pawn. Pawn takes rook, and was going to be offered a promotion, but taking and promoting at once seems to make it crash.