Creating an AI to play Hive with Mzinga, Part I

by Jon

I first started playing chess seriously in college, and I learned just enough to realize that I wasn’t going to be able to commit to the kind of study that makes a great chess player. I even built a super weak chess AI in Matlab that just made random moves. More recently I’ve gotten back into playing over at (hit me up for a game), and when I was looking for a side project last winter, I peered back into the deep and treacherous waters of chess AI programming.

But I’d already built a chess AI (dumb as it was) and wanted to do something new. Then it occurred to me that I could try to make an AI for another game I love to play, Hive.

What is Hive? Hive is an abstract board game (like chess) where the pieces are different kinds of bugs. Each bug moves in a certain way, and the goal is surround your opponent’s Queen Bee before they surround yours. Like chess in many ways, but simpler and more approachable to many people.

So I started looking around to see if anyone had already created any Hive AIs. While there is some software for playing Hive (play Hive online at Boardspace, with the PC game from BlueLine Games, or via various mobile apps) and that software usually has an AI player to play against, I couldn’t find anyone specifically trying to make a strong Hive AI player.

The chess world on the other hand, is loaded with people trying to make better chess AIs. The amount of available chess AIs (see this list of chess engines for example) and publicly available research material (see the Chess Programming Wiki) is simply astonishing.

One of the coolest aspects of it is the separation of the chess engine (where the AI does its work) and the UI (which just displays the game). There are well established protocols that chess engines can implement (such as the Chess Engine Communication Protocol or the Universal Chess Interface) to specify how you ask a chess engine to evaluate a board and pick the best move. This means that by implementing these protocols, chess programmers don’t have to agree on what programming language to use, or waste time making pretty interfaces. They can focus on the guts of their engine, using whatever tools they want, and they’ll be able to participate in games against both humans and other chess engines.

It’s with that model in mind that I started work on Mzinga.

Mzinga 0.9 ScreenshotMzinga is an open-source AI to play the board game Hive. It is architected similar to various chess-playing AIs, consisting of:

  • A set of standardized commands similar to the Universal Chess Interface
  • An command-line reference engine, which accepts the standardized commands
  • A general board UI which can interface with any engine that implements the standardized commands

The goal is not to simply implement Hive in code, but to establish a standard way for programmers to create their own AI players. The hope is that this will encourage explorations around Hive AI.

It’s written in C# (see the Mzinga source on GitHub) and runs on Windows 7 and above. You can play player vs. player, player vs. cpu, or cpu vs. cpu. It’s very beta – the included AI is not very strong, and the UI is a little bare, but it is very playable. Check it out and let me know what you think!

Stay tuned for Part II, where I go more into detail about how the AI works and what I’m doing to improve it.

Try out Mzinga today!


Update (14-JUL-2016): Creating an AI to play Hive with Mzinga, Part II is up.