What are great engines to learn the concepts from?

Discussion of chess software programming and technical issues.

Moderator: Ras

User avatar
hgm
Posts: 28404
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: What are great engines to learn the concepts from?

Post by hgm »

mvanthoor wrote: Fri Feb 05, 2021 8:37 amEven though bitboards are harder to implement (and with regard to magic bitboards, harder to wrap your head around), they really prove their return when you need to check stuff on the board. For example, the square_attacked() function needs to loop over the rays of the rook and the bishop, to find rooks, bishops and the queen, and then has to check against the other king, knights, and pawns. This is a seriously expensive operating. When using bitboards, this function boils down to one (massive) OR-statement.
But that is just a poor mailbox implementation, comparable to a bitboard implementation where you would extract the bits by shifting and testing them one by one, rather than using bit-scan forward. It is always possible to make crappy implementations of any technique. This is why I am of the opposit opinion as Joost. When my mailbox engine Inferno has to do IsSquareAttacked, it just tests whether the entry for that square in the attack map is zero or not. No looping over rays of the board, no massive OR statements. Just a single array access.

Code: Select all

IsSquareAttacked(int sqr, int stm)
{
  return (attacks[stm][sqr] != 0);
}
Dann Corbit
Posts: 12799
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: What are great engines to learn the concepts from?

Post by Dann Corbit »

If you are familiar with bitwise operations like & | ^ >> << etc, then I would recommend Olithink.

Trying to learn to write a chess program from Stockfish is like trying to learn how to build a log cabin from examination of the empire state building.
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.
lojic
Posts: 71
Joined: Thu Jan 28, 2021 9:50 pm
Full name: Brian Adkins

Re: What are great engines to learn the concepts from?

Post by lojic »

Dann Corbit wrote: Fri Feb 05, 2021 8:06 pm If you are familiar with bitwise operations like & | ^ >> << etc, then I would recommend Olithink.

Trying to learn to write a chess program from Stockfish is like trying to learn how to build a log cabin from examination of the empire state building.
Yes, I spent many years with assembler, C & C++ twiddling bits :) I've decided to stick with a mailbox engine for this first version, but that doesn't mean I'm opposed to auxiliary bitboards to speed some things up. My engine just beat a 1,900 human player, but it was with me doing all the time management by adjusting the think time appropriately :) When I just played it myself earlier today, I was able to beat it by concentrating, and I'm only 1,650, so I still have plenty of work to do. I also have an idea of its weaknesses which isn't fair :) Engine was playing black - Stockfish says black move 26 was a blunder:

Code: Select all

1. d4 d5 2. Nf3 Nc6 3. e3 Be6 4. Bd3 Qd7 5. a3 O-O-O 6. Nbd2 Nh6 7. h3 Re8 8. b3 f6 9. Bb2 Rd8 10. Qe2 Qe8 11. O-O-O Bf7 12. g4 e5 13. Bb5 exd4 14. Bxc6 Qxc6 15. Nxd4 Qb6 16. Qb5 Qxb5 17. Nxb5 a6 18. Nd4 Re8 19. Rhe1 Bg6 20. f4 c5 21. N4f3 Be7 22. f5 Bf7 23. c4 dxc4 24. bxc4 Bd6 25. Kc2 Ref8 26. Kc3 Be5+ 27. Nxe5 fxe5 28. Ne4 Rd8 29. Nxc5 Rxd1 30. Rxd1 Re8 31. e4 Re7 32. a4 Rc7 33. Ne6 Bxe6 34. fxe6 b5 35. axb5 axb5 36. c5 Rxc5+ 37. Kb4 Rc7 38. Rd5 Re7 39. Rxe5 Kd8 40. Rd5+ Ke8 41. Rd6 Rc7 42. Kxb5 Ke7 43. Ba3 Ke8 44. Ra6 Rc8 45. Ra7 Rd8 46. Rxg7 Rb8+ 47. Kc6 Rc8+ 48. Kd5 Ra8 49. Bc5 Rd8+ 50. Ke5 Rd3 51. Rxh7 Kd8 52. Rxh6 Kc8 53. Rh7 Rd8 54. g5 Kb8 55. g6 Rg8 56. Kf6 Kc8 57. g7 Kc7 58. Rh8 Rxg7 59. Kxg7 Kc6 60. e7 Kxc5 61. e8=Q Kd4 62. Qc6 Ke3 63. Rf8 Kd3 64. Rf3+ Kd2 65. Qc3+ Ke2 66. Qd3+ Ke1 67. Rf1# 
abulmo2
Posts: 479
Joined: Fri Dec 16, 2016 11:04 am
Location: France
Full name: Richard Delorme

Re: What are great engines to learn the concepts from?

Post by abulmo2 »

xr_a_y wrote: Thu Feb 04, 2021 10:19 am Dumb is very simple and instructive.
Merci pour le compliment.
I just updated a new version of it. Dumb is a minimalist chess program (about 1200 lines of code) but quite strong (last version should reach 2650-2700 Elo on CCRL). I abuse my coding style to make the code more concise, but I hope it is still very readable and to be a very direct translation of the algorithms without too much distracting code.
Richard Delorme