DEV Community

Cover image for Kamisado, a JavaScript Implementation of an Abstract Board Game.

Kamisado, a JavaScript Implementation of an Abstract Board Game.

I have a problem. I have way too many unfinished side projects in my ~/dev folder. So I wanted to build something quick, and commit to releasing it and showing it off as quickly as possible. So here it is!

For the best experience, click here to go to CodePen's Full screen view. But I've embedded it here for your convenience.

I've built it using p5.js, mainly so I wouldn't have to deal with the raw canvas API.

About Kamisado

Kamisado is an abstract board game for 2 players, played on a grid with differently colored squares. Each player has 8 pieces, each one corresponding to a tile color.

The first player, white, can choose which piece to move. After the first move you must always move your piece that corresponds to the color of the square the last player moved to. You can move a piece as far as you want straight forwards, or diagonally forwards. Never sideways or backwards.

You win by moving one of your pieces to the opponent's home row.

Known shortcomings

This version only includes the short mode of Kamisado. In the real game, you can continue playing once you've reached the other side, by turning your piece into a sumo that can push other pieces. I might build upon this version to add this in the future.

The code isn't very pretty. I've used snake-cased capital letters for global variables, rather than for constants, as they're usually used in JavaScript. I've also written purely procedural code (no classes), and I don't think the structure is as good as it could be.

Roadmap

I'd like to write a post here on board game AI, and would like to implement a simple AI for Kamisado as an example. I'll work on this during the next week.

I'd also like to allow people to play over the internet. I'm trying to decide whether to implement this using firebase or a WebRTC data channel.

Top comments (3)

Collapse
 
yokim profile image
Yokim Pillay

Great job! I've never heard of this before, sounds like a really fun concept!

Collapse
 
_bigblind profile image
Frederik 👨‍💻➡️🌐 Creemers

I hadn't heard about it either before last week. I was looking for a game that was longer and a little bit more interesting than tic-tac-toe, but still fairly short and simple.

I'd like to write an article, possibly a series of articles, on algorithms for board game AI, and I was looking for an interesting game to implement where minimax, without having to cut it off at a certain depth. The games with the simplest rules are often abstract games, so I googled abstract games, and this was one of the first ones that came up.

Collapse
 
yokim profile image
Yokim Pillay

That's super fascinating! I'm looking forward to your next articles :)