Chess changes: en passant and not suggesting illiegal moves

Johnny Jazeix jazeix at gmail.com
Sun Jun 7 11:20:04 BST 2020


Hi,

I removed the images from your mail, created a bug on our tracker
(https://phabricator.kde.org/T13248) and added the images in it
https://phabricator.kde.org/M175.
For the en-passant move, I probably won't have the knowledge to fix it quickly.

For restraining the moves to the only "really" possible ones, it
should be possible:
https://invent.kde.org/education/gcompris/-/blob/master/src/activities/chess/chess.js#L317:
we display the possible moves.
Here is the function where we check if the move is legal or not:
https://invent.kde.org/education/gcompris/-/blob/master/src/activities/chess/chess.js#L151

I can add it in my todo list, except if you want to take a look.

Johnny

Le dim. 7 juin 2020 à 03:30, Tyson Williams <tyson.d.w at gmail.com> a écrit :
>
> Hello everyone,
>
> I decided to only take screenshots for the incorrect cases, of which there are five.
>
> The first is that en passant is not possible but should be.  See attached file "en_passant.png".
>
> The other four cases are moves that are suggested but should NOT be.  In all four cases, only the suggestions are wrong.  Trying to play at any of these "bad" suggestions displays the error message "Invalid, your king may be in check".
> 1. Suggested moves for the king should not include moving to a square that is under attack.  In the attached file "1-King_moving_into_an_attack.png", there should be no suggested moves for the king.
> 2. When in an absolute pin, there should be no move suggestions.  In the attached file "2-Stuck_in_absolute_pin.png", there should be no suggested moves for the bishop.  There are some other pin-related cases that are more complicated.
> 3&4. When in check, the only valid moves of non-king pieces are to block or capture.  In the attached file "3_Only_move_absolute_pin.png", the only suggested move should be to block the queen's attack.  In the attached file "4-Only_move_capture.png", the only suggested move should be to capture the queen.
>
> The program already knows that some of the suggestions are no good.  That is why it doesn't allow those moves and shows an error message instead.  I just want it to never show those bad suggestions in the first place.
>
> On Fri, Jun 5, 2020 at 5:35 PM Tyson Williams <tyson.d.w at gmail.com> wrote:
>>
>> Hello Johnny,
>>
>> Thanks for the links.  I will take a look at them.
>>
>> To help you and others better understand the cases, it just occurred to me that I could create and markup some screenshots.  I should be able to get those over the weekend.
>>
>>
>> On Fri, Jun 5, 2020, 2:48 PM Johnny Jazeix <jazeix at gmail.com> wrote:
>>>
>>> Hi Tyson,
>>>
>>> thank you for your explanation. We are using the engine of p4wn
>>> (https://github.com/douglasbagnall/p4wn) to power the chess activity.
>>> There were already a few bug they fixed for "en passant":
>>> https://github.com/douglasbagnall/p4wn/issues?q=is%3Aissue+is%3Aclosed
>>> but maybe that did not handle all the cases.
>>>
>>> If you have knowledge, for sure these improvements are welcome!
>>> If you can reproduce the bugs in http://p4wn.sourceforge.net/, then it
>>> would be better if this can be fixed upstream (proposing a pull
>>> request) and we'll have to report on our code
>>> (https://github.com/gcompris/GCompris-qt/blob/master/src/activities/chess/engine.js).
>>> I can help you understand the code on GCompris, but will have more
>>> difficulty to help on the engine.
>>>
>>> I'll take a closer look tomorrow to try to understand more the
>>> different use cases you are talking about.
>>>
>>> Johnny
>>>
>>> Le ven. 5 juin 2020 à 14:18, Tyson Williams <tyson.d.w at gmail.com> a écrit :
>>> >
>>> > !Hello everyone,
>>> >
>>> > My children (twin 6yos and 4yo) love playing the activities in GCompris.  In particular, one of my 6yos especially enjoys that he can been me at the flying kings variant of checkers.
>>> >
>>> > Anyway, there are two improvements that I would like to make to the chess activities.
>>> >
>>> > The first is that en passant is not a supported move.  I would like to add support for them.
>>> >
>>> > The second is about the inconsistency in which moves are displayed as possible.  After clicking on a piece, the general behavior is that the squares to which that piece can move are highlighted.  The suggested moves vary according to the situation in many cases.
>>> >
>>> > Here are five cases in which only legal moves are suggested:
>>> > - Opponent pieces in the way (e.g. if R on a1 can capture at a2, then capturing at a3 is not suggested)
>>> > - Own piece in the way (e.g. there are no suggested moves for the king as the first move of the game)
>>> > - Pawn's first vs non-first move (i.e. only when it is a pawn's first move and the two squares in front of it are empty is the suggestion given to move the pawn forward two squares)
>>> > - Pawn capture (i.e. only if an enemy piece is diagonally in front of a pawn is the suggestion given to move in that diagonal direction)
>>> > - Castling (i.e. castling the king by moving it horizontally is only suggested if it is valid...which means the king has never moved, the rook as never moved, square the king moves through is not being attached, and the square the king stops on is not being attached)
>>> >
>>> > In contrast, there is one case in which invalid moves are suggested, which is when the king of that player would become under attack (except for castling as mentioned above).  I know of four ways in which this can happen:
>>> > - Suggestions are given to move the king to a square that is under attack.
>>> > - Suggestions are given to move a piece that is absolutely pinned.
>>> > - For a piece that can put itself into an absolute pin, suggestions are given to move that piece that would not place it into an absolute pin.
>>> > - For a piece that can capture a piece attacking the king, suggests are given to move that piece that does not capture that piece or place it into an absolute pin.
>>> >
>>> > If the user clicks such an illegal suggestion, the follow message is displayed.
>>> > > "Invalid, your king may be in check"
>>> >
>>> > This message makes me think that I have missed some case....that the game can suggest a move that is illegal for some reason other than the king being under attack after the move.  However, I have been unable to find such a case.
>>> >
>>> > When my children play chess and their king becomes checked, they click the suggested moves to get out of check, but many of them are illegal and display that message to them.  I would prefer if those illegal moves were not suggested.
>>> >
>>> > Would making en passant possible and removing illegal move suggestions be welcome changes to the chess activities?
>>> >
>>> > --
>>> > Tyson Williams
>
>
>
> --
> Tyson Williams


More information about the GCompris-devel mailing list