Programming chess engine

Discussions about Winboard/Xboard. News about engines or programs to use with these GUIs (e.g. tournament managers or adapters) belong in this sub forum.

Moderator: Andres Valverde

Programming chess engine

Postby matrix101 » 23 Mar 2014, 15:16

Hello!

I have been working on programming own chess engine though the whole project is in prime factors. I have xboard and I think I need xboard protocol to communicate with the engine http://www.gnu.org/software/xboard/engine-intf.html but the problem is that I don`t have any and I don`t know how to start. Do I need to download the protocol from somewhere? Or do I need to build it by coding in text editor/terminal window? I`m not sure but I think I also need C++ compiler though not sure what that does.

Thanks.
matrix101
 
Posts: 53
Joined: 02 Feb 2014, 12:46

Re: Programming chess engine

Postby H.G.Muller » 24 Mar 2014, 09:54

What programming language did you use to program your engine? If you don't have a C++ compiler, how do you compile it now? Is it written in some other language than C/C++?
User avatar
H.G.Muller
 
Posts: 3453
Joined: 16 Nov 2005, 12:02
Location: Diemen, NL

Re: Programming chess engine

Postby matrix101 » 25 Mar 2014, 16:10

Hi!

The problem is that I have not programmed any engine because I don`t know how to write a bug free board representation I only know I need C++ language and xboard protocol. I have xboard 4.7.2 but nothing else. Someone told me "the protocol is just a specification. You need to implement it yourself or start from an existing source, of which there are many." I don`t know any. If I understand you correct I need to program FIRST the engine and after that use C++ compiler downloaded from here: http://gcc.gnu.org/ to compile c++ source (the engine) to binary executable.
matrix101
 
Posts: 53
Joined: 02 Feb 2014, 12:46

Re: Programming chess engine

Postby H.G.Muller » 26 Mar 2014, 07:38

Have you ever programmed anything at all? If so, in what language?

You make it sounds like you whave no programming experience at all. And a Chess engine might not be the best thing to start with. That would be a bit like: "I am going to build a space shuttle, and someone told me this involves glue. Now I have never used glue before, but I know a shop where they sell it."

You are correct about the mechanics of programming: one writes a program in text format ('source code'), and then feeds it to a compiler to turn it into an executable. Do you work on Windows, Linux or Mac?
User avatar
H.G.Muller
 
Posts: 3453
Joined: 16 Nov 2005, 12:02
Location: Diemen, NL

Re: Programming chess engine

Postby matrix101 » 26 Mar 2014, 13:28

I use opensuse 13.1. I have not programmed anything I want to learn C++ language. I want to write a program "Hello world". Before that I think I need stdio.h which does not obviously exist in my programs! Now when I think it I need gcc compiler to be able to install stdio.h with: sudo zypper install libc6-dev

Now I don`t know how to install gcc compiler: http://gcc.gnu.org/ I suppose I need to install GCC 4.8.2 but how
matrix101
 
Posts: 53
Joined: 02 Feb 2014, 12:46

Re: Programming chess engine

Postby H.G.Muller » 26 Mar 2014, 16:14

I don't have Open SUSE, but I suppose you would have to do something like "sudo zypper install gcc" or perhaps "sudo zypper install g++". In Ubuntu, when I type a command that I have not installed, it prints a message like

hgm@hgm-xboard:~$ f77
The program 'f77' is currently not installed. You can install it by typing:
sudo apt-get install fort77

If Open SUSE would have something similar, you could just type gcc or g++, to get the name of the package you have to install. I don't know C++. Perhaps it would be easier to learn plain C first. Many Chess engines are written in C. In any case, "Hello World" would be a more suitable first project than a Chess engine.
User avatar
H.G.Muller
 
Posts: 3453
Joined: 16 Nov 2005, 12:02
Location: Diemen, NL

Re: Programming chess engine

Postby matrix101 » 08 Apr 2014, 17:56

Hello!

Now I use ubuntu and I build xboard 4.7.3 from source. http://www.physics.drexel.edu/courses/Comp_Phys/General/C_basics/c_tutorial.html

Someone told me that this tutorial contains errors and it`s not wise to rely solely on online tutorials. Is this correct?

Maybe I should learn C by buying a book? Can you recommend one or how did you learn C
Last edited by matrix101 on 11 Apr 2014, 14:21, edited 2 times in total.
matrix101
 
Posts: 53
Joined: 02 Feb 2014, 12:46

Re: Programming chess engine

Postby matrix101 » 08 Apr 2014, 19:12

