Programming chess engine

Code, algorithms, languages, construction...
User923005
Posts: 616
Joined: Thu May 19, 2011 1:35 am

Re: Programming chess engine

Post by User923005 » Wed Aug 27, 2014 6:13 pm

The header file conio.h is a non-standard header file.
However, it is not needed anyway. Just comment it out.

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

Re: Programming chess engine

Post by spacerocket » Fri Aug 29, 2014 4:59 pm

Just remove #include <conio.h> ?

User923005
Posts: 616
Joined: Thu May 19, 2011 1:35 am

Re: Programming chess engine

Post by User923005 » Fri Aug 29, 2014 7:08 pm

Yes. Remove it. It isn't needed.

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

Re: Programming chess engine

Post by spacerocket » Fri Aug 29, 2014 7:55 pm

I get error message if I remove it and try to compile...

User923005
Posts: 616
Joined: Thu May 19, 2011 1:35 am

Re: Programming chess engine

Post by User923005 » Tue Sep 02, 2014 2:31 pm

What error message do you get?

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

Re: Programming chess engine

Post by spacerocket » Thu Sep 04, 2014 6:52 pm

Code: Select all

Documents/firstchess.c: In function ‘int Eval()’:
Documents/firstchess.c:313:124: warning: large integer implicitly truncated to unsigned type [-Woverflow]
     unsigned char             value_piece[6] = {VALUE_PAWN, VALUE_KNIGHT, VALUE_BISHOP, VALUE_ROOK, VALUE_QUEEN, VALUE_KING};
                                                                                                                            ^
Documents/firstchess.c:313:124: warning: large integer implicitly truncated to unsigned type [-Woverflow]
Documents/firstchess.c:313:124: warning: large integer implicitly truncated to unsigned type [-Woverflow]
Documents/firstchess.c:313:124: warning: large integer implicitly truncated to unsigned type [-Woverflow]
Documents/firstchess.c:313:124: warning: large integer implicitly truncated to unsigned type [-Woverflow]
Documents/firstchess.c: In function ‘void ComputerThink(unsigned char)’:
Documents/firstchess.c:616:48: warning: large integer implicitly truncated to unsigned type [-Woverflow]
     score = Search(-MATE, MATE, max_depth, &mm3);
                                                ^
Documents/firstchess.c:616:48: warning: large integer implicitly truncated to unsigned type [-Woverflow]
Documents/firstchess.c: At global scope:
Documents/firstchess.c:661:23: error: ‘::main’ must return ‘int’
 void             main()
                       ^
Documents/firstchess.c: In function ‘int main()’:
Documents/firstchess.c:687:30: error: too many arguments to function ‘int MakeMove()’
             MakeMove(bestMove);
                              ^
Documents/firstchess.c:497:13: note: declared here
 static int  MakeMove()
             ^
Documents/firstchess.c:697:30: warning: format ‘%s’ expects argument of type ‘char*’, but argument 3 has type ‘char (*)[256]’ [-Wformat=]
         sscanf (buf, "%s", &s);
                              ^
Documents/firstchess.c:714:13: error: return-statement with no value, in function returning ‘int’ [-fpermissive]
             return;
             ^

User923005
Posts: 616
Joined: Thu May 19, 2011 1:35 am

Re: Programming chess engine

Post by User923005 » Thu Sep 04, 2014 9:09 pm

Change:
void main()

to:
int main(void)

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

Re: Programming chess engine

Post by spacerocket » Fri Sep 05, 2014 1:04 pm

Code: Select all

Documents/firstchess.c: In function ‘int Eval()’:
Documents/firstchess.c:313:124: warning: large integer implicitly truncated to unsigned type [-Woverflow]
     unsigned char             value_piece[6] = {VALUE_PAWN, VALUE_KNIGHT, VALUE_BISHOP, VALUE_ROOK, VALUE_QUEEN, VALUE_KING};
                                                                                                                            ^
Documents/firstchess.c:313:124: warning: large integer implicitly truncated to unsigned type [-Woverflow]
Documents/firstchess.c:313:124: warning: large integer implicitly truncated to unsigned type [-Woverflow]
Documents/firstchess.c:313:124: warning: large integer implicitly truncated to unsigned type [-Woverflow]
Documents/firstchess.c:313:124: warning: large integer implicitly truncated to unsigned type [-Woverflow]
Documents/firstchess.c: In function ‘void ComputerThink(unsigned char)’:
Documents/firstchess.c:616:48: warning: large integer implicitly truncated to unsigned type [-Woverflow]
     score = Search(-MATE, MATE, max_depth, &mm3);
                                                ^
Documents/firstchess.c:616:48: warning: large integer implicitly truncated to unsigned type [-Woverflow]
Documents/firstchess.c: In function ‘int main()’:
Documents/firstchess.c:687:30: error: too many arguments to function ‘int MakeMove()’
             MakeMove(bestMove);
                              ^
Documents/firstchess.c:497:13: note: declared here
 static int  MakeMove()
             ^
Documents/firstchess.c:697:30: warning: format ‘%s’ expects argument of type ‘char*’, but argument 3 has type ‘char (*)[256]’ [-Wformat=]
         sscanf (buf, "%s", &s);
                              ^
Documents/firstchess.c:714:13: error: return-statement with no value, in function returning ‘int’ [-fpermissive]
             return;
             ^

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

Re: Programming chess engine

Post by microp » Sun Sep 14, 2014 9:26 pm

I didn't remember firstchess to have these issues at compiling.

Maybe you can give a try to secondchess. It was my own project some years ago, and it's basically firstchess + castle + ep. So the code isn't much more complex than first chess:
https://github.com/emdio/secondchess

BTW in the repo there is a chart_functions.png image with the relations between the functions.

Hope this helps

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

Re: Programming chess engine

Post by spacerocket » Fri Dec 05, 2014 6:54 pm

Yes, now I have had more time to write code, I should put more time to it in the near future. I have finished my tictactoe, which can be found at https://github.com/matrix110/Tictactoe. No quality guarantees, I just tested that it compiles

I have to admit that I haven`t looked much into C programs because C and C++ are separate languages. Not much time to chessprogramming though. I know that the engine needs to be well planned, otherwisely can happen old-fashioned :D

Post Reply