A very simple engine in C/C++ using bitboards?

Discussion of anything and everything relating to chess playing software and machines.

Moderators: bob, hgm, Harvey Williamson

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
User avatar
pocopito
Posts: 236
Joined: Tue Jul 12, 2011 11:31 am
Contact:

A very simple engine in C/C++ using bitboards?

Post by pocopito » Mon Oct 01, 2018 1:35 pm

Hi all

Maybe someone here remembers Firstchess "FirstChess, a very simple open source chess program with a command line interface written by Nguyen Hong Pham (surname) in C for didactic purpose, introduced in 2002"

https://github.com/nguyenpham/FirstChess

I'm wondering whether something similar, written in C/C++ but with bitboards exists.

Thanks in advance

Emilio
Two first meanings of the dutch word "leren":
1. leren [vc] (learn, larn, acquire) acquire or gain knowledge or skills.
2. leren [v] (teach, learn, instruct) impart skills or knowledge to.

User avatar
Guenther
Posts: 3045
Joined: Wed Oct 01, 2008 4:33 am
Location: Regensburg, Germany
Full name: Guenther Simon
Contact:

Re: A very simple engine in C/C++ using bitboards?

Post by Guenther » Mon Oct 01, 2018 2:50 pm

pocopito wrote:
Mon Oct 01, 2018 1:35 pm
Hi all

Maybe someone here remembers Firstchess "FirstChess, a very simple open source chess program with a command line interface written by Nguyen Hong Pham (surname) in C for didactic purpose, introduced in 2002"

https://github.com/nguyenpham/FirstChess

I'm wondering whether something similar, written in C/C++ but with bitboards exists.

Thanks in advance

Emilio
e.g. Winglet (original site does not exist anymore - thus the wayback link)
http://web.archive.org/web/201206211002 ... m/winglet/
Current foe list count : [97]
http://rwbc-chess.de/chronology.htm

Edsel Apostol
Posts: 762
Joined: Mon Jul 17, 2006 3:53 am
Full name: Edsel Apostol
Contact:

Re: A very simple engine in C/C++ using bitboards?

Post by Edsel Apostol » Mon Oct 01, 2018 5:33 pm

pocopito wrote:
Mon Oct 01, 2018 1:35 pm
Hi all

Maybe someone here remembers Firstchess "FirstChess, a very simple open source chess program with a command line interface written by Nguyen Hong Pham (surname) in C for didactic purpose, introduced in 2002"

https://github.com/nguyenpham/FirstChess

I'm wondering whether something similar, written in C/C++ but with bitboards exists.

Thanks in advance

Emilio
You can try this one. This is when I'm just starting to learn programming in College.

https://github.com/ed-apostol/TwistedLo ... /Logic18.c

Dann Corbit
Posts: 10110
Joined: Wed Mar 08, 2006 7:57 pm
Location: Redmond, WA USA
Contact:

Re: A very simple engine in C/C++ using bitboards?

Post by Dann Corbit » Mon Oct 01, 2018 7:36 pm

pocopito wrote:
Mon Oct 01, 2018 1:35 pm
Hi all

Maybe someone here remembers Firstchess "FirstChess, a very simple open source chess program with a command line interface written by Nguyen Hong Pham (surname) in C for didactic purpose, introduced in 2002"

https://github.com/nguyenpham/FirstChess

I'm wondering whether something similar, written in C/C++ but with bitboards exists.

Thanks in advance

Emilio
Olithink.
From here:
http://brausch.org/home/chess/index.html
This link:
http://brausch.org/home/chess/OliThink533.src.zip
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.

mkchan
Posts: 83
Joined: Thu Oct 06, 2016 7:17 pm
Location: India
Contact:

Re: A very simple engine in C/C++ using bitboards?

Post by mkchan » Tue Oct 02, 2018 4:54 am

Check out Teki:

https://github.com/Mk-Chan/Teki

