the wrong bishop – the ever buggy code

In some positions a extra bsihop is worth nothing if it has the wrong color. I already wrote about that fact:

The method is simple, maybe…for a human…
Chess knowledge …. simple for a human

And I thought Atomysticas detection algorithm works, but it did not.

The following position Atomystica detected as a draw

Schwarz am Zug
Black to move

Atomystica calculated the move order 16…Rf2 17. Rxf2 h5 18. Nxc7 Bxc3 and a draw because of the wrong Bishop rule. All the black pawns are indeed on the “right” color, but White can create a unstoppable passed pawn. And so it happened

Weiß am Zug
White to move

White moved 19. Bd6 and Atomystica suddenly recognized the problem, but it was to late.

The problem, if you put the a-pawn onto the e-file the position is really a draw.

Weiß am Zug
White to move

Here White can not create a passed pawn.

2 thoughts on “the wrong bishop – the ever buggy code

  1. Perhaps if Atomystica were open source, bugs would get fixed faster. I’d like to understand how your draw detection rule functions so I can implement something similar in my engines!

    1. Sorry, if you try to read the code you surely get eye cancer 😉 The code is not clean and often bad style,. The “wrong bishop” draw detection is about 300 lines long. Most of it checks if there are potential passers on the board. And if they can be forced to become a true passed pawn or if the weak side can exchange them.
      The rest of the code analyzes the positions of the kings looking for possible checks. It is nothing special.I think the heart of the detection is the passed pawn check.


      function TAtomica_Brett.rekurs_kann_freibauer_werden(StrongC, WeakC : TFarbe; Pawn:Integer; Bauernstruktur: TBauernstruktur):boolean;
      var rueckgabe : Boolean;
      i , helper, defender : Integer;
      begin
      i := Pawn-1;
      defender := 0;
      helper := 0;
      rueckgabe := false;
      while (i > 0) AND ((Bauernstruktur.Bauernrowlist[StrongC,i] > 0) OR (Bauernstruktur.Bauernrowlist[WeakC,i] > 0)) do
      begin
      if (Bauernstruktur.Bauernrowlist[StrongC,i] > 0) then
      inc(helper);
      if (Bauernstruktur.Bauernrowlist[WeakC,i] > 0) then
      inc(defender);
      dec(i);
      end;
      i := Pawn+1;
      while (i < 9) AND ((Bauernstruktur.Bauernrowlist[StrongC,i] > 0) OR (Bauernstruktur.Bauernrowlist[WeakC,i] > 0)) do
      begin
      if (Bauernstruktur.Bauernrowlist[StrongC,i] > 0) then
      inc(helper);
      if (Bauernstruktur.Bauernrowlist[WeakC,i] > 0) then
      inc(defender);
      inc(i);
      end;
      if defender <= helper then rueckgabe := true; result := rueckgabe; end;

Leave a Reply

Your email address will not be published. Required fields are marked *