Yet there is another problem. I haven`t finished installing xboard 4.7.3 from source:

xdg-mime: file 'xboard.xml' does not exist
xdg-desktop-menu: file 'xboard-pgn-viewer.desktop' does not exist
xdg-desktop-menu: file 'xboard-fen-viewer.desktop' does not exist
xdg-desktop-menu: file 'xboard-tourney.desktop' does not exist
xdg-desktop-menu: file 'xboard-config.desktop' does not exist
xdg-icon-resource: file 'pixmaps/board32.xpm' does not exist
xdg-icon-resource: file 'pixmaps/cross32.xpm' does not exist
xdg-icon-resource: file 'pixmaps/ini32.xpm' does not exist
xdg-icon-resource: file 'pixmaps/board48.xpm' does not exist
xdg-icon-resource: file 'pixmaps/cross48.xpm' does not exist
xdg-icon-resource: file 'pixmaps/ini48.xpm' does not exist
make[3]: [install-mime-database] Error 2 (ignored)

The xml file is missing... what should I do

This is the actual file that I am looking for: https://github.com/shauncassingham/xboard/blob/master/xboard.xml

but how I make use of it is the question - it needs saving and putting in the right place
matrix101
 
Posts: 53
Joined: 02 Feb 2014, 12:46

Re: Programming chess engine

Postby H.G.Muller » 13 Apr 2014, 20:43

Did you do "sudo make install" to get all the files into place?

All the files you mention should be part of the XBoard source package (in its root directory). Were you in that directory when doing the make-install? What does it say when you do "ls -l" there?
User avatar
H.G.Muller
 
Posts: 3453
Joined: 16 Nov 2005, 12:02
Location: Diemen, NL

Re: Programming chess engine

Postby matrix101 » 14 Apr 2014, 12:44

Yep I did sudo make install. I noted it says after ./configure: infodir: ${datarootdir}/info (info files will go here) ... xml belongs here?


ls -l
total 2340
-rw-r--r-- 1 user user 692568 huhti 8 18:06 backend.o
-rw-r--r-- 1 user user 35040 huhti 8 18:06 board.o
-rw-r--r-- 1 user user 36392 huhti 8 18:06 book.o
-rw-r--r-- 1 user user 1520 huhti 8 18:06 childio.o
-rwxr-xr-x 1 user user 66464 huhti 14 14:33 cmail
-rw-r--r-- 1 user user 5729 huhti 8 18:06 config.h
-rw-r--r-- 1 user user 38003 huhti 14 14:33 config.log
-rwxr-xr-x 1 user user 41573 huhti 14 14:33 config.status
drwxr-xr-x 2 user user 4096 huhti 6 21:32 Desktop
-rw-r--r-- 1 user user 166112 huhti 8 18:06 dialogs.o
drwxr-xr-x 2 user user 4096 huhti 14 12:48 Documents
drwxr-xr-x 6 user user 4096 huhti 14 13:37 Downloads
-rw-r--r-- 1 user user 36872 huhti 8 18:06 draw.o
-rw-r--r-- 1 user user 17296 huhti 8 18:06 engineoutput.o
-rw-r--r-- 1 user user 9472 huhti 8 18:06 evalgraph.o
-rw-r--r-- 1 user user 8980 huhti 6 20:52 examples.desktop
-rw-r--r-- 1 user user 20696 huhti 8 18:06 gamelist.o
drwxr-xr-x 3 user user 4096 huhti 8 18:06 gtk
-rwxr-xr-x 1 user user 8614 huhti 10 17:44 hello
-rw-r--r-- 1 user user 7400 huhti 8 18:06 history.o
-rw-r--r-- 1 user user 2696 huhti 8 18:06 lists.o
-rw-r--r-- 1 user user 69566 huhti 14 14:33 Makefile
-rw-r--r-- 1 user user 54088 huhti 8 18:06 menus.o
-rw-r--r-- 1 user user 63680 huhti 8 18:06 moves.o
drwxr-xr-x 2 user user 4096 huhti 6 21:32 Music
-rw-r--r-- 1 user user 7624 huhti 8 18:06 nengineoutput.o
-rw-r--r-- 1 user user 5800 huhti 8 18:06 nevalgraph.o
-rw-r--r-- 1 user user 14864 huhti 8 18:06 ngamelist.o
-rw-r--r-- 1 user user 4568 huhti 8 18:06 nhistory.o
-rw-r--r-- 1 user user 27472 huhti 8 18:06 parser.o
-rw-r--r-- 1 user user 9552 huhti 8 18:06 pgntags.o
drwxr-xr-x 2 user user 4096 huhti 10 15:25 Pictures
drwxr-xr-x 2 user user 4096 huhti 14 14:33 po
drwxr-xr-x 2 user user 4096 huhti 6 21:32 Public
-rw-r--r-- 1 user user 30 huhti 14 14:33 stamp-h
-rw-r--r-- 1 user user 23 huhti 14 14:33 stamp-h1
drwxr-xr-x 2 user user 4096 huhti 6 21:32 Templates
-rw-r--r-- 1 user user 3192 huhti 8 18:06 uci.o
-rw-r--r-- 1 user user 4600 huhti 8 18:06 usounds.o
-rw-r--r-- 1 user user 19840 huhti 8 18:06 usystem.o
-rwxr-xr-x 1 user user 8961 huhti 11 20:57 var
drwxr-xr-x 2 user user 4096 huhti 6 21:32 Videos
drwxr-xr-x 3 user user 4096 huhti 8 18:06 xaw
-rwxr-xr-x 1 user user 775080 huhti 8 20:24 xboard
-rw-r--r-- 1 user user 3263 huhti 14 14:34 xboard.conf
matrix101
 
Posts: 53
Joined: 02 Feb 2014, 12:46

Re: Programming chess engine

Postby H.G.Muller » 14 Apr 2014, 13:06

This is very strange:

None of the XBoard source files show up in that listing. Not only the xboard.xml and the *.desktop files are missing, but also all the C sources (*.c and *.h files, like backend.c and common.h). Yet you do seem to be in the base directory of the XBoard source tree, as all the sub-directories are there (xaw, gtk, ...). But there are also sub-directories that are not from the XBoard source tree (such as Videos, Documents and Music). And all the object files (*.o) made by the C compiler are also there. But the files they were made from are not!?!
User avatar
H.G.Muller
 
Posts: 3453
Joined: 16 Nov 2005, 12:02
Location: Diemen, NL

Re: Programming chess engine

Postby matrix101 » 14 Apr 2014, 15:04

Would you recommend to uninstall whole xboard and re-install the whole xboard system?

I installed earlier xboard from the repo`s so maybe the system has mixed up something.