It uses the classical bitboard approach (non-magic/rotated).

Uri Blass
Posts: 8586
Joined: Wed Mar 08, 2006 11:37 pm
Location: Tel-Aviv Israel

Re: A very simple engine in C/C++ using bitboards?

Post by Uri Blass » Tue Oct 02, 2018 10:19 pm

Guenther wrote:
Mon Oct 01, 2018 2:50 pm
pocopito wrote:
Mon Oct 01, 2018 1:35 pm
Hi all

Maybe someone here remembers Firstchess "FirstChess, a very simple open source chess program with a command line interface written by Nguyen Hong Pham (surname) in C for didactic purpose, introduced in 2002"

https://github.com/nguyenpham/FirstChess

I'm wondering whether something similar, written in C/C++ but with bitboards exists.

Thanks in advance

Emilio
e.g. Winglet (original site does not exist anymore - thus the wayback link)
http://web.archive.org/web/201206211002 ... m/winglet/
Thanks for this link
I started to try to follow the steps

I have some problem in step 5.

int _tmain(int argc, _TCHAR* argv[])
{
printf("hello, I am your new friend!\n");
return 0;
}

This code produce errors when I compile it.

Severity Code Description Project File Line Suppression State
Error (active) E0020 identifier "_TCHAR" is undefined chess_project C:\Users\UriBlass\source\repos\chess_project\chess_project\main.cpp 2
Severity Code Description Project File Line Suppression State
Error (active) E0020 identifier "printf" is undefined chess_project C:\Users\UriBlass\source\repos\chess_project\chess_project\main.cpp 5

Note that
I have no errors with the following code that does what it is supposed to do and maybe the code that they suggest is only relevant for visual C++2010 and not for visual C++2017.

#include <iostream>
int main()
{
printf("hello, I am your new friend!\n");
return 0;
}

Edit:
I guess that the following comment in step 5 is also not relevant for people who use Visual C++ 2017

"Visual Studio C++ Express does not come with 64-bit compilers.
If you want to build your executable for a 64-bit platform, then I suggest searching the internet for "how to configure Visual C++ Projects to Target 64-Bit Platforms". This will lead you to Microsoft's site with more information. "

Am I right?

tttony
Posts: 259
Joined: Sat Apr 23, 2011 10:33 pm
Contact:

Re: A very simple engine in C/C++ using bitboards?

Post by tttony » Wed Oct 03, 2018 1:56 am

Uri Blass wrote:
Tue Oct 02, 2018 10:19 pm
Guenther wrote:
Mon Oct 01, 2018 2:50 pm
pocopito wrote:
Mon Oct 01, 2018 1:35 pm
Hi all

Maybe someone here remembers Firstchess "FirstChess, a very simple open source chess program with a command line interface written by Nguyen Hong Pham (surname) in C for didactic purpose, introduced in 2002"

https://github.com/nguyenpham/FirstChess

I'm wondering whether something similar, written in C/C++ but with bitboards exists.

Thanks in advance

Emilio
e.g. Winglet (original site does not exist anymore - thus the wayback link)
http://web.archive.org/web/201206211002 ... m/winglet/
Thanks for this link
I started to try to follow the steps

I have some problem in step 5.

int _tmain(int argc, _TCHAR* argv[])
{
printf("hello, I am your new friend!\n");
return 0;
}

This code produce errors when I compile it.

Severity Code Description Project File Line Suppression State
Error (active) E0020 identifier "_TCHAR" is undefined chess_project C:\Users\UriBlass\source\repos\chess_project\chess_project\main.cpp 2
Severity Code Description Project File Line Suppression State
Error (active) E0020 identifier "printf" is undefined chess_project C:\Users\UriBlass\source\repos\chess_project\chess_project\main.cpp 5

Note that
I have no errors with the following code that does what it is supposed to do and maybe the code that they suggest is only relevant for visual C++2010 and not for visual C++2017.

