FB_Numpty wrote:Re my earlier post - I've found the problem with the error in illegal move generation - it's not the move gen function but a problem related to using setboard again.
The clear board subroutine is not initialising accurately meaning that the off-board guardian values (-99) are not being set for invalid squares, so the board is effectively wrapping around:
variable X needs to be stepped by 10 as it is 10x12 board and guardians are the 2 squares either side of the board
With the above change the perft values from the previous post for Nomega_Win_DD are correct.
I altered something but remove/added to much, my apologize for that.
First About GCC I found what made GCC crash under winboard/arena.
After compile with -exx I found that it stop with a error message array out of bounds. I made act_epsq an UInteger but a -1 is loaded into it so it needs to be a Integer. Secondly there is check using B(act_epsq) since act_epsq can be -1 the array b() was out of bounds (0 to 119) needs to be (-1 to 119).
Code: Select all
Dim Shared As Integer B(-1 To 119)
Dim Shared As Integer act_epsq ' actual ep-square value (ie post-move)
Restore
For x = -1 To 119
B(x) = -99
Next x
It stopped crashing but it will not work under winboard/arena, it receives data from winboard/arena but sending date does not work. I don't know why. In console mode GCC runs just like FB.
(Need to make it a habit to testing with -exx, even when array are out of bound FB does not allways crash).
Stop working when there is a promoted queen.
With hindsight it made sense, data is send in lower case the test for it uses upper case letters
Code: Select all
' ...in winboard mode
If WinboardMode = 1 And B(MoveTo) = 1 And MoveTo > 90 Then
If pr_str = "Q" Then B(MoveTo) = 6 need to be "q", "r", "b", "n"
If pr_str = "R" Then B(MoveTo) = 4
If pr_str = "B" Then B(MoveTo) = 3
If pr_str = "N" Then B(MoveTo) = 2
End If
If WinboardMode = 1 And B(MoveTo) = -1 And MoveTo < 29 Then
If pr_str = "Q" Then B(MoveTo) = -6
If pr_str = "R" Then B(MoveTo) = -4
If pr_str = "B" Then B(MoveTo) = -3
If pr_str = "N" Then B(MoveTo) = -2
End If
Something I changed and forgot about
Code: Select all
If O$ = "go" then
if side = white then cmpclr = 1
if side = black then cmpclr = 1 <== need to be -1
call computer_move(side)
call display()
if assessboard(side,best_score) = true then call ending()
side = -side
end if
When working on the program I got a idea for the incheck/attack routine for check by Bishop/Rook/Queen
Code: Select all
Do
K += Move_Offset(N)
Loop Until (B(k) <> 0) 'keep looping until a non zero field is found
If B(k) = val_bishop Or B(k) = val_queen Then ' if it contains a bishop or queen then incheck= true else try next direction
Return TRUE
End If
simple code, guess a roll out will bring some speed up.
I called it it castling problem but it that looks to be wrong, it looks more a problem where the king is incheck and then makes the wrong move. Have a look a the following game data.
Code: Select all
[Event "Test111hla1"]
[Site "USER-PC"]
[Date "2014.03.10"]
[Round "2"]
[White "Numpty_DD"]
[Black "nomega"]
[Result "1-0"]
[BlackElo "2200"]
[ECO "C43"]
[Opening "Russian Game"]
[Time "14:28:42"]
[Variation "Modern Attack, 3...Nxe4 4.Bd3 d5 5.Nxe5 Be7"]
[WhiteElo "2200"]
[TimeControl "30/300:30/300:30/300"]
[Termination "rules infraction"]
[PlyCount "47"]
[WhiteType "program"]
[BlackType "program"]
1. e4 e5 2. Nf3 Nf6 3. d4 Nxe4 4. Bd3 d5 5. Nxe5 Nd7 6. Nd2 {(b1d2) +0.02/6
11} Nec5 {(e4c5) -0.32/6 11} 7. O-O {(e1g1) 0.00/6 11} Nxe5 {(d7e5) -0.27/6
11} 8. dxe5 {(d4e5) +0.22/7 19} Nxd3 {(c5d3) -0.22/6 11} 9. cxd3 {(c2d3)
-0.08/4 0} Be7 {(f8e7) -0.22/6 11} 10. d4 {(d3d4) -0.15/6 11} O-O {(e8g8)
-0.15/6 11} 11. Nf3 {(d2f3) -0.20/6 10} Be6 {(c8e6) -0.15/6 7} 12. Qb3
{(d1b3) -0.05/6 10} Rb8 {(a8b8) -0.15/6 12} 13. Be3 {(c1e3) -0.15/6 11} f6
{(f7f6) -0.08/6 11} 14. Rad1 {(a1d1) -0.13/6 12} Bg4 {(e6g4) +0.05/6 11}
15. Bf4 {(e3f4) -0.20/6 11} fxe5 {(f6e5) +0.11/6 11} 16. Bxe5 {(f4e5)
-0.04/7 10} Qd7 {(d8d7) +0.04/6 12} 17. Rc1 {(d1c1) -0.18/6 12} Rfc8
{(f8c8) +0.01/6 12} 18. Bf4 {(e5f4) -0.11/6 11} Bf5 {(g4f5) -0.02/6 13} 19.
Rfe1 {(f1e1) -0.11/6 12} Bf6 {(e7f6) -0.19/6 11} 20. Qc3 {(b3c3) +0.19/5 8}
Ra8 {(b8a8) -0.14/6 13} 21. Qc5 {(c3c5) +0.14/5 9} b6 {(b7b6) -0.27/6 13}
22. Qc6 {(c5c6) +0.52/6 13} Qxc6 {(d7c6) -0.62/6 14} 23. Rxc6 {(c1c6)
+0.52/4 0} Bd8 {(f6d8) -0.62/6 11} 24. Re8 {(e1e8) +0.57/6 14 Arena
Adjudication. Illegal move!} 1-0
If you look at the first part of the FEN you can see that the black king is attack by a white rook,
r1rbR1k1/p1p3pp/1pR5/3p1b2/3P1B2/5N2/PP3PPP/6K1 b - - 2 24
black plays Bf5-g6 ignoring the fact that it is checked, the only legal move for black is Kg8-f7.
I entered the FEN with setboard and saved it (loading it is easier than retyping it).
When I loaded it, I gave a perft command, level 1,and I got a answer of 30 nodes. This is wrong and thinking about it I realized that the load routine does not set wkloc and bkloc to it proper value's. Added some code to do this and tried again, the answer was 1 node. The best idea I now have about the problem is that the program somehow loses track of the position of the king's.
new version
It uses the book for openings and also uses the variations. Endgames vary, kings tends to prefer the center leaving pawns on the edge on there own, when both sides are equal in strength most games end in 3 fold repetions.
EDIT:
Link points to a newer version, Nomega will compile with GCC(64) and run under Arena.