Invalid fen

Discussion of chess software programming and technical issues.

Moderators: bob, hgm, Harvey Williamson

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
User avatar
hgm
Posts: 23615
Joined: Fri Mar 10, 2006 9:06 am
Location: Amsterdam
Full name: H G Muller
Contact:

Re: Invalid fen

Post by hgm » Wed Apr 01, 2015 11:12 am

lucasart wrote:I don't know if the UCI protocol specifies this explicitly, but if it doesn't it's because it assumes the reader isn't retarded. So I will re-explain it for you:

Code: Select all

Incorrect input => Undefined behaviour
Even if SF could recognize an invalid FEN, SF would write a message, and what is the GUI supposed to do? Nothing in the UCI protocol specifies the format of such an error message, and how it's supposed to be handled by the GUI. It is the assumption of the UCI protocol that the GUI isn't bogous. And it is the intent of the UCI protocol to avoid reinventing wheels in every engine, and factorizing as much as possible in the GUI (eg. input validation, book management, option parsing rather than reading text config files in hardcoded paths like old xboard engines etc.)
Obviously this should be explained to you:
Undefined behavior => crappy software
(And indeed, the UCI specs do not explicitly specify there should be undefined behavior. In fact it is something you just made up yourself.)

Your reasoning is flawed in several respects:

- By supporting features beyond UCI (such as perft), the assumption that a GUI will be used as front-end is obviously non-sensical.

- UCI does actually define a mechanism to present messages to the user: "info string MESSAGE". This could be used to send warnings to the user, which the latter could see when he runs from the command line, and which any compliant GUI would relay to him.

- Even if you want to insist that UCI is highly deficient, and does not allow for such elementary courtesies as error messages, it is still your own choice to use it. That crappiness results from the choice of an inadequate protocol does not make it any less crappy than when it would result from any other bug or design flaw.

Aleks Peshkov
Posts: 870
Joined: Sun Nov 19, 2006 8:16 pm
Location: Russia

Re: Invalid fen

Post by Aleks Peshkov » Sat Apr 04, 2015 12:36 pm

Anybody can verify my perft numbers?

position fen rrrrkr1R/rr1rr3/8/8/8/8/8/6K1 b abcdf -
1: 39
2: 376
3: 18105
4: 204974
5: 11293287
6: 135685036
7: 7893079147

elcabesa
Posts: 806
Joined: Sun May 23, 2010 11:32 am
Contact:

Re: Invalid fen

Post by elcabesa » Sat Apr 04, 2015 12:48 pm

I don't understad your fen string , but probably because I only know hortodox chess :)

that said, hose are my perft result:

rrrrkr1R/rr1rr3/8/8/8/8/8/6K1 b - - 0
1: 39
2: 376
3: 17835
4: 201108
5: 10939405
6: 130907832
7: 7531849347

Henk
Posts: 5799
Joined: Mon May 27, 2013 8:31 am

Re: Invalid fen

Post by Henk » Sat Apr 04, 2015 12:59 pm

elcabesa wrote:I don't understad your fen string , but probably because I only know hortodox chess :)

that said, hose are my perft result:

rrrrkr1R/rr1rr3/8/8/8/8/8/6K1 b - - 0
1: 39
2: 376
3: 17835
4: 201108
5: 10939405
6: 130907832
7: 7531849347
Something completely different:

TestPerft(3, "rrrrkr1R/rr1rr3/8/8/8/8/8/6K1 b k - 0 1", 17835);

Gives "System.Exception: invalid fen: short castling rights black"

User avatar
Evert
Posts: 2923
Joined: Fri Jan 21, 2011 11:42 pm
Location: NL
Contact:

Re: Invalid fen

Post by Evert » Sat Apr 04, 2015 9:41 pm

Aleks Peshkov wrote:Anybody can verify my perft numbers?

position fen rrrrkr1R/rr1rr3/8/8/8/8/8/6K1 b abcdf -
1: 39
2: 376
3: 18105
4: 204974
5: 11293287
6: 135685036
7: 7893079147

Code: Select all

#[Chess] 0w>setboard rrrrkr1R/rr1rr3/8/8/8/8/8/6K1 b abcdf -
 8r r r r k r   R *
 7r r   r r       
 6                
 5                
 4                
 3                
 2                
 1            K   
  a b c d e f g h 
#[Chess] 0b (f)>perft 6
 1         39  0.00    684210.53nps
 2        376  0.00   1579831.93nps
 3      18105  0.01   3472382.05nps
 4     204974  0.04   4935802.35nps
 5   11290454  1.78   6325864.74nps
 6  135645554 26.89   5043927.64nps

Aleks Peshkov
Posts: 870
Joined: Sun Nov 19, 2006 8:16 pm
Location: Russia

Re: Invalid fen

Post by Aleks Peshkov » Mon Apr 06, 2015 10:19 am

Aleks Peshkov wrote:Anybody can verify my perft numbers?