All the C sources (*.c and *.h files, like backend.c and common.h) are missing from the base directory.

ls -l shows some other sub-directories that are not from the XBoard source tree.
matrix101
 
Posts: 53
Joined: 02 Feb 2014, 12:46

Re: Programming chess engine

Postby H.G.Muller » 14 Apr 2014, 18:49

Well, I don't know what you did to get in this state, and if there is any uninstall that could undo it. It looks like you unpacked the XBoard sources in your home directory, did ./configure and make, and then somehow deleted all the source files again (but not the sub-directories).

Proper procedure would be to create a new directory (e.g. 'xboard' in your home directory), and unpack the source files there. And then change to it (with 'cd xboard'), and do ./configure, make, and sudo make install there.
User avatar
H.G.Muller
 
Posts: 3453
Joined: 16 Nov 2005, 12:02
Location: Diemen, NL

Re: Programming chess engine

Postby matrix101 » 14 Apr 2014, 19:43

Hello!

If I understand you right I should create a new xboard directory inside my home directory and do ./configure, make and make install inside that xboard directory after creating path for xboard-4.7.2 to that directory.

In summary, should be something like this:

Code: Select all
mkdir Home/xboard


Would it be possible to uninstall xboard-4.7.3 and all the components that came with it to mitigate this fuss?

Besides In my Home directory there are all kind of stuff that I don`t like Makefile, book.o,hello I don`t understand how they got there. Maybe just delete them all. And every time I open new file it automatically goes to -> Recent. Strange.
matrix101
 
Posts: 53
Joined: 02 Feb 2014, 12:46

Re: Programming chess engine

Postby H.G.Muller » 14 Apr 2014, 20:52

The *.o files are intermediate products of the compilation process, created by gcc from the corresponding *.c files. They are later forged into a binary (xboard, in this case).

I don't think install/uninstall works for source packages. You just have to delete them. This is why it is best to unpack them in a directory where there is nothing else, so that if you want to get rid of them, you just delete that entire directory. Once things get mixed, you would have to sort out by hand what you want to keep and what to delete.

'hello' is not part of the XBoard package. Perhaps it is a 'hello World' program you wrote as exercise?

When you are in your home directory after login, it should be enough to do

mkdir xboard
cd xboard

and then unpack the source package in that xboard directory. First delete the file called 'xboard', though, or you cannot make a directory of that name. (Or use another name.)
User avatar
H.G.Muller
 
Posts: 3453
Joined: 16 Nov 2005, 12:02
Location: Diemen, NL

Re: Programming chess engine

Postby matrix101 » 15 Apr 2014, 11:11

Ok

Now I downloaded the xboard-4.7.2 source code and extracted into xboard-4.7.2 filefolder. Then I moved it to the folder "xboard" existing in my Home directory.

Then I did xboard/xboard-4.7.2/./configure this seemed to go well.

Then:

