Improving speed

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

Ras
Posts: 2487
Joined: Tue Aug 30, 2016 8:19 pm
Full name: Rasmus Althoff

Re: Improving speed

Post by Ras »

Henk wrote:That means I at least have to improve speed by a factor 4 instead of 2 because of the expensive evaluation stuff.
I wouldn't focus on speed that much. The goal is getting good moves, not NPS. If you cut down speed in half, you'll lose about 50 Elo. However, if you do useful stuff with the additional calculations, that should easily buy much more than 50 Elo.

Develop the pieces, go for castling, avoid bad pawn structure and put the rooks on useful files. This is the next useful step for Skipper, IMHO.

Could you post a game between the CT800 (Winboard version) and Skipper? The CT800 is heavily focused on massive static eval instead of NPS.
Henk
Posts: 7216
Joined: Mon May 27, 2013 10:31 am

Re: Improving speed

Post by Henk »

About the same NPS. During opening CT800 is faster than Skipper. 39 .. Ke8?? but game already totally lost.

[pgn]
[Event "Computer Chess Game"]
[Site "HP"]
[Date "2017.06.22"]
[Round "-"]
[White "CT800 V1.11 64 bit"]
[Black "SkipperWinb"]
[Result "1-0"]
[TimeControl "180"]
[Annotator "2. +0.09 1... +0.06"]

1. c4 Nc6 {+0.06/150 3} 2. d4 {+0.09/10 1.9} Na5 {-0.09/110 3} 3. e4
{+0.58/9 1.6} e6 {-0.14/130 2.9} 4. Bd3 {+0.63/9 1.8} a6 {-0.26/110 2.9} 5.
Nf3 {+1.23/9 2.7} Bb4+ {-0.37/120 2.8} 6. Bd2 {+1.21/9 2.7} Bxd2+
{-0.85/130 2.8} 7. Qxd2 {+0.86/10 2.5} Nc6 {-1.25/120 2.8} 8. d5
{+1.26/9 2.1} Nce7 {-0.89/130 2.7} 9. Qg5 {+1.02/8 2.7} Ng6 {-1.30/130 2.7}
10. Qxd8+ {+0.91/10 1.7} Kxd8 {-0.79/140 2.6} 11. dxe6 {+0.92/10 2.7} fxe6
{-0.60/140 2.6} 12. Nc3 {+0.99/9 2.7} Nf4 {-0.22/140 2.5} 13. O-O-O
{+1.08/9 2.7} Nf6 {-0.22/130 2.5} 14. Bc2 {+1.10/9 1.6} b6 {-0.14/110 2.4}
15. e5 {+1.53/9 1.9} Ng4 {-0.51/120 2.4} 16. Ng5 {+1.46/9 2.7} Ke7
{-1.35/110 2.4} 17. Rd4 {+2.20/10 1.6} Rf8 {-1.59/130 2.3} 18. Nxh7
{+2.08/10 2.3} Rf7 {-1.64/130 2.3} 19. Ng5 {+2.21/9 2.7} Rf8
{-1.58/130 2.3} 20. Nh3 {+2.08/9 2.7} g5 {-1.06/130 2.2} 21. Nxg5
{+2.06/10 2.4} Nxf2 {-1.06/120 2.2} 22. Rg1 {+2.31/10 2.6} Nh5
{-1.42/110 2.2} 23. Rh4 {+3.10/9 1.6} Nf4 {-2.24/130 2.1} 24. Kd2
{+3.39/10 2.7} Bb7 {-2.17/130 2.1} 25. g3 {+3.60/10 2.7} Ng2
{-2.35/120 2.0} 26. Rh7+ {+4.26/10 1.6} Kd8 {-3.50/130 2.0} 27. Nce4
{+4.52/9 2.7} Ng4 {-2.59/120 2.0} 28. Rxg2 {+4.55/9 2.7} Nxe5
{-2.68/110 2.0} 29. Kc3 {+4.67/10 2.1} Rf1 {-2.68/100 1.9} 30. Re2
{+5.68/9 2.7} Bxe4 {-5.33/110 1.9} 31. Rxe4 {+6.02/10 2.7} Ng6
{-4.28/120 1.9} 32. Nxe6+ {+6.18/10 2.3} dxe6 {-5.28/140 1.8} 33. Rd4+
{+7.00/12 2.2} Kc8 {-6.29/130 1.8} 34. Bxg6 {+7.14/11 2.1} Rf3+
{-6.21/130 1.8} 35. Rd3 {+7.38/11 2.7} Rxd3+ {-6.42/130 1.8} 36. Bxd3
{+7.60/9 2.7} Ra7 {-5.99/160 1.8} 37. Be4 {+7.97/8 2.7} Kd8 {-7.89/130 1.7}
38. Bc6 {+11.76/8 1.6} b5 {-12.71/120 1.7} 39. Rd7+ {+12.90/8 2.7} Ke8
{-13.42/140 1.6} 40. Rxc7+ {+13.24/9 2.2} Kf8 {-12.87/130 1.6} 41. Rxa7
{+15.22/10 2.5} bxc4 {-13.71/120 1.6} 42. Kxc4 a5 {-14.07/110 1.5} 43. Kd4
{+15.58/8 2.7} a4 {-14.35/110 1.5} 44. Ke5 a3 {-2621.36/120 1.5} 45. Kf6
Kg8 {-2621.38/130 1.5} 46. Be4 axb2 {-2621.40/150 1.5} 47. Ra8#
{Xboard adjudication: Checkmate} 1-0
[/pgn]
zenpawn
Posts: 349
Joined: Sat Aug 06, 2016 8:31 pm
Location: United States

