frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

Beating myself at chess

https://log.schemescape.com/posts/diy/beating-myself-at-chess.html
42•zdw•1mo ago

Comments

apetresc•1mo ago
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.

petermcneeley•1mo ago
It is very humbling to write your own chess engine.
thomasmg•1mo ago
Yes. I did the exact same thing a few weeks ago (in Java, but the idea is to port it to my own programming language). I wrote a terminal UI. Lots of small challenges. Many things to learn, like minimax, bitboards, immutable vs mutable.
dado3212•1mo ago
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.
_ache_•1mo ago
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.

XCSme•1mo ago
I tried playing against it, I didn't have many expectations, but even though I blundered a bishop on move 3 due to a mouse-slip, I could still checkmate it in 6 moves. To me it seemed like it makes random moves.
dmurray•1mo ago
I thought it played worse than random moves and couldn't understand how it could beat anyone (no offence to OP).

But if you intentionally hang your pieces, it tends to take them. And it will try to promote pawns in the endgame. So it is possible for it to stumble upon a checkmate, though in my effort where I gave away all my pieces, it instead found the only move to stalemate once it had K+Q+R vs K.

dullcrisp•1mo ago
It tries to promote pawns in the opening and mid-game too.
_ache_•1mo ago
The algorithm behind it is very basic.

Chose the most aggressive move (in term of pieces value and check-mate), if none is aggressive, it takes on of the move equally non aggressive.

Didn't remember the depth of the algorithm but it was very simple C code, could check quickly. It should be able to find a mate in 2 or 3 if it was in position of having one.

I didn't check the correctness of the algorithm, just the intention.

noir_lord•1mo ago
It’s terrible everywhere tbh, it has zero awareness of how dangerous the f7 square is in the opening, you can pretty much just mate it by landing the queen on f7 with a piece covering it every time.

I applaud the effort but not sure I see the point, I had a more capable chess playing program than this on a zx speccy in the 80’s.

mettamage•1mo ago
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.
elicash•1mo ago
When I created my chess variant and had to create an engine, I used ChatGPT and was surprised that it worked, too. But it was fun learning its flaws.
recursivecaveat•1mo ago
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.
Recursing•1mo ago
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

utopiah•1mo ago
> surprisingly readable and surprisingly strong chess engine in 111 lines of Python

Link I get shows 500 lines and it starts with 50 lines of piece-square tables. Maybe it's obvious when you are into the domain but otherwise... that's pretty much of opposite of what I would call "readable".

Recursing•1mo ago
Yes it's "surprisingly readable" only for being so strong and so concise, definitely not production code.

The file is 500 lines because of the piece square tables (as you mentioned), comments, and the CLI interface logic

Previous HN thread here: https://news.ycombinator.com/item?id=20068651

svat•1mo ago
It appears that the “111 lines” is a reference to the version as of 2014-02-11: https://github.com/thomasahle/sunfish/blob/e2b7fc29ce2a112be... (386 lines), about which the author says (https://www.reddit.com/r/programming/comments/1xmj1a/comment...):

> I got 111 by deleting the tables in the top, and the UI code in the bottom, and then running 'cloc' on the result. That gave 20 blanks, 56 comments and 111 lines of code. ;-)

fogleman•1mo ago
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!

yyyk•1mo ago
Note most modern Chess engines use UCI instead of Winboard protocol. But either is fine really.
tux3•1mo ago
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.

Seedance2 – multi-shot AI video generation

https://www.genstory.app/story-template/seedance2-ai-story-generator
1•RyanMu•1m ago•1 comments

Πfs – The Data-Free Filesystem

https://github.com/philipl/pifs
1•ravenical•4m ago•0 comments

Go-busybox: A sandboxable port of busybox for AI agents

https://github.com/rcarmo/go-busybox
1•rcarmo•5m ago•0 comments

Quantization-Aware Distillation for NVFP4 Inference Accuracy Recovery [pdf]

https://research.nvidia.com/labs/nemotron/files/NVFP4-QAD-Report.pdf
1•gmays•6m ago•0 comments

xAI Merger Poses Bigger Threat to OpenAI, Anthropic

