Chess programming C++

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

FainterSquare
Posts: 1
Joined: Mon Jan 28, 2019 4:56 pm
Full name: John Berry

Chess programming C++

Post by FainterSquare »

Hello my name is FainterSquare and I was wondering how to code a chess program in C++. I found it very difficult to find way to code a chess program on my own from the references on the internet so I was wondering if there were any good resources that would allow me to code a chess program on my own from scratch. I have looked at chessprograming wiki and looked over the internet yet no one seems to have made any videos on how to code chess..




-----Sincerely FainterSquare
smatovic
Posts: 2641
Joined: Wed Mar 10, 2010 10:18 pm
Location: Hamburg, Germany
Full name: Srdja Matovic

Re: Chess programming C++

Post by smatovic »

FainterSquare wrote: Tue Jan 29, 2019 7:34 pm Hello my name is FainterSquare and I was wondering how to code a chess program in C++. I found it very difficult to find way to code a chess program on my own from the references on the internet so I was wondering if there were any good resources that would allow me to code a chess program on my own from scratch. I have looked at chessprograming wiki and looked over the internet yet no one seems to have made any videos on how to code chess..

-----Sincerely FainterSquare
I started with C and a MiniMax search for TicTacToe first,
then implemented AlphaBeta,
then started to implement move generation for chess by CPW,
which was a mind wrapping task back then....

--
Srdja
Dann Corbit
Posts: 12538
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Chess programming C++

Post by Dann Corbit »

FainterSquare wrote: Tue Jan 29, 2019 7:34 pm Hello my name is FainterSquare and I was wondering how to code a chess program in C++. I found it very difficult to find way to code a chess program on my own from the references on the internet so I was wondering if there were any good resources that would allow me to code a chess program on my own from scratch. I have looked at chessprograming wiki and looked over the internet yet no one seems to have made any videos on how to code chess..




-----Sincerely FainterSquare
Did you find this place:
https://www.chessprogramming.org/Main_Page
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.
odomobo
Posts: 96
Joined: Fri Jul 06, 2018 1:09 am
Location: Chicago, IL
Full name: Josh Odom

Re: Chess programming C++

Post by odomobo »

Here's a great resource (the vice chess engine), but it uses c instead of c++ https://www.youtube.com/watch?v=bGAfaep ... tZHVbT-2hg

TSCP is the classic "reference" chess engine, in c (not significantly different from vice, in terms of features).

My engine GearHeart https://bitbucket.org/odomobo/gearheart is supposed to be a kind of a reference engine in c++17. However, I suspect it might be too advanced for people new to chess programming, and there's currently not much documentation.
jdart
Posts: 4366
Joined: Fri Mar 10, 2006 5:23 am
Location: http://www.arasanchess.org

Re: Chess programming C++

Post by jdart »

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

Re: Chess programming C++

Post by hgm »

If you don't mind plain C, (which after all is a sub-set of C++) you could also start with micro-Max (far simpler than TSCP, and stronger), or KingSlayer (stronger still, and a bit more conventional). Both sources are elaborately commented.
supriyala
Posts: 1
Joined: Mon Feb 04, 2019 6:04 am
Full name: supriya lade

Re: Chess programming C++

Post by supriyala »

Great information here. Thank you. Excellent share!
tocnaza
Posts: 2
Joined: Sun Mar 03, 2019 7:13 pm
Full name: juanca lina

Re: Chess programming C++

Post by tocnaza »

Nice info! Thanks for sharing us!
jorose
Posts: 358
Joined: Thu Jan 22, 2015 3:21 pm
Location: Zurich, Switzerland
Full name: Jonathan Rosenthal

Re: Chess programming C++

Post by jorose »

Definitely take a look at Andrew Grant's Ethereal. It is written in C, not C++, but the code is fairly straightforward and it is some of the cleanest and most well commented code I am aware of.
Stockfish also has a lot of good comments and is in C++, but I find it a bit more difficult to follow as it is extremely optimized and sometimes a bit over-engineered.
The benefit of these two (and Arasan from further up, but I haven't looked at that code myself) is that you won't really outgrow the codebase and most of the state of the art ideas for classical AB engines are implemented.

A large portion of the other engines I am aware of are small projects by individual (but oftentimes brilliant) programmers and this is unfortunately quite visible in the lack of comments and code cleanliness.
-Jonathan
SlowThought
Posts: 1
Joined: Sat Feb 25, 2017 1:58 am
Location: USA

Re: Chess programming C++

Post by SlowThought »

I used C++ for Zotron (last release in 2004), with extensive use of object orientation to describe the various pieces. It helped me get the program working, but there is a performance price. If I were to do it again, and my goal was a strong engine, I'd stick to C.