I've implemented a custom command "board" so I could test the "position fen | startpos [moves ...]" implementation. The protocol is actually unclear about this. (This: http://wbec-ridderkerk.nl/html/UCIProtocol.html) It actually says "position fen | startpos [moves ...]", which made it look like as if the FEN-string goes where "fen" is declared now. It doesn't, according to arena. The command actually is "position fen <fen_string> | startpos [moves ...]"Terje wrote: ↑Fri Oct 23, 2020 3:21 am ucinewgame should reset TT and any other stuff you keep from turn to turn during a single game - could be things like previous turns final search depth, whether you saved time last move and want to spend more the coming turn etc. In Weiss this is still just clearing TT and resetting number of failed queries to chessdb.cn if using NoobBook.
It doesn't have to reset the board (though it doesn't hurt); a position command must be sent before each go command. Setting up the board on startup is nice for humans doing a quick manual test, but manually playing a full game and starting a new one ucing UCI in a terminal seems unlikely.
Also, what to do if "moves" contains an illegal move? I use my engine's internal move generator and make move to determine if "e2e4" is actually a possible pseudo-move. Then I execute it, but if it's illegal, it will be unmade, obviously. I tested this in Texel 1.07, and if to, from, and promotion piece are legal, it actually just moves the piece on the board. If you start with "position startpos moves e2d6" and then "go", it will capture the pawn on d6.
In my engine, I can't even do that, except if I start to just flip bits and actually circumvent the engine itself.
Assuming a GUI never accepts illegal moves and never sends illegal moves (or wrongly formatted FEN-strings), I've decided to not worry about that, and:
- Try to set up the FEN. If it fails, print a message and don't change the board. (Useful if someone is using the engine through the console; it already functions like this internally.)
- Try to execute moves. As soon as there is an illegal one, print a message pointing out this move, and stop processing the move list.
This seems to work fine; it uses the engine's own error checking facilities. The only thing I had to add was to print a message in case someone is putting this in through the console. (And so I can, should I want to, log communication and retrace it.)
(As an example: here, d5d4 puts the king in check so the engine won't have you execute this move.)
Code: Select all
$ ./target/release/rustic.exe
d888888b dP oo
88 88 88
88oooo88 88 88 d8888b d8888P dP d88888b
88 88 88 88 8ooooo 88 88 88
88 88 88 88 88 88 88 88
88 88 88888P 888888P dP dP 888888P
ooooooooooooooooooooooooooooooooooooooooooooo
Engine: Rustic Alpha 1
Author: Marcel Vanthoor
EMail: mail@marcelvanthoor.nl
Website: https://rustic-chess.org/
Protocol: uci
Threads: 1
position fen 8/3p4/8/4k3/8/8/Q7/5K2 w - - 0 1 moves a2a5 d7d5 f1e2 d5d4
d5d4: This is not a legal move in this position.
board
8 . . . . . . . .
7 . . . . . . . .
6 . . . . . . . .
5 Q . . i k . . .
4 . . . . . . . .
3 . . . . . . . .
2 . . . . K . . .
1 . . . . . . . .
A B C D E F G H
Zobrist key: 250d5801f898ffd7
Active Color: Black
Castling:
En Passant: -
Half-move clock: 1
Full-move number: 2
Thanks; almost there. I hope to be able to play a testing game this weekendGetting close, keep at it