Game Loop Mostly Finished

I’ve been hard at work on the Bird Chess (tori shogi) game, all week. I typed my fingers raw, braving carpal tunnel and coder’s block. Waking at odd hours of the night and morning just to fit a few more LOC’s in.

And what do I have to show for it?

I’ve finished hooking up the interface for the first AI. Also, I’ve got most of the initial game loop finished. And I managed to detect wins.

This all means that I can now play a game against a partially implemented AI. Neither the AI or I actually play by the rules, but one of us wins every time.

Okay. I win every time. I may have “forgotten” to tell the AI it is supposed to capture the Phoenix to win the game 😉 But, the AI has fun capturing swallows while I win.

There is still tons of work to do, though. My next step is to revisit the computer-generated, optimized, moves arrays. That will allow me to enforce most of the rules of the game. The moves arrays are likely to take me well into December.

Keep checking back for my tori shogi progress.

Alpha-Beta Pruning Finished

I’m still hard at work on the Tori Shogi web app. The game AI is moving along nicely. My big accomplishment for this week is that I finished a generic ClojureScript Alpha Beta Pruning library for use with the Tori Shogi game and other games that I write later on.

Alpha Beta Pruning is built on the MinMax algorithm. MinMax is a Game Theory methodology for figuring out the best move in two-player games of perfect information. I’ve only written unit tests for three plies. I’ll do deeper tests later on and then move on to refine and optimize the Alpha Beta Pruning with some extra improvements when I write the more advanced AI’s.

Yeah, … I’m sure that is all exciting and all. However, the point is that the Bird Shogi game is moving along now that I have this important part of the first AI finished. Keep checking back for more information on my Tori Shogi progress.

Also, if you are a Clojure / ClojureScript geek who wants to get ahold of my source for the Alpha Beta Pruning library, check over at https://makeonlinegames.com/ I’m sure I’ll post more information there once I have the source up on GitHub.

Delving into Tori Shogi

I have never played tori shogi. It’s a fascinating game written back about 200 years ago in Japan by an expert swordsman. As a game, several master shogi players have played tori shogi seriously, but not anywhere near as many as should have.

My personal journey towards tori shogi started decades ago. I’ve been playing shogi for many years. I actually picked up shogi from a Japanese friend of mine back in the early 1990’s. He was sick of me beating him in chess, so he pulled out a shogi board he had had his parents send him from Japan. He said, he could beat me a few times in shogi and even up the score.

He definitely beat me in shogi. We played many times after that, and when we parted ways, he gave me his shogi board as a gift. I still have that shogi board and taught all my children shogi using it.

Fast forward to the late 2010’s and I’ve written several versions of shogi AI’s. I wrote them mostly because it was so hard to find good opponents to play shogi against. I probably never would have written my first shogi AI if not for being completely unable to find opponents back in the 2000’s.

I actually snagged a lot of the old code from the shogi AI I wrote back then and put it into the online shogi prototype over at japanesechess.org. That one is really just a prototype I threw together from old code with a couple of weeks of work. The AI is a bit crippled by being rewritten in JavaScript. (Running a shogi AI in a web browser does not provide nearly the resources that running a shogi AI in a desktop app does.) Also, I didn’t use a good algorithm for the shogi AI, so I groan whenever I play it.

Now, I’m interested in learning tori shogi. I don’t have many options for opponents in my area, so I’m going to write a tori shogi game and AI. I’ve actually got a fair way along in writing my new tori shogi game. I’ve written the code for the tori shogi board and tokens. I’ve also hooked up the UI code to the ClojureScript code that will be the brains of the game and the AI.

One of the key piece of the tori shogi AI is called the Alpha-Beta Pruning library. I’m writing that today in ClojureScript for use in the tori shogi game I’m making for my funwebgames.net site. Alpha-Beta algorithms are used for most board games in the shogi and chess genres, so I can reuse this library for other games after I finish writing the tori shogi AI.

This piece of the shogi AI should look fairly elegant when I’m done writing it, but I’ll have to write quite a few tests to make sure I get it right. I should have the library working some time later today.

Wish me luck on my tori shogi AI!

Tori Shogi

What is togi shogi? Why it is Japanese bird chess, or bird shogi, depending on who you ask. I defer to wikipedia on this one.

Tori shogi (禽将棋 or 鳥将棋, ‘bird chess’) is a variant of shogi (Japanese chess), which was invented by Toyota Genryu in 1799 despite being traditionally attributed to his master Ōhashi Sōei. It was first published in 1828 and again in 1833. The game is played on a 7×7 board and uses the drop rule; it is the only traditional shogi variant, possibly besides wa shogi, to do so. This is one of the more popular shogi variants. There were tournaments in London and Royston in the 1990s and early 2000s.

That should clear things up a bit.