DarkTemplar dissected..!!


posted Feb 15, 2012, 10:00 PM by Binesh Andrews   [ updated Feb 15, 2012, 10:44 PM ]

And more..

I hosted a repository for the code on github.

Some delta modifications...

posted Feb 6, 2012, 9:10 PM by Binesh Andrews   [ updated Feb 6, 2012, 9:12 PM ]

Just realized that I didn't turn on the compiler optimizations in the makefile. Who doesn't want a "free" speedup?!

The Makefile in the repository is updated incorporate that and I can see tangible results straightaway. I don't mean that the engine suddenly became lightning fast, but there is improvement. Something is better than nothing!!

Source Code

posted Oct 30, 2011, 10:40 PM by Binesh Andrews   [ updated Oct 30, 2011, 10:41 PM ]

Well, accidentally noticed that the binaries for this engine was linked from a few chess forums recently. It was quite surprising considering the fact that the whole project and the website was lying dormant for more than an year.

That makes me more motivated to improve the engine. Unfortunately it seems that I won't be able to dedicate any time for this. I am posting a git repository with the source code hoping that some beginners might benefit from some tricks there.

Here is the location:

Using DarkTemplar to solve Mate-in-2 puzzles...

posted Aug 8, 2010, 8:24 AM by Binesh Andrews   [ updated Aug 8, 2010, 8:31 AM ]

DarkTemplar can be used to solve mate-in-2 puzzles. The "edit position" functionality interface for winboard is implemented by DarkTemplar.


a) Select the "edit position" from the mode menu.
b) Setup the desired board position 
c) Select "Two machines" from the mode menu... and DarkTemplar will attempt to solve the puzzle for you.

[NB: [The side currently having the next turn to play (before edit) will be the side to move next after the edit.]

The following  screenshots show how DarkTemplar solve a couple of puzzles available on the Internet.
[The squares with the yellow border shows the suggested first move]

a) White to move and mate in 2.

b) White to move and mate in 2


posted Aug 8, 2010, 3:41 AM by Binesh Andrews   [ updated Aug 8, 2010, 3:51 AM ]

Making life easier...

posted Aug 7, 2010, 10:09 AM by Binesh Andrews   [ updated Aug 7, 2010, 10:27 AM ]

To save effort setting up DarkTemplar on Winboard, I have included a Winboard 4.4 bare executable in the download section. This is the same one which can be dowloaded from the link provided in the previous post.

These are the steps needed to get the engine running on winboard.

1) Download and extract to a convenient location (i.e. <path_to_darktemplar> )
2) Download and extract to any convenient location
3) Create a file, winboard.ini, in the same directory as winboard.exe which is generated during step-2. The contents of this file is as follows:

/firstChessProgramNames={"DarkTemplar_v01" /fd="<path_to_darktemplar>\bin\win32"
/secondChessProgramNames={"DarkTemplar_v01" /sd="<path_to_darktemplar>\bin\win32"
4) Start winboard.exe and start playing.

DarkTemplar v0.1 - Making it work!!

posted Aug 7, 2010, 6:26 AM by Binesh Andrews   [ updated Aug 8, 2010, 4:06 AM ]

Finally!! :-)

DarkTemplar v 0.1 is available for download now. Check out the Download page. This package contains the windows executable for DarkTemplar as well as 3 opening books to select from. A Linux executable(to work with XBoard) is not included in this package. This will be updated later.

[Note that this is a prototype version of DarkTemplar. This doesn't include the magic bitboard implementation for move generation. Advanced features like time control and pondering are not implemented yet. ]

This post will list out the steps required to get the engine working on your computer.

1) Download and unzip the package downloaded to any convenient folder.
2) Download and install the winboard / Arena GUIs. [I'll be concentrating on Winboard in this post. Arena configuration is equally simple. ]
3) Add DarkTemplar in the default engine list of the GUI.

Winboard can be downloaded from the Winboard Forum webpage: .

Arena can be downloaded from the Arena webpage:

Configuring and setting up Winboard for DarkTemplar:

After Winboard is downloaded and unpacked successfully, it is time to configure it to connect to and use our DarkTemplar engine.
The detailed steps on how to install a chess engine in Winboard is discussed here:

Using the shortcut method / command line:

<path_to_winboard>\winboard.exe" -cp -fcp "DarkTemplar_v01" -fd "<path_to_darktemplar>\bin\win32

Using the ini method, edit the winboard.ini:

"GNUChes5 xboard"
"DarkTemplar_v01" /fd="<path_to_darktemplar>\bin\win32"
"GNUChes5 xboard"
"DarkTemplar_v01" /sd="<path_to_darktemplar>\bin\win32"