Re: Improving speed

Post by zenpawn »

Henk wrote:About the same NPS. During opening CT800 is faster than Skipper. 39 .. Ke8?? but game already totally lost.
39...Ke8 because 39...Kc8 loses to 40.Re7! and mate cannot be avoided.
Henk
Posts: 7216
Joined: Mon May 27, 2013 10:31 am

Re: Improving speed

Post by Henk »

Ok. I was still sleeping (and maybe not a good chess player as well)
Henk
Posts: 7216
Joined: Mon May 27, 2013 10:31 am

Re: Improving speed

Post by Henk »

If you put on your website that CT800 is even playing much better than Skipper it will be a million seller.
mar
Posts: 2554
Joined: Fri Nov 26, 2010 2:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: Improving speed

Post by mar »

What's the difference between CT800 and NG-play?
Dann Corbit
Posts: 12538
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Improving speed

Post by Dann Corbit »

Henk wrote:
Dann Corbit wrote:Houdini and Goliath are both stupendously fast.
But beside that, they are relatively correct.

If you hit your head with a hammer 1 million times in a second, it's not a benefit.
Whatever I do there are always people doing at least thousand times better.
Sure. There is only one greatest of all time at any task. So there are other people who are better than we are.

So our goal should be to do our best, not someone else's best.

IMO-YMMV
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
Ras
Posts: 2487
Joined: Tue Aug 30, 2016 8:19 pm
Full name: Rasmus Althoff

Re: Improving speed

Post by Ras »

If you just look at the position after the 13th move by Black, then it becomes clear what the issue is:

- White has developed all pieces, castled, the rooks are connected, and a rook is on a semi-open file.
- Black has developed two pieces, but the bishop is stuck, and it will take another pawn move to get it going. The rooks are not connected and sit in the corners, and castling is not possible.

I've seen the same issue when Skipper plays against Fairymax. Twice as much NPS are useless if the position doesn't hold anything. Superior tactics always come from a superior position, as Steinitz noticed (blunders aside).

If you focus first on development, then Skipper has something to fight with.
Henk
Posts: 7216
Joined: Mon May 27, 2013 10:31 am

Re: Improving speed

Post by Henk »

Ras wrote:If you just look at the position after the 13th move by Black, then it becomes clear what the issue is:

- White has developed all pieces, castled, the rooks are connected, and a rook is on a semi-open file.
- Black has developed two pieces, but the bishop is stuck, and it will take another pawn move to get it going. The rooks are not connected and sit in the corners, and castling is not possible.

I've seen the same issue when Skipper plays against Fairymax. Twice as much NPS are useless if the position doesn't hold anything. Superior tactics always come from a superior position, as Steinitz noticed (blunders aside).

If you focus first on development, then Skipper has something to fight with.
No Skipper has not the right data structures. So that should be first priority. Actually it is already too late for it is almost too much work to rewrite it. But step by step.
Ras
Posts: 2487
Joined: Tue Aug 30, 2016 8:19 pm
Full name: Rasmus Althoff

Re: Improving speed

Post by Ras »

The main differences are:

Book:
- the CT800 has an embedded opening book of 21,000 unique moves in 11,000 positions (NG-Play: about a 1,000 moves). The opening book is hand-crafted.
- the book is position-based using a combined CRC-40 and recognises transpositions. Actually, the raw book is still line-based, but I've written an opening book compiler.
- if White plays a mirrored opening with an intentional tempo loss to throw the computer out of the book (e.g. 1. e2-e3 e7-e5 2. e3-e4), that is also recognised, and the opening book still works.

Game:
- there is a trade logic: trade pieces if you're up, trade pawns if you're down, and don't trade when equal unless it's useful or avoids harm, i.e. keep the board full.
- the rook eval is tied to the pawn eval: open files are preferred, but also backward enemy pawns on semi-open files are marked as rook targets.
- positions with blocked centre are evaluated asymetrically as bad for the computer because it knows that humans try this anti-computer strategy. The opening book avoids these positions from the beginning.
- the pawn hash table stores whether an evaluation is middlegame or endgame related.
- there is an embedded endgame table for KP:K.
- below move 30, the CT800 avoids draw by repetition if it is not worse than -0.4 pawns.

Handling:
- the time management is new, though the PC version doesn't have all of it, except some points.
- when there is less than 100ms move time, NG-Play just resigns. Fixed in my bugfix versions. The CT800 takes the best move from the shallow pre-sorting in this case.
- quick replies are implemented for easy moves, which are mostly recaptures. Not only this saves time, it also robs pondering opponents from a sure ponder hit.
- when a depth iteration finishes and more than 55% of the allocated move time are already over, the next iteration isn't started because it would not finish anyway.
- together with the opening book, this allows 25% more allocated move time at the same time controls.

Codebase:
- I have refactored the code since it was all in a single C file.

For the target system:
- reducing the RAM footprint to 192 kB, not counting code and constant data since these go to the flash ROM.
- the hardware driver layer as the system doesn't have an operating system; coded as per the controller reference manual.
- the menu system, the embedded position editor and the HMI with dialogue boxes.
- the analysis and mate search modes, the latter with the possibility to check a mating puzzle for double solution moves.
- more complete time management, including undo/redo which book the time back and forth, including possible Fischer delay.
- configurable eval blurring.