position fen rrrrkr1R/rr1rr3/8/8/8/8/8/6K1 b abcdf -
1: 39
2: 376
3: 18105
4: 204974
5: 11293287
6: 135685036
7: error
7: 7893075637
8: 96373302738

User avatar
SMIRF
Posts: 91
Joined: Wed Mar 26, 2014 3:29 pm
Location: Buettelborn/Hessen/Germany
Contact:

Re: Invalid fen

Post by SMIRF » Tue Apr 07, 2015 5:19 am

there only could be two active castling columns (see '*' marks), e.g.:

Code: Select all

XFEN 00: rrrrkr1R/rr1rr3/8/8/8/8/8/6K1 b kq - 0 1
(b)+-*--b--c--d--*--*--g--h-+
 8 |&#91;r&#93;&#91;r&#93;&#91;r&#93;&#91;r&#93;&#91;k&#93;&#91;r&#93;   <R>|  Compiled on Apr  7 2015
 7 |&#91;r&#93;&#91;r&#93;&#58;&#58;&#58;&#91;r&#93;&#91;r&#93;   &#58;&#58;&#58;   |  MS Vis.Studio C/C++ 64-Bit Vers. 18.0
 6 |   &#58;&#58;&#58;   &#58;&#58;&#58;   &#58;&#58;&#58;   &#58;&#58;&#58;|
 5 |&#58;&#58;&#58;   &#58;&#58;&#58;   &#58;&#58;&#58;   &#58;&#58;&#58;   |  Break, when time >= 5.0 sec
 4 |   &#58;&#58;&#58;   &#58;&#58;&#58;   &#58;&#58;&#58;   &#58;&#58;&#58;|
 3 |&#58;&#58;&#58;   &#58;&#58;&#58;   &#58;&#58;&#58;   &#58;&#58;&#58;   |  &#40;run with 4-fold TT hashing&#41;
 2 |   &#58;&#58;&#58;   &#58;&#58;&#58;   &#58;&#58;&#58;   &#58;&#58;&#58;|
 1 |&#58;&#58;&#58;   &#58;&#58;&#58;   &#58;&#58;&#58;   <K>   |
   +-a--b--c--d--e--f--g--h-+

Ply      Moves   all &#91;x&#93; &#91;ep&#93;    all &#91;+&#93; &#91;++&#93; Prom     Cstl Time
 1&#58;         39         1    0          7    0    0        0 0.00
 2&#58;        376        33    0         33    0    0        0 0.00
 3&#58;      18039       220    0       2877    0    0      204 0.00
 4&#58;     204085      9724    0      10687    0    0        0 0.00
 5&#58;   11194917    137417    0    1580468    0    0   109450 0.11
 6&#58;  134393515   7249723    0    7075928    0    0        0 0.94
 7&#58; 7780247748 112617238    0 1057026618    0    0 62337934 6.28

Aleks Peshkov
Posts: 870
Joined: Sun Nov 19, 2006 8:16 pm
Location: Russia

Re: Invalid fen

Post by Aleks Peshkov » Tue Apr 07, 2015 9:28 am

SMIRF wrote:

Code: Select all

 5&#58;   11194917    137417    0    1580468    0    0   109450 0.11
My number is 11194916 here.

Henk
Posts: 5799
Joined: Mon May 27, 2013 8:31 am

Re: Invalid fen

Post by Henk » Tue Apr 07, 2015 9:33 am

Aleks Peshkov wrote:
SMIRF wrote:

Code: Select all

 5&#58;   11194917    137417    0    1580468    0    0   109450 0.11
My number is 11194916 here.
fen is invalid should be:

Code: Select all

rrrrkr1R/rr1rr3/8/8/8/8/8/6K1 b q - 0 1
Only castling on the queen side makes sense.

Aleks Peshkov
Posts: 870
Joined: Sun Nov 19, 2006 8:16 pm
Location: Russia

Re: Invalid fen

Post by Aleks Peshkov » Tue Apr 07, 2015 9:43 am

Code: Select all

rrrrkr1R/rr1rr3/8/8/8/8/8/6K1 b kq -
 1 e8f7 304286
 2 d7d1 58515
 3 d7d2 337958
 4 d7d3 431916
 5 d7d4 426319
 6 d7d5 411939
 7 d7d6 397690
 8 d7c7 290526
 9 e7e1 46820
10 e7e2 268995
11 e7e3 357363
12 e7e4 365643
13 e7e5 366635
14 e7e6 367536
15 e7f7 236853
16 e7g7 32800
17 e7h7 47283
18 b7b1 56799
19 b7b2 334041
20 b7b3 424513
21 b7b4 418309
22 b7b5 403634
23 b7b6 389230
24 b7c7 280939
25 a7a1 54889
26 a7a2 325633
27 a7a3 412838
28 a7a4 406581
29 a7a5 392186
30 a7a6 378069
31 c8c1 46815
32 c8c2 279431
33 c8c3 364842
34 c8c4 370864
35 c8c5 369809
36 c8c6 368876
37 c8c7 281849
38 f8g8 56542
39 f8h8 29150
Total&#58; 11194916

Post Reply