Using DarkTemplar to play on the Internet:
Both Winboard and Arena allows chess engines to connect to and play games online using the ICS protocol. All the common chess servers like ICC ( and FICS( are supported along with a few others. You would require a "computer chess" account on any of these servers to start playing. Information on how to configure Winboard or Arena to play online can easily be found on the internet.

NB: DarkTemplar doesn't assure that it can play in the Blitz pace (40 moves in 5 mins). It is possible that the chess engine ends up forfeiting the game due to time crunch.

Engine configuration options:
Currently the only available configuration permitted for DarkTemplar is the opening book setup. The "openingBook" directory contains 3 polyglot opening books to select from. "Morphius201004.bin" is the book selected by default. You may try other books by copying it to the openingBook directory.
To select any book, edit the config.txt file to include the name.

  ------  ------  ------  ------  ------  ------  ------  ------  ------  ------  ------  ------  ------  ------  ------  ------  ------

Drop in a comment for assistance if you find it difficult to manage yourself.

Happy battling :-)

The chess engine communication protocol - Tethering the chess engine to the GUI..

posted Jul 11, 2010, 9:39 AM by Binesh Andrews   [ updated Jul 11, 2010, 10:45 AM ]

Every chess program would need a user interface to go with the engine. The user should be able to make moves, undo moves, setup a custom position, select a side to play, etc.

It would be a redundant effort if every chess programmer were to develop the user interface as well. Separating out the chess engine and the user interface is the typical solution. Thus, the chess programmer can concentrate on just the artificial intelligence required to make the computer play the game and not worry about the aesthetics of the user interface.

The "complete" chess program thus has atleast three modules.
a) The Chess GUI - i.e. The user Interface
b) The Chess Engine - The intelligence to make the computer play the game.
c) An interface between the GUI and the Engine

The roles of each of the modules are self-explanatory. Since there are a lot of information on the web already on this topic, I'll just include the pointers to the available information rather than attempting to rewrite all of them.

The interface between the GUI and the engine is standardized. There are 3 commonly used interfaces.

a) The Chess Engine Communication Protocol - This is designed by Tim Mann. More details can be found on Tim Mann's homepage. The protocol specifications can be found here.
b) The UCI (Universal Chess Interface) - Designed by Stefan Meyer-Kahlen, the author of the popular Shredder Chess Engine.
c) Chessbase Interface - This is a proprietary protocol (details not published) developed by the GmbH and is used in most of the strong commercial chess engines (eg: Fritz). Refer to the Wikipedia page for detailed information.

More details of all the chess engine protocol can be read from the computer-chess wiki article on the same topic.

Coming back to the GUIs available, we have:
a) Winboard(windows) and Xboard(Linux) - From Tim Mann, the author of the chess engine communication protocol. These are available now under the GNU public license. The GNU chess uses this interface. Details can be found on Tim Mann's website.
b) Arena - Supports Chess Engine Communication Protocol and UCI.

DarkTemplar will support the Chess Engine Communication Protocol to start with. UCI will be supported later. DarkTemplar would thus run under WinBoard, Arena (windows) and XBoard (linux).

Naming the engine..

posted Jul 11, 2010, 2:12 AM by Binesh Andrews

I've been on a lookout for a name for the chess engine; a name which express what the chess engine is all about. I was primarily looking for a tag which has something to do with being fearless, cunning, mysterious, etc.

DarkTemplar is what I finally ended up with. As Wikipedia quotes it (Ref: Knight Templar) :

"[A Templar Knight] is truly a fearless knight, and secure on every side, for his soul is protected by the armour of faith, just as his body is protected by the armour of steel. He is thus doubly armed, and need fear neither demons nor men."  - Bernard de Clairvaux, c. 1135, De Laude Novae Militae—In Praise of the New Knighthood.

The DarkTemplar has its roots from StartCraft. DarkTemplars are warriors who are individualistic, but band together during times of adversity. They wield the energies of "the Void" and have the abilities of  "bending light" and "merge with the shadows". They are driven by a thirst for knowledge.

See more information from the StarCraft Wiki .

Thus, this chess engine advertises itself as being skilled, fearless and strong.  The "Dark" in the name brings in the mystery and stealth.

I am sort of settled for this name; and going forward, the "DarkTemplar" is what we all will be hearing about. :-)

Setting the goals..

posted Jul 9, 2010, 1:35 AM by Binesh Andrews   [ updated Aug 6, 2010, 11:31 AM ]

DarkTemplar is a Winboard-UCI compatible chess engine. The intention here is to create a moderately strong chess engine which implements most of the ideas/techniques used in a modern chess engine. This chess engine is expected to take the form of a pedantic chess engine rather than an obscure highly-optimized one.

The following functionality is being planned for DarkTemplar over the course of its development.

  • Support for Winboard/UCI interface - Winboard and Arena GUIs.
  • Support for Polyglot opening books
  • Standard Arithmetic notation (SAN, eg: Nf3) and Standard Co-ordinate Notation (eg: g1f3)  for recording and parsing moves.
  • Support Forsyth-Edward Notation(FEN) for representing and re-creating board positions.
  • Fast pseudo-legal move generation - Use bitboards (magic bitboards) to quickly generate the pseudo legal moves(including en-passent, pawn promotion and castling) for a given board position [DeBruijn and other hashing techniques, maximum 840KB of attack tables.]
  • X-ray attacks, discovered checks, checkmate, stalemate, 3-move draw, 50-move draw detection.
  • Alpha beta pruning for the nega-max search tree - This is a very basic requirement to fasten the decision making phase of the engine.
  • Initial move ordering and aspiration window search for better pruning performance.
  • Zobrist hash and support for transposition tables
  • Quiescence search
  • Static board evaluation based on piece values, king safety and pawn structure.
  • Offer/accept draws, resign judiciously.
  • Timed move support.
  • Pondering
  • Support for end game tables (EGTBs)  (Nalimov 3-4-5-6 men EGTB?).
  • [Optional:  null move / killer move heuristics ]

Language: C/C++ (ISO C++ with makefile to build on Win32 and linux)
Version Control: Online-CVS from (mostly)
Bugs : Bugzilla (mostly)

1-10 of 10