user@user-MS-7817:~$ make
make all-recursive
make[1]: Entering directory `/home/user'
Making all in po
make[2]: Entering directory `/user/user/po'
make[2]: Leaving directory `/user/user/po'
make[2]: Entering directory `/home/user'
make[2]: *** No rule to make target `Downloads/xboard-4.7.3/./backend.c', needed by `backend.o'. Stop.
make[2]: Leaving directory `/user/user'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/user/user'
make: *** [all] Error 2

I think my mistake was that I didn` move xboard-4.7.2.tar.gz directly to the folder "xboard" and extracted there. Instead I extracted the xboard-4.7.2.tar.gz package in Downloads and then moved to "xboard". . I have had

Ubuntu just a while. Xboard-4.7.3 still remais as an application even though I deleted all files related to that. I can even open it.

Ok now I did move xboard-4.7.2.tar.gz directly to the folder "xboard" and extracted there. I also deleted the old xboard-4.7.2 files and created new xboard folder before extracting into it(deleted also the old one). Now I`m having the same error message.
matrix101
 
Posts: 53
Joined: 02 Feb 2014, 12:46

Re: Programming chess engine

Postby H.G.Muller » 15 Apr 2014, 13:06

matrix101 wrote:Then I did xboard/xboard-4.7.2/./configure this seemed to go well.


I think this is what is wrong. You try to execute the build commands from your home directory, in stead of moving there first through

cd xboard/xboard-4.7.2
./configure

I am already surprised that this seems to work for ./configure, but it would not work for 'make install', which looks for the files relative to the current directory. You really have to cd first.

If XBoard 4.7.3 still works, you must have overlooked it when deleting. Normally it would be in /usr/games.
User avatar
H.G.Muller
 
Posts: 3453
Joined: 16 Nov 2005, 12:02
Location: Diemen, NL

Re: Programming chess engine

Postby matrix101 » 15 Apr 2014, 15:41

I need to look at that too. Now my Ubuntu froze however and the volume "Filesystem root" has only 524.5MB disk space remaining (66GB/69,6GB) used So I`m unable to use Ubuntu at least for now.
matrix101
 
Posts: 53
Joined: 02 Feb 2014, 12:46

Re: Programming chess engine

Postby H.G.Muller » 15 Apr 2014, 20:22

That is pretty amazing. I run Ubuntu 10.04 from a virtual machine with only 8GB (virtual) disk space, and 3.8GB of it is still empty.
User avatar
H.G.Muller
 
Posts: 3453
Joined: 16 Nov 2005, 12:02
Location: Diemen, NL

Re: Programming chess engine

Postby matrix101 » 15 Apr 2014, 21:08

Yep that`s strange.

user@user-MS-7817:~$ cd xboard/xboard-4.7.2
user@user-MS-7817:~/xboard/xboard-4.7.2$ ./configure

......................

configure: creating ./config.status
config.status: creating Makefile
config.status: creating cmail
mawk: write failure (No space left on device)
mawk: close failed on file /dev/stdout (No space left on device
)


That`s paranormal! When I go to Disk usage Analyzer I can see /(root) 65,9GB and home usage 93,4%?? and size 61,2GB?? . Home contents 2514 items. Maybe it would be wise to delete whole home directory.

Content of Home:

/home/user/Desktop Contents: nothing Location: /home/user Free space: 1,2 MB
/home/userDocuments Contents: 7 items totalling 58.8 kB Location: /home/user Free space: 1,2 MB
/home/user/Downloads Contents: 224 items totalling 16,1MB Location: /home/user Free space: 1,2 MB
/home/user/gtk Contents: nothing Location: /home/user Free space: 1,2 MB
/home/user/Music Contents: 1 item with size 0 bytes Location: /home/user Free space: 1,2 MB
/home/user/Pictures Contents: 1 item, with size 369,5 kB Location: /home/user Free space: 1,2 MB
/home/user/po Contents: 3 items, totalling 38,7 kB Location: /home/user Free space 1,2 MB
/home/user/Public Contents: nothing Location: /home/user Free space: 1,2 MB
/home/user/Templates Contents: nothing Location: /home/user Free space: 1,2 MB
/home/user/Videos Contents: nothing Location: /home/user Free space: 1,2 MB
/home/user/xaw Contents: nothing Location: /home/user Free space: 1,2 MB
/home/user/xboard Contents: 1 144 items, totalling 14,4 MB Location: /home/user Free space: 1,2 MB
/home/user/examples.desktop Contents: 3 items, totalling 5,2 MB Location: /home/user Free space: 1,2 MB
/home/user/hello Contents: 8,6 kB (8 614 bytes) Location: /home/user Free space:
/home/user/ttt Contents: 14,0 kB (14 006 bytes) Location: /home/user Free space:
Last edited by matrix101 on 15 Apr 2014, 21:33, edited 2 times in total.
matrix101
 
Posts: 53
Joined: 02 Feb 2014, 12:46

Next

Return to Winboard and related Topics

Who is online

Users browsing this forum: No registered users and 34 guests