https://www.bloomberg.com/news/newsletters/2026-02-03/musk-s-xai-merger-poses-bigger-threat-to-op...
1•andsoitis•6m ago•0 comments

Atlas Airborne (Boston Dynamics and RAI Institute) [video]

https://www.youtube.com/watch?v=UNorxwlZlFk
1•lysace•7m ago•0 comments

Zen Tools

http://postmake.io/zen-list
1•Malfunction92•10m ago•0 comments

Is the Detachment in the Room? – Agents, Cruelty, and Empathy

https://hailey.at/posts/3mear2n7v3k2r
1•carnevalem•10m ago•0 comments

The purpose of Continuous Integration is to fail

https://blog.nix-ci.com/post/2026-02-05_the-purpose-of-ci-is-to-fail
1•zdw•12m ago•0 comments

Apfelstrudel: Live coding music environment with AI agent chat

https://github.com/rcarmo/apfelstrudel
1•rcarmo•13m ago•0 comments

What Is Stoicism?

https://stoacentral.com/guides/what-is-stoicism
3•0xmattf•14m ago•0 comments

What happens when a neighborhood is built around a farm

https://grist.org/cities/what-happens-when-a-neighborhood-is-built-around-a-farm/
1•Brajeshwar•14m ago•0 comments

Every major galaxy is speeding away from the Milky Way, except one

https://www.livescience.com/space/cosmology/every-major-galaxy-is-speeding-away-from-the-milky-wa...
2•Brajeshwar•14m ago•0 comments

Extreme Inequality Presages the Revolt Against It

https://www.noemamag.com/extreme-inequality-presages-the-revolt-against-it/
2•Brajeshwar•14m ago•0 comments

There's no such thing as "tech" (Ten years later)

1•dtjb•15m ago•0 comments

What Really Killed Flash Player: A Six-Year Campaign of Deliberate Platform Work

https://medium.com/@aglaforge/what-really-killed-flash-player-a-six-year-campaign-of-deliberate-p...
1•jbegley•15m ago•0 comments

Ask HN: Anyone orchestrating multiple AI coding agents in parallel?

1•buildingwdavid•17m ago•0 comments

Show HN: Knowledge-Bank

https://github.com/gabrywu-public/knowledge-bank
1•gabrywu•22m ago•0 comments

Show HN: The Codeverse Hub Linux

https://github.com/TheCodeVerseHub/CodeVerseLinuxDistro
3•sinisterMage•23m ago•2 comments

Take a trip to Japan's Dododo Land, the most irritating place on Earth

https://soranews24.com/2026/02/07/take-a-trip-to-japans-dododo-land-the-most-irritating-place-on-...
2•zdw•24m ago•0 comments

British drivers over 70 to face eye tests every three years

https://www.bbc.com/news/articles/c205nxy0p31o
26•bookofjoe•24m ago•10 comments

BookTalk: A Reading Companion That Captures Your Voice

https://github.com/bramses/BookTalk
1•_bramses•25m ago•0 comments

Is AI "good" yet? – tracking HN's sentiment on AI coding

https://www.is-ai-good-yet.com/#home
3•ilyaizen•26m ago•1 comments

Show HN: Amdb – Tree-sitter based memory for AI agents (Rust)

https://github.com/BETAER-08/amdb
1•try_betaer•26m ago•0 comments

OpenClaw Partners with VirusTotal for Skill Security

https://openclaw.ai/blog/virustotal-partnership
2•anhxuan•27m ago•0 comments

Show HN: Seedance 2.0 Release

https://seedancy2.com/
2•funnycoding•27m ago•0 comments

Leisure Suit Larry's Al Lowe on model trains, funny deaths and Disney

https://spillhistorie.no/2026/02/06/interview-with-sierra-veteran-al-lowe/
1•thelok•27m ago•0 comments

Towards Self-Driving Codebases

https://cursor.com/blog/self-driving-codebases
1•edwinarbus•27m ago•0 comments

VCF West: Whirlwind Software Restoration – Guy Fedorkow [video]

https://www.youtube.com/watch?v=YLoXodz1N9A
1•stmw•28m ago•1 comments

Show HN: COGext – A minimalist, open-source system monitor for Chrome (<550KB)

https://github.com/tchoa91/cog-ext
1•tchoa91•29m ago•1 comments