Bonanza Shogi Engine


Bonanza Windows binary (.exe only; get support files from regular Bonanza download.)
Bonanza source code (Contains instructions for compiling on Linux in readme.txt file.)
WinBoard GUI for Chess, Shogi, Xiangqi (and a lot more)
XBoard Shogi App for OSX/Mac, including the enhanced Bonanza engine
BCMgames GUI for Shogi, Xiangqi, Chess

Home   Shogi Home

Bonanza for interactive analysis of Shogi games

Bonanza is one of the strongest Shogi engines that currently exists, and can be regularly found amongst the top-4 finishers of the Computer-Shogi world Championship. The original version of the engine does not support any standard protocol through which it can be operated as a console application, however. It does support the CSA netwerk protocol to connect to a server. But to be operated from the command line it uses its own, unique set of commands (the so-called 'Bonanza protocol').

There exists an adapter (u2b.exe) to run Bonanza as a USI engine. But the translation of USI to Bonanza protocol can only be imperfect. For instance, in USI time is comunicated in msec, but in Bonanza protocol the resolution is only seconds, so that severe precision loss occurs on rounding. This really hurts in bullet games. Other problems are that Bonanza does not have commands for every feature of USI.

Interactive analysis

For interactive analysis a number of features are very important: it should be possible to force the engine to calculate multiple variations (for each iteration), rather than just the best (as would be enough for playing a games). This is known as 'multi-PV'. Another feature is the possibility to exclude moves from the analysis (e.g. because you recognize them as strategically poor, which the engine would only see at very large deoth or not at all, in the mean time wasting time on them). Also important is the possibility to play and take back moves while the analysis goes on.

XBoard showing engine-output with header to control multi-PV setting.

Bonanza protocol does have commands for multi-PV, and it also had a feature to exclude moves. With Bonanza Feliz the excluded moves would have to be supplied in a file, however, which would make it very cumbersome to change them from position to position. In Bonanza 6.0 excluding moves was no longer possible in console mode, although it was still possible in some of the network /cluster modes. Furthermore, Bonanza protocol did not really have a command to analyze a given position. The only way was to let it think on the position, but that would always result in Bonanza playing an unwanted move. And there was no command to take a move back at all. In ponder mode Bonanza would not think about the current position, but on the position that would result from a speculative move.

So I started by extending Bonanza protocol with an 'undo' command to take back a move, and an 'analyze' command to ponder on a position indefinitely, i.e. until the arrival of another command. The 'move' and 'undo' command will not terminate analysis, however, but just cause it to continue / resume on the new position. The 'mpv' commands to change the multi-PV settings will likewise not terminate analysis. All other commands will, including a newly added 'exit' command that will only do that.

A WinBoard version of Bonanza

Excluding a Chess move.

I also added a command 'xboard', which will switch Bonanza to communicating in XBoard/WinBoard protocol. It then supports a sort of minimal set of WB commands, enough to play games under the standard WinBoard time-control modes, and do interactive analysis. (Most important command that is still missing is 'remove', to take back a move in engine-human games.) This makes it possible to directly run Bonanza (i.e. without adapter) as a engine under WinBoard/XBoard or BCMshogi/BCMgames.

In particular, this version of Bonanza supports the 'exclude' / 'include' commands of WB protocol. This means it is possible to exclude specified moves from analysis, or re-include them, when Bonanza is running as an engine under the WinBoard GUI. Such exclusion would last until you move to another position.

WinBoard supports various methods to exclude moves; when you are analyzing, any move you play with the Ctrl key pressed, will be taken as a move to be excluded rather than a move to be played. The same happens when you grab a piece for dragging with a double-click. Both these methods actually toggle the exclusion state of the move. Once you start excluding moves, these will appear as a list in the Engine Output window header, pefixed by '-' (when they are excluded) or '+' (when they are included), so that you can keep track of what you are doing. Also from there it is possible to toggle the exclusion state, by right-clicking on the move in the list. A special case is 'best', occurring as the first element of this list; right-clicking that will always exclude the current best of all non-excluded moves. Repeated clicking of this can be used to build up a list of the most likely moves.

The number of PVs shown can be controlled by right-clicking on the words 'more' and 'fewer' in the Engine Output window header. This does not alter the exclusion state of any move, it just shows you more included moves. It can also be changed in WinBoard's Engine Settings dialog, but this is far more cumbersome. Bonanza also has a multi-PV margin, below which it would not show the moves. E.g. if you asked for 4 PVs, but only the first two recapture a piece that has to be recaptured, so that the others lose more than the specified margin compared to the best, only the two 'sensible' PVs will be shown. This margin can only be set from the Engine Settings dialog (but there usually is little reason to change it from position to position).

Regular Shogi of course is a bit bigger than this, but you get the idea.

Variation board

WinBoard offers a method to preview on the board what the engine considers the best continuation (the Principal Variation, PV for short). This can be done by right-clicking the board, and moving the mouse pointer vertically with the right button kept down. This motion lets you step through the last principal variation that the engine printed, move by move. When you release the mouse button, the display goes back to showing the current position.

You can also select which PV you want to examine this way, e.g. PVs calculated at lower depth than the most recent one, or PVs belonging to 'sub-optimal' moves at the same depth, when you are running in multi-PV mode. To do that, you would have to right-click the PV you want to play through in the Engine Output window. Be careful, though: WinBoard has a mode where it would automatically add moves of a PV you select that way to the game, so that when you release the mouse button, you would not return to the position the engine was analyzing, but stay in the position you were viewing. (In WinBoard 4.8.0 and later, this adding of moves is only done when you click on the later moves of the PV you want to select for display; when you right-click the first move or in front of it, it will never add moves, but always returns to the original position when you release the mouse button.) This is an easy way to advance the game in the way the engine thinks it should, and sets the engine analyzing on a position near the end of this prediction, to check if it all works out as the engine expected. If it was not your intention to alter the game, you should take care to return to the original position at the start of the PV before releasing the mouse button. The PV walk will start after the first move of the PV, so a static right-click on one of the PVs in the Engine-Output window would make you play the corresponding move, and analyze from there.

XBoard Shogi App for Apple Mac

XBoard, the Linux/OS X version of WinBoard, is now also available as an OS X App, which also contains a number of engines, ready to run 'out of the box'. There also is a Shogi version of this OS X App, which contains the enhanced Bonanza engine, where XBoard is pre-configured to use an oriental board theme, see the screenshot below. These Apps were created from the source codes mentioned here by Joshua Pettus. These Apps can be downloaded from the WinBoard forum.