Chess2u
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Chess2uLog in

SecondChess

descriptionSecondChess - Page 2 EmptyRe: SecondChess

more_horiz
Of course there was something wrong about printBoard. I guess I just had got used to it and saw just right :) (the funny think is that I almost always use the terminal to play against secondchess).

Thanks for pointing it out, it's already fixed in the github repository.

Best Regards

E Diaz

descriptionSecondChess - Page 2 EmptyRe: SecondChess

more_horiz
Emilio
Great that you are aware of the board print console output.

I am now trying to more fully understand the PrintBoard function.
My C skills are very basic at the moment as I do not fully understand bitwise operators yet!
From Wikipedia:wikipedia bitwise
A bitwise AND takes two binary representations of equal length and performs the logical AND operation on each pair of corresponding bits.

So I need to understand these lines better

Code:

if ((i & 7) == 0)

if (i <= 56)
         {
            printf(" %d |", 8 - (((unsigned) i) >> 3));
         }

if ((i & 7) == 7)

and I need to understand this line better:

Code:

printf(" %c |", pieceName[piece[i] + (color[i] == WHITE ? 0 : 6)]);
(this line not bitwise op but the >> ? 0 : 6 << part).

SecondChess is using 1D arrays for it's board and piece reps and I need to more fully familiarise myself with this approach over the 2D approach I am more used to for matrix/board reps! Hopefully it won't take me too long to fully grasp this bitwise op & ID board rep coding ideas!

Best wishes
smile

descriptionSecondChess - Page 2 EmptyRe: SecondChess

more_horiz
The printboard function is a nice work by Mr Nguyen (The creator of firstchess, from wich secondchess started on).

And about bitwise operations, two of the most important ones are in the very first lines of code:

#define COL(pos) ((pos)&7)
#define ROW(pos) (((unsigned)pos)>>3)


Thanks god (and I mean the only true one) chess is played in an 8 by 8 board.

descriptionSecondChess - Page 2 EmptyRe: SecondChess

more_horiz
Emilio
Many thanks again for your very helpful reply
(reminding me of the board defines is very helpful in understanding PrintBoard function!!).
smile

descriptionSecondChess - Page 2 EmptyRe: SecondChess

more_horiz
Two minor modifcations:
-The diagrams are printed in a more easy to watch format
-As secondchess has no opening book, it always plays the same moves in the same position. It's a problem for me, because when I try to test it playing many games against another engine, many of the games are all the same. In order to provide more variety, and threfore allow a better detection of bugs in the move generator, I've added some randomnes to the evaluation. It's implemented in a very gross way, but so far it makes its work.

descriptionSecondChess - Page 2 EmptyRe: SecondChess

more_horiz
Emilio
Changes noted but I have problems with this version.
For some unknown reason to me, my compiled secondchess.exe will not run in Arena.
It does run from the command line but still seems to play 1....d4 vs 1.e4 99% time....
Regards

descriptionSecondChess - Page 2 EmptyRe: SecondChess

more_horiz
Thanks for the info Richard.

Maybe the code needs more randomness :)


I'll check the code later today and try to upload a new version.

EDIT: I've checked the code and executables and seem to work ok under linux: I get many different responses to 1-e4. Do you get any warning when compiling under Windows?
In any case, I myself will try to compile a windows version and upload it to github.

descriptionSecondChess - Page 2 EmptyRe: SecondChess

more_horiz
Hi Emilio
Thanks for your edit note.
I would appreciate it if you could manage to add windows version on github.
I looked today but no windows version yet on github.
I still am having the same issues with the current version playing with it in Arena.
I compile it with gcc (from MingW) on my Win7 but as black it it still only plays centre game vs 1.e4 for me!
I look forward to your windows version upload/attempt!
Many thanks & best wishes

descriptionSecondChess - Page 2 EmptyRe: SecondChess

more_horiz
It's odd: I've compiled a windows version from linux, but although the engine seems to work alright, for some reason the "randomness" is lost from one version to another. I'll have to make more tests with some very basic code in order to discover the source of the problem.

descriptionSecondChess - Page 2 EmptyRe: SecondChess

more_horiz
Emilio
Thanks for checking this.
What does addRand function do/how?
Can you explain it a little more?

Code:

int
addRand (int argc, char *argv[])
{
  /* Simple "srand()" seed: just use "time()" */
  unsigned int iseed = (unsigned int)time(NULL);
  srand (iseed);

  double randuno = (((double)rand()/RAND_MAX)) * 100;
  int randunofinal = (int)randuno;

  return randunofinal;
}


When I compile in Windows using Geany.21 I get

gcc -Wall -c "secondchess.c" (in directory: C:\Program Files (x86)\Arena\Engines\SecondChess\pocopito-secondchess-v0.1-35-gd1633e5\pocopito-secondchess-d1633e5)
secondchess.c: In function 'Gen':
secondchess.c:531: warning: implicit declaration of function 'IsInCheck'
secondchess.c:532: warning: implicit declaration of function 'IsAttacked'
secondchess.c: In function 'GenCaps':
secondchess.c:604: warning: unused variable 'row'
secondchess.c: In function 'Eval':
secondchess.c:873: warning: implicit declaration of function 'addRand'
secondchess.c: In function 'TakeBack':
secondchess.c:1433: warning: unused variable 'i'
secondchess.c: In function 'perft':
secondchess.c:1790: warning: unused variable 'tmpMove'
secondchess.c:1785: warning: unused variable 'value'
Compilation finished successfully.

Thanks

descriptionSecondChess - Page 2 EmptyRe: SecondChess

more_horiz
Hi and sorry for the delay.

I've had a hard time trying to solve a bug on quiescent search, and finally Ron Murawski kindly showed me the solution.

