review of my code

Discussion of chess software programming and technical issues.

Moderator: Ras

flok

review of my code

Post by flok »

Hi,

I was wondering: is anyone interested to give me a little help?
I'm stuck in finding the bug which causes very strange moves.
As far as I can see/test the whole alpha/beta and evaluation code is fine (both in single- and multi-threaded mode), but clearly something must be wrong if you see what moves it does. Oh and the move generator is probably also not deffect as it has played 100k matches on fics in a different version of my engine.
It is probably a small thing but I don't see it.

I could just publish the code but I'm afraid someone would clone it, change names, and tell the world it is his. Of course I would need to trust the people I send the code (catch 22?).
rreagan
Posts: 102
Joined: Sun Sep 09, 2007 6:32 am

Re: review of my code

Post by rreagan »

Can you post examples of the strange moves it makes?
flok

Re: review of my code

Post by flok »

Here's an example:

[Event "Computer Chess Game"]
[Site "mulder"]
[Date "2013.09.25"]
[Round "-"]
[White "DeepBrutePos/1.7/Tue Aug 27 21:31:13 2013/631"]
[Black "GNU Chess"]
[Result "0-1"]
[TimeControl "40/300"]
[Annotator "10. +2.60 1... -0.22"]

1. Nf3 Nc6 {-0.22/12 5} 2. c4 Nf6 {+0.01/12} 3. g3 e5 {+0.35/11} 4. Nc3 Bb4
{+0.30/11} 5. Nd5 e4 {+0.45/12} 6. Nxb4 Nxb4 {+0.39/11 0.1} 7. Nd4 O-O
{+0.28/12} 8. Bg2 d5 {+0.45/12 0.1} 9. Nc2 a5 {+0.39/12} 10. Bxe4
{+2.60/5 3} dxe4 {+3.12/12 0.1} 11. O-O {+2.45/5 0.4} Bh3 {+4.39/15} 12.
Ne1 {-2.70/5} Bxf1 {+5.55/12} 13. Qb3 {-2.30/5} Qd7 {+10.13/12} 14. Nf3
{-1.30/5} Qh3 {+99.91/31} 15. Ne1 {-2.70/5} Bxe2 {+99.95/49} 16. Ng2
{-14.75/7} Ng4 {+99.97/46} 17. Qxb4 {-100.00/7} Qxh2# {+99.99/45 3}
{Xboard adjudication: Checkmate} 0-1

I'm not an expert but move 5, 9, 10, 11 and 17 look rather silly to me.
mar
Posts: 2674
Joined: Fri Nov 26, 2010 2:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: review of my code

Post by mar »

It's hard to say but you obviously have some nasty bug(s).
No matter what any engine would probably recapture the bishop at move 13.
Have you tried turning hashtable off? Tried perft?
I think you can try to disable features until you figure out what's causing problems.
You can also try the position before move 13 and debug the search to find out why it didn't recapture. I think a 5 ply search should see it even without qsearch.
A side note: why do you play against GNU Chess?
It's a very strong engine and I guess the difference is so big that your engine won't score even a single halfpoint against it until the end of ages (in it's current state).
I think you should find an appropriate opponent.
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: review of my code

Post by Sven »

flok wrote:I'm not an expert but move 5, 9, 10, 11 and 17 look rather silly to me.
The blunders are the white moves 10 (this one already loses the game), 12, 13 and 14. Something very basic must go wrong since the engine sacrifices whole pieces for no obvious reason.

Does that happen with your single-core engine, or only with the SMP version?

Sven
flok

Re: review of my code

Post by flok »

(reply to Martin and Sven):

This happens also with single core, no transposition table, no move ordening.
At one stage I tested +/- perft alike code. The result was somewhat neer the expected amount.
mar
Posts: 2674
Joined: Fri Nov 26, 2010 2:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: review of my code

Post by mar »

flok wrote:At one stage I tested +/- perft alike code. The result was somewhat neer the expected amount.
Near the expected amount is not enough :)
I suggest you debug your move generator. You can try to use divide (i.e. subcounts for each move) to trace the problem.
syzygy
Posts: 5895
Joined: Tue Feb 28, 2012 11:56 pm

Re: review of my code

Post by syzygy »

mar wrote:
flok wrote:At one stage I tested +/- perft alike code. The result was somewhat neer the expected amount.
Near the expected amount is not enough :)
I suggest you debug your move generator. You can try to use divide (i.e. subcounts for each move) to trace the problem.
It is really not worth asking other people for help as long as not all perft counts are accurate...
flok

Re: review of my code

Post by flok »

Well, that is I think the whole point.
I can't find what is causing that it is giving the incorrect perft counts.
Especially since move-generation seems to be fine - I used the move generator from "pos" (the non-brute-force engine I wrote earlier) and that one has been playing for years on fics without never any matches lost because of incorrect moves (104492 games currently).
JVMerlino
Posts: 1407
Joined: Wed Mar 08, 2006 10:15 pm
Location: San Francisco, California

Re: review of my code

Post by JVMerlino »

flok wrote:Well, that is I think the whole point.
I can't find what is causing that it is giving the incorrect perft counts.
Especially since move-generation seems to be fine - I used the move generator from "pos" (the non-brute-force engine I wrote earlier) and that one has been playing for years on fics without never any matches lost because of incorrect moves (104492 games currently).
Never playing illegal moves is not the same as knowing all of the legal moves that can be played.

jm