Inspiration

Baba Is You is a 2D grid-based strategy game in which you move around blocks representing the rules of the game to change the rules and solve puzzles. Chess is also a 2D grid-based strategy game. Thus the idea for Baba Is Chess was born.

What it does

Baba Is Chess is a chess variant in which certain squares will transform pieces into a designated new piece. For example, if a knight lands on an "IS ROOK" square, it will become a rook. Baba Is Chess also comes with a configurable alpha-beta pruning bot that you can play against if you're by yourself.

How I built it

Baba Is Chess is written in "vanilla" TypeScript with a few libraries to help out. chessboard-element provided the chess board and chess.js powered the core of the game logic (though there's a decent amount of extra logic on top of it since the library doesn't support chess variants out of the box).

For the bot, I wrote a standard alpha-beta pruning implementation, plus I used web workers to make sure the page was still interactive during the search. The evaluation feature uses the same code as the bot, though it will usually run in a separate worker (assuming the user has multiple cores in their CPU) so that they don't fight each other for resources as much.

Challenges I ran into

After I had the concept, actually deciding on the mechanics was a bit tricky. At first I wanted to do something more like how Baba Is You actually works where the pieces would have words on them and moving pieces would change the rules of the game, though there unfortunately aren't enough squares on the board for that to work very well. I also had an idea for a "moves like" version where pieces don't change into other pieces and instead just move like them, but at the end of the day I think this version is a bit more interesting. Then of course I had to decide on the board layout, which took a few iterations before I had something I liked.

From a technical perspective, trying to get chess.js to do what I wanted was not trivial and required a lot of experimentation. It's very nice for setting up standard chess games in a browser (and even some variants like Fischer random chess which follow the same basic rules), but it struggles with more interesting variants. I had to do quite a bit of work trying to get the bot performance to acceptable levels for the "very hard" bot (and I couldn't make an even harder bot due to performance limitations).

Accomplishments that I'm proud of

Baba Is Chess is a surprisingly interesting game for being a joke chess variant I came up with at a hackathon. Also, the bots are actually kind of hard to beat.

What I learned

I learned a lot of the ins and outs of chess.js (debugging required reading quite a bit of source code...). I also re-learned how to implement alpha-beta pruning, which is nice since it's been a couple years since I took an AI class.

What's next for Baba Is Chess

Putting it on the internet for people to play!

Built With

Share this project:

Updates