Problem with Negamax

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

universecoder
Posts: 53
Joined: Mon Sep 19, 2016 6:51 am

Re: Problem with Negamax

Post by universecoder »

Is it ok now ( the file think.cpp )
User avatar
hgm
Posts: 27808
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Problem with Negamax

Post by hgm »

universecoder wrote:I am finding it really difficult to communicate with xboard, is there any sample code available?
For a tutorial on interfacing with XBoard in a minimum amount of work, see

http://www.open-aurec.com/wbforum/viewt ... 24&t=51739
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: Problem with Negamax

Post by Sven »

universecoder wrote:Is it ok now ( the file think.cpp )
I would still assume that you intended to write

Code: Select all

whiteVal += pieceVals[piece];
instead of

Code: Select all

whiteVal += piece;
in staticEval(), and the same for black.

Furthermore, please have a look at your piece-square tables (ptable, ntable etc.). They should be reversed rank-wise, I think. For instance, you want to reward pawns and rooks on rank 7 but actually you do it for rank 2.

Testing whether your static evaluation makes sense could also be done by simply providing an "eval" command that prints the result of calling staticEval(), and possibly also the evaluation components leading to that result, maybe separately for white and black. You could then set up any position with "setboard" and send "eval" to see the evaluation for this position.
User avatar
hgm
Posts: 27808
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Problem with Negamax

Post by hgm »

Sven Schüle wrote:Of course I did not mention any kind of error handling. In case of a user move (opponent move) you need to check the move for legality first (after checking the move string itself for validity, e.g. "hello", "e2e4567" and "e9k4" aren't valid move strings. I do this by generating all legal moves and matching the from-to-promotionPiece triple that I have extracted from the move string against the move string. If there is no matching legal move then the user move is rejected with an error message (CECP protocol describes a standard style for it), otherwise you have found a valid move data structure including information like en passant or castling, and can make that move on the board.
Note that for normal Chess this is sort of a waste of time, as XBoard knows the rule of that, and can check the legality of moves for you (if you did not switch off "test legality"). In that case all moves you get are guaranteed to be legal.

This whole issue of legality checking and rejecting illegal moves stems from the time that XBoard could not reliably test moves for legality even for orthodox Chess. It is now only important for playing variants of which XBoard doesn't know the rules (mostly engine-defined variants).

Of course you can use this as a test for the engine, to see if it would ever reject perfectly legal moves. But for this there are far better tests (such as preft).
Last edited by hgm on Sun Oct 09, 2016 10:01 pm, edited 2 times in total.
universecoder
Posts: 53
Joined: Mon Sep 19, 2016 6:51 am

Re: Problem with Negamax

Post by universecoder »

Hello, I read this page: http://home.hccnet.nl/h.g.muller/interfacing.txt

But still it responds with broken pipe!

https://github.com/universecoder/Horus- ... /tree/test

I tried using xboard -debug but it is not helping. I know it's too simple but it's the first time I am doing this!
universecoder
Posts: 53
Joined: Mon Sep 19, 2016 6:51 am

Re: Problem with Negamax

Post by universecoder »

What the heck am I doing today!
Sorry.
User avatar
hgm
Posts: 27808
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Problem with Negamax

Post by hgm »

'Broken pipe' means that your engine crashed. If you don't see any output from the engine in the xboard.debug file that was created when you ran XBoard with the option -debug, it means your engine exited without printing anything.

A first test you should do is make the engine print some lines before doing anything at all (doesn't matter much what, "Hello World!" would do nice), and make sure you flush the standard output. Then at least that message should appear in the xboard.debug file.
universecoder
Posts: 53
Joined: Mon Sep 19, 2016 6:51 am

Re: Problem with Negamax

Post by universecoder »

I have reversed them row-wise, so mirroring the values for white and not doing anything for black should work, right?
universecoder
Posts: 53
Joined: Mon Sep 19, 2016 6:51 am

Re: Problem with Negamax

Post by universecoder »

Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: Problem with Negamax

Post by Sven »

universecoder wrote:I have reversed them row-wise, so mirroring the values for white and not doing anything for black should work, right?
Yes, that should work, although it is sort of a hack which you apply to display the tables in your source code in the same way as you look on a chess board (rank 1 at the bottom and rank 8 on top).

But you decide whether it "works" by testing!