Myracle GUI

Discussion of anything and everything relating to chess playing software and machines.

Moderator: Ras

Max
Posts: 279
Joined: Tue Apr 13, 2010 10:41 am

Re: Myracle GUI

Post by Max »

Played in the meantime several "normal" games with Beowulf and all went well!

Only with an starting position (i.e. without Nb1) the forfeit by illegal move happens after opponents castling.

I use this book without-Nb1.pgn for all knight odd games:

Code: Select all

[Event "?"]
[Site "?"]
[Date "????.??.??"]
[Round "?"]
[White "?"]
[Black "?"]
[Result "*"]
[SetUp "1"]
[FEN "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/R1BQKBNR w KQkq - 0 1"]

*
It seems to be an issue of Beowulf and has nothing to do with Myracle.
Sorry Martin :oops:
mar
Posts: 3121
Joined: Fri Nov 26, 2010 2:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: Myracle GUI

Post by mar »

no problem, I'm glad we figured it out - perhaps someone interested might fix the engine since it's open source.
it seems that in parser.c in EditMode function the engine should infer castling rights before BoardToFEN,
where kings and rooks are in their initial positions. it's funny that Beowulf supports setboard <fen>, but that is protover 2 command,
so the GUIs don't know it's available.
Max
Posts: 279
Joined: Tue Apr 13, 2010 10:41 am

Re: Myracle GUI

Post by Max »

Thanks Martin!

I asked our overlords and they came up with an solution, which worked :idea:
The output after 9 seconds:

I've (ChatGPT) located the problem in the repository, and your (Martins) diagnosis is correct.

Code: Select all

In parser.c, the EditMode() function modifies the board's pieces[] array directly. However, it never updates the board's castling-rights field (B->castle) before calling BoardToFEN().

This is important because Beowulf stores castling permissions separately from the piece positions.

The castling flags are defined by the FEN parser in board.c:

Bit value	Castling right
1	White kingside (K)
2	White queenside (Q)
4	Black kingside (k)
8	Black queenside (q)

Therefore, the solution is to reconstruct B->castle from the actual king and rook positions after editing the board and immediately before calling BoardToFEN().
1. The fix

Code: Select all

Open parser.c and locate the end of EditMode().

Currently, you have:
c

} while (input[0] != '.');

BoardToFEN(B,FEN);

SetBoard(B,FEN,TRUE);

Replace it with:
c

} while (input[0] != '.');

/* Reconstruct castling rights from the edited position. */
B->castle = 0;

/* White castling rights */
if (B->pieces[e1] == wking) {
    if (B->pieces[h1] == wrook)
        B->castle |= 1;  /* White kingside */

    if (B->pieces[a1] == wrook)
        B->castle |= 2;  /* White queenside */
}

/* Black castling rights */
if (B->pieces[e8] == bking) {
    if (B->pieces[h8] == brook)
        B->castle |= 4;  /* Black kingside */

    if (B->pieces[a8] == brook)
        B->castle |= 8;  /* Black queenside */
}

BoardToFEN(B,FEN);

SetBoard(B,FEN,TRUE);
2. Why this works

Code: Select all

The implementation follows the existing Beowulf conventions:

    e1 and e8 are the original king squares.
    a1 and h1 are the original white rook squares.
    a8 and h8 are the original black rook squares.
    wking, bking, wrook and brook are the existing piece constants.

The king must be on its original square for either castling permission to be granted.

Likewise, each rook must be on its corresponding original square.

Importantly, B->castle is reset to zero first. This prevents stale castling permissions from the position that existed before entering edit mode.

BoardToFEN() then correctly converts these flags into KQkq (or -).
3. Testing

Code: Select all

Recompile:
bash

clang -O3 chess.c -o beowulf -lm

Start Beowulf and enter XBoard edit mode:
text

xboard
edit
<..deleted by me TLDR ..>
4. One important detail

Code: Select all

This implementation deliberately infers castling rights from piece placement, as requested.

There is a distinction between:

    A rook and king currently occupying their original squares.
    A rook and king that have never moved.

FEN castling rights represent the second condition, which cannot always be determined from piece placement alone.

However, XBoard's edit command is intended to construct a position, and inferring rights from the original king and rook squares is a reasonable convention for this use case.

My recommendation: Apply this small patch in EditMode() rather than modifying BoardToFEN() or SetBoard(). That keeps the change localized and avoids affecting normal game handling or FEN loading.

The relevant source files are available in the Beowulf repository.
mar
Posts: 3121
Joined: Fri Nov 26, 2010 2:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: Myracle GUI

Post by mar »

build 176 is up:
- added two new books from Andres, avt-fringe, and EQ2026 (in bundle zips)
- new book randomizer books (.bra, json format, sample files are stored in book_rand folder); basically this allows to play n random plies from various startpositions (including random chess324, frc and dfrc), also allowing a seed book. each entry has a priority weight
- output script, a custom simple scripting language that allows to create custom binary format from each finished game, i.e. useful
for datagen for engine programmers using selfplay
output script files can be selected per book in book settings; there is a sample script in out_script subfolder
- removed some older versions of bundled engines

note: gui_data.zip has changed too; also windows binary has hit a whopping 2.9MB now :D

I believe these are great new features especially for engine devs since writing a custom datagen might be a bit tricky;
surely it'd deserve to say a lot more about it but for now what's included should do. did my best to test, though
I expect some bugs will be found eventually
SSTATHIS
Posts: 96
Joined: Tue Jun 22, 2010 7:55 pm

Re: Myracle GUI

Post by SSTATHIS »

Hi Martin!
I want to remove the last engine from a finished tournament.
Is there any way to generate crosstable html and txt file without replay a game?

Best regards
mar
Posts: 3121
Joined: Fri Nov 26, 2010 2:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: Myracle GUI

Post by mar »

hi Stathis,

hmm, not at the moment, but the local text crosstable in tournament tab will be updated instantly

actually I think this is technically a bug, because tour is saved right after tournament edits, except that the crosstable is not regenerated immediately

I will try to fix it in the next build, however I plan one more small feature so it will take a while
SSTATHIS
Posts: 96
Joined: Tue Jun 22, 2010 7:55 pm

Re: Myracle GUI

Post by SSTATHIS »

mar wrote: ↑Wed Nov 18, 2026 10:53 pm hi Stathis,

hmm, not at the moment, but the local text crosstable in tournament tab will be updated instantly

actually I think this is technically a bug, because tour is saved right after tournament edits, except that the crosstable is not regenerated immediately

I will try to fix it in the next build, however I plan one more small feature so it will take a while
Thanks Martin!