Chess programming C++

Discussion of chess software programming and technical issues.

Moderators: hgm, Harvey Williamson, bob

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
FainterSquare
Posts: 1
Joined: Mon Jan 28, 2019 3:56 pm
Full name: John Berry

Chess programming C++

Post by FainterSquare » Tue Jan 29, 2019 6: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

smatovic
Posts: 604
Joined: Wed Mar 10, 2010 9:18 pm
Location: Hamburg, Germany
Full name: Srdja Matovic
Contact:

Re: Chess programming C++

Post by smatovic » Tue Jan 29, 2019 6:59 pm

FainterSquare wrote:
Tue Jan 29, 2019 6: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: 9414
Joined: Wed Mar 08, 2006 7:57 pm
Location: Redmond, WA USA
Contact:

Re: Chess programming C++

Post by Dann Corbit » Tue Jan 29, 2019 7:24 pm

FainterSquare wrote:
Tue Jan 29, 2019 6: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: 50
Joined: Thu Jul 05, 2018 11:09 pm
Location: Chicago, IL
Full name: Josh Odom

Re: Chess programming C++

Post by odomobo » Tue Jan 29, 2019 8:42 pm

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: 3701
Joined: Fri Mar 10, 2006 4:23 am
Location: http://www.arasanchess.org

Re: Chess programming C++

Post by jdart » Wed Jan 30, 2019 3:00 am


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

Re: Chess programming C++

Post by hgm » Wed Jan 30, 2019 10:32 pm

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 5:04 am
Full name: supriya lade

Re: Chess programming C++

Post by supriyala » Tue Feb 05, 2019 4:05 am

Great information here. Thank you. Excellent share!

tocnaza
Posts: 2
Joined: Sun Mar 03, 2019 6:13 pm
Full name: juanca lina

Re: Chess programming C++

Post by tocnaza » Mon Mar 04, 2019 7:56 am

Nice info! Thanks for sharing us!

jorose
Posts: 203
Joined: Thu Jan 22, 2015 2:21 pm
Location: Zurich, Switzerland
Full name: Jonathan Rosenthal

Re: Chess programming C++

Post by jorose » Mon Mar 04, 2019 3:41 pm

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 12:58 am
Location: USA

Re: Chess programming C++

Post by SlowThought » Wed Mar 06, 2019 10:00 pm

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.

Post Reply