Related to the "randomness" stuff: for some reason I ignore it doesn't work propertly when compiled under windows. The function returns a value, but despite the seed being different, the value returned isn't random at all. Something similar to Dilbert's stripe:
https://2img.net/r/ihimg/photo/my-images/51/dilberttourofaccounting.png/sr=1

In any case, randomness is implemented really poorly, and probably I'll just remove it from the code. I guess in order to get randomnes when playing against other engines, I'll rely in the oponent's opening book.

As I mentioned above, now quiescent search is working propertly, and the engine can be easilly compiled with or without quiescent search. It's quite interesting how on a 1 ply search it's capable to avoid bad captures (for example taking a pawn with a knight that will be taken in the next move). In the next days I'll try to clean the code.

Regards

descriptionSecondChess - Page 2 EmptyRe: SecondChess

more_horiz
Just a short update:

-Right now a very simple qsearch implementation is already working. For beginners it can be interesting to study the differences in the analysis with and without qsearch (tanks to all who helped to develop this feature).
-perft function is done and after fixing a bug in the takeback function all the tests I've tried so far have been passed by secondchess so its move generator seems to be quite robust rihgt now.

It still lacks rules for 3 repetitions and 50 moves rules, but as the aim of secondchess is to be didactic they won't be implementd (maybe in a future engine).


Best regards

descriptionSecondChess - Page 2 EmptyRe: SecondChess

more_horiz
no Windows build?

descriptionSecondChess - Page 2 EmptyRe: SecondChess

more_horiz
Hi Vladimir, thanks for your interest in secondchess.

Secondchess is meant to be a didactic engine for people who are interested in learning how a very basic chess engine works. All the code is in a single C file heavily commented, and totals around 2000 lines.
Due to this approach its playing strentgh is really weak, and the main interest should be reading the code, modify it in order to make tests and compile it.
I guess in windows it can be compiled with tcc (tiny c compiler) but actually I haven't made this test myself.

In short: if you're looking for a chess engine to which play against or to analyze games, secondchess isn't the best option.

In any case in the next days I'll try to make a windows compilation and upload to the github repo.

Best regards

Emilio

descriptionSecondChess - Page 2 Emptywindows exe added

more_horiz
Well, thanks to Vladimir interest it seems I've been able to upload a windows executable to the repo.

I've tested it on windows7 and seems to work fine, but I wouldn't be surprised if it crashes here or there :)

Best regards

Emilio

descriptionSecondChess - Page 2 EmptyRe: SecondChess

more_horiz
Thanks Emilio. It works fine here, on Windows XP 32-bit / Windows 7 64-bit. smile

descriptionSecondChess - Page 2 EmptyRe: SecondChess

more_horiz
Thanks for the feedback.

I've modified the code so that the windows binary can show the perft results correctly.

descriptionSecondChess - Page 2 EmptyRe: SecondChess

more_horiz
SecondChess 0.1 w32
mediafire.com ?gjx2rdb5mxhmj2e

descriptionSecondChess - Page 2 EmptyRe: SecondChess

more_horiz
Hi Hossam

Thanks a lot for the link. Did you have any trouble compiling the windows executable? I'm developing secondchess from linux and shame on me I don't pay many attention to crossplataform: actually the win32 executable that is available at the repo is compiled from linux.

Regards

Emilio

descriptionSecondChess - Page 2 EmptyRe: SecondChess

more_horiz
@pocopito wrote:
Hi Hossam

Thanks a lot for the link. Did you have any trouble compiling the windows executable? I'm developing secondchess from linux and shame on me I don't pay many attention to crossplataform: actually the win32 executable that is available at the repo is compiled from linux.

Regards

Emilio

Hi Emilio

No, this is a mirror link for the latest official release bigsmile

From here: https://github.com/pocopito/secondchess/blob/master/secondchessW32.exe

descriptionSecondChess - Page 2 EmptysecondchessW32

more_horiz
I have just tried secondchessW32 in Arena & was shocked after 1.e4 it didn't play ...d5 but Nc6!
I was so shocked I lost the game! :-)

I am glad progress has been made on search/perft and movegen.As a beginner C coder there is lots here I do not understand still!
I would like to look at the code more (when I can get time!) and try and understand it!
Thanks for your work on it Emilio and I hope you may patiently help me understand secondchess c code in time!
Best wishes

descriptionSecondChess - Page 2 EmptyRe: SecondChess

more_horiz
Probably in the last update I modified the piece square tables or the maximum depth: that's the only two sources I can think of that can make change its output. I suggest you to modify the piece square tables and see how the engine's play is different.

If you have any problem understanding secondchess' code don't hesitate to ask: actually its goal is to be a tool for people who want to understand how a chess engine works.

Besides, in the last months I haven't modified secondchess because at least its content is what I wanted it to be. I'm developing a new engine based on secondchess, kitteneitor, in which I try to apply more complex features.

Best regards

Emilio

descriptionSecondChess - Page 2 EmptyRe: SecondChess

more_horiz
Just a little update; I added to the repository a png with the relations between the functions. It's quite a mess, but maybe it can help to whoever tries to understand the code.

The direct link:
https://github.com/pocopito/secondchess/blob/master/chart_functions.png

Regards

Emilio

descriptionSecondChess - Page 2 EmptyRe: SecondChess

more_horiz
It's much more complex than I expected bigsmile

SecondChess - Page 2 Chart_functions

descriptionSecondChess - Page 2 EmptyRe: SecondChess

more_horiz
does anyone know anything about the strength elo of this engine secondchess ... best

descriptionSecondChess - Page 2 EmptyRe: SecondChess

more_horiz
Permissions in this forum:
You cannot reply to topics in this forum