I’m delighted to host another new engine at ChessProgramming.net. The Baron recently played at the WCCC in Leiden. It was operated by Richard’s delightful daughter Tessa. I’m not sure of the exact playing strength of The Baron but it’s certainly strong. It’s a full feature engine with SMP support and a comprehensive evaluation function. This version dates back to February 2012. You can find out more on The Baron’s own page.
Enjoy!
https://i0.wp.com/www.chessprogramming.net/wp-content/uploads/2015/07/The-Baron.png?fit=180%2C180&ssl=1180180Steve Maughanhttp://www.chessprogramming.net/wp-content/uploads/2015/05/ChessProgramming-Logo-20151-300x138.pngSteve Maughan2015-07-07 21:15:242015-07-07 23:36:45New Engine - The Baron
I’m delighted to give you this guest post by Niklas Fiekas, the creator of Python Chess. You may think Python Chess is just another chess engine. It isn’t. It’s a library of routines which can manipulate and analyze chess data using Python. After I learnt about Python Chess I immediately went to Code Academy and took their course on Python. I really see this set of tools becoming a key part in any testing or development frame-work.
Over to Niklas…
Python-chess by example: Automating the Bratko-Kopec Test
Decades ago (1982) Kopec and Bratko published a systematic test for assessing the strength chess-playing programs (pdf). Despite its age it can still be fairly challenging, even for modern chess engines. Of course 24 test positions are not going to be enough for a definite result, especially given that most positions are of a specific type: fairly closed and the solution often involves some kind of sacrifice.
For each of the 24 positions a unique best move is known. The engine is given 120 seconds to solve each position. 1 point is awared for the correct best move.
The positions are given as EPDs. In this article we are going to automate the process of testing an UCI engine, introducing python-chess along the way.
1k1r4/pp1b1R2/3q2pp/4p3/2B5/4Q3/PPP2B2/2K5 b - - bm Qd1+; id "BK.01";
3r1k2/4npp1/1ppr3p/p6P/P2PPPP1/1NR5/5K2/2R5 w - - bm d5; id "BK.02";
2q1rr1k/3bbnnp/p2p1pp1/2pPp3/PpP1P1P1/1P2BNNP/2BQ1PRK/7R b - - bm f5; id "BK.03";
...
r2qnrnk/p2b2b1/1p1p2pp/2pPpp2/1PP1P3/PRNBB3/3QNPPP/5RK1 w - - bm f4; id "BK.24";
And calculate for two minutes. The result is the best move (according to the engine) and an optional ponder move (the expected reply the engine wants to ponder on).
#!/usr/bin/python
import chess
import chess.uci
import sys
def test_epd(engine, epd):
position = chess.Bitboard()
epd_info = position.set_epd(epd)
engine.ucinewgame()
engine.position(position)
enginemove, pondermove = engine.go(movetime=120000)
if enginemove == epd_info["bm"]:
print "%s (expecting %s): +1" % (
epd_info["id"],
position.san(epd_info["bm"]))
return 1.0
else:
print "%s (expecting %s): +0 (got %s)" % (
epd_info["id"],
position.san(epd_info["bm"]),
position.san(enginemove))
return 0.0
if __name__ == "__main__":
engine = chess.uci.popen_engine(sys.argv[1])
engine.uci()
epds = """\
1k1r4/pp1b1R2/3q2pp/4p3/2B5/4Q3/PPP2B2/2K5 b - - bm Qd1+; id "BK.01";
3r1k2/4npp1/1ppr3p/p6P/P2PPPP1/1NR5/5K2/2R5 w - - bm d5; id "BK.02";
2q1rr1k/3bbnnp/p2p1pp1/2pPp3/PpP1P1P1/1P2BNNP/2BQ1PRK/7R b - - bm f5; id "BK.03";
rnbqkb1r/p3pppp/1p6/2ppP3/3N4/2P5/PPP1QPPP/R1B1KB1R w KQkq - bm e6; id "BK.04";
r1b2rk1/2q1b1pp/p2ppn2/1p6/3QP3/1BN1B3/PPP3PP/R4RK1 w - - bm Nd5; id "BK.05";
2r3k1/pppR1pp1/4p3/4P1P1/5P2/1P4K1/P1P5/8 w - - bm g6; id "BK.06";
1nk1r1r1/pp2n1pp/4p3/q2pPp1N/b1pP1P2/B1P2R2/2P1B1PP/R2Q2K1 w - - bm Nf6; id "BK.07";
4b3/p3kp2/6p1/3pP2p/2pP1P2/4K1P1/P3N2P/8 w - - bm f5; id "BK.08";
2kr1bnr/pbpq4/2n1pp2/3p3p/3P1P1B/2N2N1Q/PPP3PP/2KR1B1R w - - bm f5; id "BK.09";
3rr1k1/pp3pp1/1qn2np1/8/3p4/PP1R1P2/2P1NQPP/R1B3K1 b - - bm Ne5; id "BK.10";
2r1nrk1/p2q1ppp/bp1p4/n1pPp3/P1P1P3/2PBB1N1/4QPPP/R4RK1 w - - bm f4; id "BK.11";
r3r1k1/ppqb1ppp/8/4p1NQ/8/2P5/PP3PPP/R3R1K1 b - - bm Bf5; id "BK.12";
r2q1rk1/4bppp/p2p4/2pP4/3pP3/3Q4/PP1B1PPP/R3R1K1 w - - bm b4; id "BK.13";
rnb2r1k/pp2p2p/2pp2p1/q2P1p2/8/1Pb2NP1/PB2PPBP/R2Q1RK1 w - - bm Qd2; id "BK.14";
2r3k1/1p2q1pp/2b1pr2/p1pp4/6Q1/1P1PP1R1/P1PN2PP/5RK1 w - - bm Qxg7+; id "BK.15";
r1bqkb1r/4npp1/p1p4p/1p1pP1B1/8/1B6/PPPN1PPP/R2Q1RK1 w kq - bm Ne4; id "BK.16";
r2q1rk1/1ppnbppp/p2p1nb1/3Pp3/2P1P1P1/2N2N1P/PPB1QP2/R1B2RK1 b - - bm h5; id "BK.17";
r1bq1rk1/pp2ppbp/2np2p1/2n5/P3PP2/N1P2N2/1PB3PP/R1B1QRK1 b - - bm Nb3; id "BK.18";
3rr3/2pq2pk/p2p1pnp/8/2QBPP2/1P6/P5PP/4RRK1 b - - bm Rxe4; id "BK.19";
r4k2/pb2bp1r/1p1qp2p/3pNp2/3P1P2/2N3P1/PPP1Q2P/2KRR3 w - - bm g4; id "BK.20";
3rn2k/ppb2rpp/2ppqp2/5N2/2P1P3/1P5Q/PB3PPP/3RR1K1 w - - bm Nh6; id "BK.21";
2r2rk1/1bqnbpp1/1p1ppn1p/pP6/N1P1P3/P2B1N1P/1B2QPP1/R2R2K1 b - - bm Bxe4; id "BK.22";
r1bqk2r/pp2bppp/2p5/3pP3/P2Q1P2/2N1B3/1PP3PP/R4RK1 b kq - bm f6; id "BK.23";
r2qnrnk/p2b2b1/1p1p2pp/2pPpp2/1PP1P3/PRNBB3/3QNPPP/5RK1 w - - bm f4; id "BK.24";"""
score = 0.0
for epd in epds.split("\n"):
score += test_epd(engine, epd)
engine.quit()
print "-------------------------------"
print "%g / 24" % score
Congratulations Maverick 0.51 x64! On my machine you score 18/24, which is almost on a par with Stockfish 6 64’s 19/24.
The original Brato-Kopec test has one more rule: Sometimes the engine changes its mind. If it had the solution at the 30, 60 or 90 second mark but then discarded it, 1/4, 1/3 or 1/2 points are awarded. In order to do this we need to look at the engines principal variations while it is thinking. This is included in the full code of this example.
I’m pleased to be able to release Maverick 1.0. This version adds considerable selectivity to the search. It has a basic implementation of Late Move Reduction and Beta pruning. In my tests it is about 2500 ELO on the CCRL scale, so it’s time to give it the 1.0 version number.
A full list of changes are:
Added Late Move Reduction
Added beta pruning (inspired by Senpai)
Added unstoppable pawn code
Added king and pawn endgame knowledge
Added knight outpost bonus
Added refutation moves to the move ordering
There are also ARM and Linux version included for the first time (thanks Jim Ablett)
I’m pleased with the style of play. Maverick aggression coupled with its positional naivety makes for interesting play! If you play against chess engines I’d be interested in any feedback.
You can download Maverick 1.0 from the Download Page
https://i0.wp.com/www.chessprogramming.net/wp-content/uploads/2015/04/Maverick-1.0.png?fit=100%2C100&ssl=1100100Steve Maughanhttp://www.chessprogramming.net/wp-content/uploads/2015/05/ChessProgramming-Logo-20151-300x138.pngSteve Maughan2015-04-23 07:28:022015-05-12 00:32:48Maverick 1.0 Released
Made a bazillion tweaks which may, or may not, help!
In self play matches against 0.51 it shows an improvement of about 50 ELO. I’m hoping this will translate to a real-world strength increase of at least 30 ELO.
I’m now about to start working on improving the selective search!
Last week Microsoft release a Community Edition of Visual Studio 2013. This is a free version of the Professional edition of Visual Studio 2013. Previously Microsoft’s free edition was Visual Studio Express. This only compiled to 32 bit and didn’t include a Profiler or Profiler-Guided-Optimization. The new Community Edition includes all of these goodies and can generate 64 bit executables. This is a big deal for chess programmers. It means you can easily develop and test your engine from within the same high quality development environment (I know we’ve always had GCC but this is more integrated than the mishmash of open source tools).
There are some constraints on who can use the Community Edition. You can only use it if your engine isn’t commercial, or if it brings in less than $1 million per year – I’m sure that covers every chess engine developer!!
The Holiday season is coming. I’m hoping to have more time to dedicate to chess programming. For the last six months I’ve been swamped with work – but I think there is a light at the end of the tunnel. More updates to come.
https://i0.wp.com/www.chessprogramming.net/wp-content/uploads/2014/11/visual-studio-150x150.png?fit=150%2C150&ssl=1150150Steve Maughanhttp://www.chessprogramming.net/wp-content/uploads/2015/05/ChessProgramming-Logo-20151-300x138.pngSteve Maughan2014-11-18 22:22:382015-05-11 22:58:40Free Version of Visual Studio Professional 2013
I’m excited to let everyone know about two new engines which are to be hosted on this blog.
The first engine is Fruit Reloaded. This is fork of Fabien Letouzey’s Fruit 2.1. Most of the new development (including SMP search) has been done by Daniel Mehrmann and Ryan Benitez. You can find out more here:
The second, engine is a big surprise. Fabien himself has been dabbling once again in chess programming. He’s come up with a brand new engine – Senpai! It’s a bitboard engine (Fruit was array based) with SMP search. I ran some quick tests on a beta version and Senpai 1.0 drew a 150 game match against Chiron 2.0. Although this is a small sample of only one engine, it implies a rating of approximately 3100 ELO on the CCRL scale. You can find out more about Senpai here:
https://i0.wp.com/www.chessprogramming.net/wp-content/uploads/2014/03/senpai.png?fit=100%2C100&ssl=1100100Steve Maughanhttp://www.chessprogramming.net/wp-content/uploads/2015/05/ChessProgramming-Logo-20151-300x138.pngSteve Maughan2014-03-17 13:04:002015-05-11 23:01:46Two New Engines Hosted on ChessProgramming.net
When it comes to Maverick’s evaluation function I’m frustrated and excited in equal measure!
My focus over the last couple of months has been to improve Maverick’s evaluation function. However I’ve found it quite difficult to improve on Maverick 0.51’s actual playing strength. Adding extra knowledge (e.g backward pawns) seems to add little in terms of playing strength. I’m struck by the massive number of ways to encode chess knowledge. I feel like a blind archer as I make wild guesses trying to calibrate the parameters.
There must be a better way!
Early on in Maverick’s development I came across Thomas Petzke‘s approach to tuning evaluation function. He uses a form of genetic algorithm (PBIL) to tune the parameters. PBIL optimization algorithms are really neat – they represents each number in binary format. Each bit of each number is represented as a floating point value between zero and one. As the system “learns” the floating point values are “trained” and gravitate to either zero or one based on the training data. In Thomas’ case he played a few games of chess to assess the fitness of a set of parameters. This is expensive – but ultimately game-playing-ability is the attribute we’d like to optimize. Sp maybe the training time is justified.
Back in 2000 I worked a lot with standard genetic algorithms. I used them to evaluate marketing campaigns. I think PBIL may be even better for evaluating marketing campaigns (but that’s a story for another day). I’m certainly interested in using them to tune Maverick’s evaluation function. The only problem is Thomas’ method take ages to complete (weeks!). I’d prefer a method which is quicker.
Then I came across a post on CCC by Peter Österlund:
Peter outlines a new way to tune an evaluation function. His approach takes 2.5 million chess positions and minimizes the following fitness function:
E = 1/N * sum(i=1,N, (result[i] – Sigmoid(QuiescientScore(pos[i])))^2)
This is really quite interesting for the following reasons:
Since we’re not playing complete chess games this runs *much* faster – maybe less than one day of computing time
The sigmoid function is *really* sensitive in the -100 to +100 centipawn range. This is a critical region where virtually all games are decided. If we can create an evaluation function which accurately evaluated this range then we’re likely to have a strong chess engine
I suspect Houdini uses a similar technique to calibrate its evaluation function since it’s evaluation is linked to the probability of winning. Robert Houdart mentions this on his website, “Houdini 4 uses calibrated evaluations in which engine scores correlate directly with the win expectancy in the position. A +1.00 pawn advantage gives a 80% chance of winning the game against an equal opponent at blitz time control. At +2.00 the engine will win 95% of the time, and at +3.00 about 99% of the time. If the advantage is +0.50, expect to win nearly 50% of the time“
Some people have tested this approach to training have reported good results
When tested the pawn evaluation parameters (resulting from the PBIL optimization) they have varied considerably between the middlegame and endgame. The middlegame value of a pawn is 50 centipawns, while the endgame value is +145 centipawn. If these values are robust and uses in normal play they are likely to produce exciting chess where the engine is happy to sacrifices a pawn for a modest positional advantage. This sounds like the recipe for an interesting engine – which is one of the goals for Maverick!
So I’m in the process of rewriting Maverick evaluation code to accommodate the PBIL algorithm. I’m also writing a PGN parser (in Delphi) so I can train the evaluation function using different sets of training positions.
With all of this re-writing it may be a little while before I can release a new version of Maverick. My aim is still to take Maverick to 2500 ELO using only an improved evaluation function!
I’ll keep you posted!
https://i0.wp.com/www.chessprogramming.net/wp-content/uploads/2014/03/600px-Logistic-curve.svg_-150x150.png?fit=150%2C150&ssl=1150150Steve Maughanhttp://www.chessprogramming.net/wp-content/uploads/2015/05/ChessProgramming-Logo-20151-300x138.pngSteve Maughan2014-03-13 22:39:092015-05-11 23:02:25Automatic Tuning of Evaluation Function
Over the past month Graham Banks has been running the Division 7 competition. I was delighted when Maverick managed to win with a score of 27.5 out of 44 games. After nine round Maverick languished in the bottom half of the table. It managed to fight back and win! During the tournament I logged onto Graham’s site quite a few time and it was nice to chat with Graham and Erik. There were many nail-biting games – not good for the blood pressure!
Graham then ran a gauntlet competition for Maverick to get enough games for a rating. It managed a respectable rating of 2317 ELO on the CCRL scale. You can see the details here:
I do most of my test at fast time controls. Sometimes game in 10 seconds or 5 seconds plus a small increment. This enables me to evaluate and tune changes using oodles of games.
Based on these super-fast test Maverick 0.51 rating seems to be about 2375 ELO on the CCRL scale. For example, I pitted Maverick against TJ-Chess rated 2367 ELO at 10 seconds per game. After 1000 games Maverick wins by 518 wins 347 loses and 1356 draws. This is +60 ELO. Maverick seems to get similar results against other engines close to TJ Chess’ strength e.g. OliThink and Dragon 4.6.
So when Graham Banks tested Maverick in Division 6 I thought it would do quite well. I was wrong! Maverick ended up in 11th place out of twelve participants (TJ Chess came in 4th):
I thought I’d investigate and run a match at slower time controls. I used the same time controls as the Division 6 tournament (40 moves in 25 minutes) on my a 2.8 GHz i7. The results were not what I expected (or hoped for). Maverick lost with 20 wins 40 draws and 40 loses! This results shows TJ Chess is about 100 ELO better at slower time controls. This is a swing of 160 ELO between slow and fast time controls – far more than I thought.
As a result I’ve revised my estimate of Maverick’s strength based on the time controls. At super fast time controls it’s about 2400 ELO while at longer time controls it’s 2250 ELO!
Why the Difference?
I suspected the branching factor in Maverick is quite high. I ran some tests and indeed it seems to be about +4.5. This is high by today’s standard. I think Stockfish is about +2.0. This means every ply takes 4.5 longer to complete than the previous ply. At super-fast time controls Maverick does quite well it’s a relatively fast searcher (4.2 million nps on my i7). As the time controls get longer the branching factor takes its toll and the more selective engines out-search Maverick.
The high branching factor is almost certainly due to lack of selectivity in Maverick’s search. It does use Null Move but it doesn’t use any form of Late-Move-Reduction, which seems to be the cost common, and most effective, form of selectivity. This is by design. I have a hunch that if I can create a reasonably good evaluation function, I’ll be able to add a more effective form of LMR selectivity, guided by the evaluation function. My aim is to take Maverick up to 2500 ELO before I add this selectivity. It looks like I have 200 ELO to go!
Steve Maughanhttp://www.chessprogramming.net/wp-content/uploads/2015/05/ChessProgramming-Logo-20151-300x138.pngSteve Maughan2013-12-30 05:36:562013-12-30 05:36:56Maverick's Rating at Fast & Slow Time Controls...