Programming chess engine

Code, algorithms, languages, construction...
spacerocket
Posts: 18
Joined: Sat Mar 22, 2014 1:15 pm

Re: Programming chess engine

Post by spacerocket » Thu May 01, 2014 8:53 pm

When I go to Stroustrup`s homepage there is Programming: Principles and Practice using C++ (a programming text book aimed at beginners who wants eventually to become professionals)

http://www.stroustrup.com/programming.html

It is an introduction to programming for people who has never programmed before. It will also be useful for people who have programmed a bit and want to improve their style and technique - or simply learn modern C++


To me it seems suitable to start from C++ because I think Python comes in handy for writing graphical interfaces that open windows. But Chess engines do nothing of the sort. They are simple console programs that communicate by printing text on the terminal they are run in.

hyatt
Posts: 1242
Joined: Thu Jun 10, 2010 2:13 am
Real Name: Bob Hyatt (Robert M. Hyatt)
Location: University of Alabama at Birmingham
Contact:

Re: Programming chess engine

Post by hyatt » Fri May 02, 2014 12:31 am

spacerocket wrote:Hello!

I use opensuse 13.1 and now I`m working with the c-language. What would be the best Linux distro for programming? I want to program own chess engine, I think I need to write a board representation. Is bitboard related to this somehow? I also need GUI I have xboard 4.7.2 but don`t know how to use it with programming. If someone would advise me how to get started but be great, thx.

I am not a Suse fan. WAY too much crapware included, too many things set up to automatically run, etc. I have become a Fedora-hater because they have gone too far into security, SELinux and such, also. I have recently installed Ubuntu and it seems to be OK, but I don't particularly like their apple-wannabe desktop approach (where individual windows don't have a menu bar, they all share the menu bar at the top of the screen for options. )

spacerocket
Posts: 18
Joined: Sat Mar 22, 2014 1:15 pm

Re: Programming chess engine

Post by spacerocket » Fri May 02, 2014 9:19 am

I use Ubuntu

aiavicoli
Posts: 4
Joined: Fri Apr 06, 2012 9:41 am
Real Name: Alessandro Iavicoli

Re: Programming chess engine

Post by aiavicoli » Thu May 08, 2014 2:44 pm

Hi. Let me say some tips to write chess program you could find useful.
1) Understand each of the 3 parts of a chess engine. Board representation, move generator and search function. Leave the position evaluation methods as second task.
2) Once you did it, try to write a simple tic-tac-toe to make practice.
3) Begin with your chess engine. As first try, don't waste time for optimization. Be concentrated for a code that is easy to write and mantain. You will have time to change it in future versions.
4) Choose the programming language you better know. I released a very simple engine written in Ada (very uncommon).
Programming a chess engine is not an easy task, then it's better to not introduce complication while you are still learning basics. That's why I suggest you to give priority for a working engine instead of think about performance.
I found TSCP very useful, an LaMoSca too (italian tutorial).
Last tips: never give up (i failed for almost 4 years before having a "bug-free" version). If things become too much hard then stop it ad start again following another way.
Ask everything you want and community will help. Good luck!

spacerocket
Posts: 18
Joined: Sat Mar 22, 2014 1:15 pm

Re: Programming chess engine

Post by spacerocket » Mon May 12, 2014 2:55 pm

Yep, though I`m more interested in writing in C++ rather than C. Simple C programs can be useful though. What comes to C++, I need to understand the standard libraries besides the language. I did a google search and found first edition: http://www.amazon.com/Programming-Princ ... 0321543726 and second edition: http://www.amazon.com/Programming-Princ ... 0321992784
The books cover the STL Libraries, just thinking should I buy the second edition(newer one) instead of first one.

aiavicoli
Posts: 4
Joined: Fri Apr 06, 2012 9:41 am
Real Name: Alessandro Iavicoli

Re: Programming chess engine

Post by aiavicoli » Wed May 14, 2014 8:41 am

If you prefere C++ over C for a chess engine then I suppose you're going to use classes and other C++ features that C doesn't have.
If you don't need them, C will be a better idea.
But, as others said, you first need to be skilled in C++ if you want to develop a chess engine. Anything has to be done step by step!

vittyvirus
Posts: 9
Joined: Sat Jun 21, 2014 12:52 pm
Real Name: Syed Fahad

Re: Programming chess engine

Post by vittyvirus » Sat Jun 21, 2014 3:31 pm

spacerocket wrote: But how about my original question, which of the books would be better? Allains book is about 10 times shorter than Bjarnes does that affect something?
look, the c++ programming language contains EVERYTHING about c++. it is supposed to be a reference. thqt other book is only an intro. u can read the other book first n thn move to bjarnes one.

User avatar
Jsgroby
Posts: 1
Joined: Sat May 17, 2014 12:59 am
Real Name: Jeffrey S. Groby

Re: Programming chess engine

Post by Jsgroby » Wed Jul 02, 2014 10:37 pm

Check this site out, it is a great reference for c++. http://www.cplusplus.com

microp
Posts: 2
Joined: Sun Jan 22, 2012 9:24 pm
Real Name: Emilio D

Re: Programming chess engine

Post by microp » Tue Aug 19, 2014 12:46 pm

If you find TSCP hard to understand maybe you can try Firstchess:
http://chessprogramming.wikispaces.com/Firstchess

Take into account that Firschess lacks en pasant capture and castle, but you can get a proper idea of how a chess engine works.

If Firstchess is still to difficult for you, then maybe you need to spend some time programming other stuff (IMHO writing a chess engine is not an easy task at all).

spacerocket
Posts: 18
Joined: Sat Mar 22, 2014 1:15 pm

Re: Programming chess engine

Post by spacerocket » Wed Aug 27, 2014 12:33 pm

Ok, the actual source is actually here: http://devwebcl.atarionline.pl/cc65/

I tried to compile the firstchess.c but get this error message:

Code: Select all

 gcc Documents/firstchess.c
Documents/firstchess.c:18:19: fatal error: conio.h: No such file or directory
 #include <conio.h>
Maybe the compiler settings are wrong, anyway I haven`t had much time in writing code lately :( hopefully will have in the future.

Post Reply