#include <iostream>
int main()
{
printf("hello, I am your new friend!\n");
return 0;
}

Edit:
I guess that the following comment in step 5 is also not relevant for people who use Visual C++ 2017

"Visual Studio C++ Express does not come with 64-bit compilers.
If you want to build your executable for a 64-bit platform, then I suggest searching the internet for "how to configure Visual C++ Projects to Target 64-Bit Platforms". This will lead you to Microsoft's site with more information. "

Am I right?
I personally don't recommend that tutorial because it's focused on programming in Windows, also it's outdated, the code it's too repetitive and mix c with c++

I learned chess programming and C programming watching the VICE series (the source code it's a bit a mess but at the end you will learn), it's developed in C99, you can develop C99 in Visual Studio with just changing the source files to .c VS will compile as C code (since VS 2013 support C99) VS 2017 seems to still support C99, just using a few macros you can get a fully functional chess program in Windows, Linux and macOS

Edsel Apostol
Posts: 762
Joined: Mon Jul 17, 2006 3:53 am
Full name: Edsel Apostol
Contact:

Re: A very simple engine in C/C++ using bitboards?

Post by Edsel Apostol » Wed Oct 03, 2018 7:29 pm

pocopito wrote:
Mon Oct 01, 2018 1:35 pm
Hi all

Maybe someone here remembers Firstchess "FirstChess, a very simple open source chess program with a command line interface written by Nguyen Hong Pham (surname) in C for didactic purpose, introduced in 2002"

https://github.com/nguyenpham/FirstChess

I'm wondering whether something similar, written in C/C++ but with bitboards exists.

Thanks in advance

Emilio
Try also this one. My early versions from 2005. This is a working xboard engine:

https://github.com/ed-apostol/TwistedLo ... c/omega9.c

User avatar
pocopito
Posts: 236
Joined: Tue Jul 12, 2011 11:31 am
Contact:

Re: A very simple engine in C/C++ using bitboards?

Post by pocopito » Wed Oct 03, 2018 7:47 pm

[/quote]

Try also this one. My early versions from 2005. This is a working xboard engine:

https://github.com/ed-apostol/TwistedLo ... c/omega9.c
[/quote]

This one doesn't compile

$ gcc -o omega9 omega9.c
omega9.c: In function ‘gettime’:
omega9.c:533:5: warning: implicit declaration of function ‘_ftime’; did you mean ‘ftime’? [-Wimplicit-function-declaration]
_ftime(&tv);
^~~~~~
ftime
omega9.c:534:15: error: invalid use of undefined type ‘struct _timeb’
return (tv.time * 1000 + tv.millitm);
^
omega9.c:534:32: error: invalid use of undefined type ‘struct _timeb’
return (tv.time * 1000 + tv.millitm);
^
omega9.c: In function ‘displayb’:
omega9.c:927:14: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long int’ [-Wformat=]
printf("%d.%s%s c: %d castle: %d ep square: %d eval: %d fifty: %d \n",
~^
%ld
(status - H) / 2 + (o ? 1 : 0), o ? " " : " ...", displaymove((status - 1)->m),
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
omega9.c: At top level:
omega9.c:148:15: error: storage size of ‘tv’ isn’t known
struct _timeb tv;
^~
Two first meanings of the dutch word "leren":
1. leren [vc] (learn, larn, acquire) acquire or gain knowledge or skills.
2. leren [v] (teach, learn, instruct) impart skills or knowledge to.

tpoppins
Posts: 919
Joined: Tue Nov 24, 2015 8:11 pm
Location: upstate

Re: A very simple engine in C/C++ using bitboards?

Post by tpoppins » Thu Oct 04, 2018 3:45 am

Compiles without errors with MinGW GCC 5.3.0 into a.exe -- attached.
Attachments
TwistedLogic-omega9.zip
Twisted Logic omega9
(28.17 KiB) Downloaded 62 times
Tirsa Poppins
CCRL

Post Reply