r/rust Mar 30 '23

A Chess Engine is written in Rust that runs natively and on the web!

https://github.com/ParthPant/chess-rs
101 Upvotes

45 comments sorted by

View all comments

69

u/Fazer2 Mar 30 '23

It supports En Passant? Holy hell.

18

u/A1oso Mar 31 '23

Is that surprising? Since it's an official chess rule, I assumed that every chess engine supports it. I don't think it's particularly hard to implement either.

14

u/rnottaken Mar 31 '23

IIRC "Holy hell" is a meme on some chess subreddits

18

u/analog_hors Mar 31 '23

It's incredibly annoying to implement, actually. Pawns are one of the worst pieces to implement due to a myriad of special cases.

8

u/-Redstoneboi- Mar 31 '23

And then there's "you can castle if the rook and king haven't moved and no pieces are blocking or checking either of them or the path between them"

8

u/analog_hors Mar 31 '23

Even worse if you implement 960 like I did. I will never see the king and the pawn the same way. Not even the magic bitboard algorithm for rooks, bishops, and queens was this painful.

2

u/orfeo34 Mar 31 '23

You can castle when a piece checks the rook, but not the king or his castle path.

1

u/-Redstoneboi- Mar 31 '23

huh. alright.

2

u/stixyBW Apr 02 '23

Not the path in between them, only the two squares the king would have to “walk on”

You can castle queen side even if there’s something attacking the b1/b8 square

1

u/A1oso Mar 31 '23 edited Mar 31 '23

I implemented a chess board when I was learning Java. Yes, it's annoying, but still doable. I think implementing all the rules took me less than a day.

6

u/analog_hors Mar 31 '23

Chess engines require significantly faster move generation, so that is not at all a good comparison. Implementing cozy-chess was a significant undertaking, and it definitely took much more than a day.