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

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

Moderators: hgm, Rebel, chrisw

User avatar
pocopito
Posts: 238
Joined: Tue Jul 12, 2011 1:31 pm

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

Post by pocopito »

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: 4605
Joined: Wed Oct 01, 2008 6:33 am
Location: Regensburg, Germany
Full name: Guenther Simon

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

Post by Guenther »

pocopito wrote: Mon Oct 01, 2018 3: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/
https://rwbc-chess.de

trollwatch:
Chessqueen + chessica + AlexChess + Eduard + Sylwy
Edsel Apostol
Posts: 803
Joined: Mon Jul 17, 2006 5:53 am
Full name: Edsel Apostol

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

Post by Edsel Apostol »

pocopito wrote: Mon Oct 01, 2018 3: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: 12538
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

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

Post by Dann Corbit »

pocopito wrote: Mon Oct 01, 2018 3: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: 88
Joined: Thu Oct 06, 2016 9:17 pm
Location: India

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

Post by mkchan »

Check out Teki:

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

It uses the classical bitboard approach (non-magic/rotated).
Uri Blass
Posts: 10268
Joined: Thu Mar 09, 2006 12:37 am
Location: Tel-Aviv Israel

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

Post by Uri Blass »

Guenther wrote: Mon Oct 01, 2018 4:50 pm
pocopito wrote: Mon Oct 01, 2018 3: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: 268
Joined: Sun Apr 24, 2011 12:33 am

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

Post by tttony »

Uri Blass wrote: Wed Oct 03, 2018 12:19 am
Guenther wrote: Mon Oct 01, 2018 4:50 pm
pocopito wrote: Mon Oct 01, 2018 3: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: 803
Joined: Mon Jul 17, 2006 5:53 am
Full name: Edsel Apostol

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

Post by Edsel Apostol »

pocopito wrote: Mon Oct 01, 2018 3: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: 238
Joined: Tue Jul 12, 2011 1:31 pm

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

Post by pocopito »

[/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 9:11 pm
Location: upstate

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

Post by tpoppins »

Compiles without errors with MinGW GCC 5.3.0 into a.exe -- attached.
Tirsa Poppins
CCRL