Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chu Shogi counter-strike not being invoked when a Lion is locust-captured and the final destination is not a Lion square #830

Closed
amdewitt opened this issue May 25, 2024 · 9 comments
Labels
bug Something isn't working

Comments

@amdewitt
Copy link

amdewitt commented May 25, 2024

Explanation - This is due to the code not preserving the counter-strike square after the second Lion move if it moves the moving piece to another square that is not a Lion square.

To fix, simply add a block of code that preserves the counter-strike square even if the victim on the second square is not a Lion.

Your best bet for reproduction is https://lishogi.org/analysis/chushogi

This is an implementaton bug, which can be seen at the Chu Shogi Analysis board or when playing Chu Shogi on Lishogi.

Steps to reproduce the bug
I. I have prepared an example position with the help of Github user maconard. Put the following FEN Code in the Chu Shogi Analysis Board:

lfcsgekgscfl/a1b1txot1b1a/mvrhdqn1hrvm/ppppp+Dp1pppp/3i3pi3/12/12/3IP3I3/PPPP1P+dPPPPP/MVRH1NQDHRVM/A1B1TOXT1B1A/LFCSGKEGSCFL b - 9

II. Capture White's Lion with Black's Soaring Eagle, then move the just-moved Eagle to another square (the bug will not occur if it stops on the spot)
III. Select White's Eagle or Queen on rank i. You should see that a capture of Black's Lion is possible even though a Lion was just captured on the last turn.

More explicitly, from position: lfcsgekgscfl/a1b1txot1b1a/mvrhdqn1hrvm/ppppp+Dp1pppp/3i3pi3/12/12/3IP3I3/PPPP1P+dPPPPP/MVRH1NQDHRVM/A1B1TOXT1B1A/LFCSGKEGSCFL b - 9

After taking the opponent's lion with 7d6c (non-double move), Lion counterstrike on the next turn is prevented

Expected Outcome - After taking the opponent's lion with 7d6c7d (igui double move) or 7d6c5b (hit and run double move), Lion counterstrike on the next turn is not allowed

What happened instead? - After taking the opponent's lion with 7d6c7d (igui double move) or 7d6c5b (hit and run double move), Lion counterstrike on the next turn is allowed

However, none of these three captures should be permitted.

Note that if the second part of a Lion move captures two Lions simultaneously, the bug does not occur. For example in this position if a Horned Falcon captures two Lions at once the bug does not occur:

lfcsgekgscfl/a1b1tx1t1b1a/mvr1dqndhrvm/pppp1p+oppppp/4p1+H1i3/12/12/3I1+h1P4/PPPPP+OP1PPPP/MVRHDNQD1RVM/A1B1T1XT1B1A/LFCSGKEGSCFL b - 2

Note: I asked H. G. Muller (Author of HaChu) via the CVP Comments what he thought since he was an authority on the subject I could reach out to personally. He said that the general consensus among players, the historical sources, and all the authorities on the subject, including the Chu Shogi Renmei, is that the term "non-Lion" means a piece type, not a move type. This means that in the situation given above, the counter-strike rule should be invoked regardless of where Black's Eagle ends up.

Operating system and browser version: Any that supports Chu Shogi

Soaring Eagle Counter-Strike

Soaring Eagle Counter-Strike-2

@amdewitt amdewitt added the bug Something isn't working label May 25, 2024
@daxx00
Copy link

daxx00 commented May 25, 2024

I was able to duplicate the implementation error. After a lion is captured in the first step of a double-move by a falcon or eagle, lishogi currently allows immediate capture of a lion (by a non-lion) in return, which should not happen. I tested multiple non-lion piece types, and all were able to complete the erroneous capture.

@maconard
Copy link

maconard commented May 25, 2024

More explicitly, from position: lfcsgekgscfl/a1b1txot1b1a/mvrhdqn1hrvm/ppppp+Dp1pppp/3i3pi3/12/12/3IP3I3/PPPP1P+dPPPPP/MVRH1NQDHRVM/A1B1TOXT1B1A/LFCSGKEGSCFL b - 9

  • After taking the opponent's lion with 7d6c (non-double move), Lion counterstrike on the next turn is prevented
  • After taking the opponent's lion with 7d6c7d (igui double move) or 7d6c5b (hit and run double move), Lion counterstrike on the next turn is allowed

However, none of these three captures should be permitted.

@amdewitt
Copy link
Author

Note that if you capture two lions at once, the bug will not occur. I have added screenshots and the appropriate FEN for this.

@maconard
Copy link

Pull request to fix this issue submitted here: WandererXII/shogiops#8

@amdewitt amdewitt changed the title Chu Shogi counter-strike not being invoked when a Lion is locust captured by a Falcon or Eagle (RESOLVED) Chu Shogi counter-strike not being invoked when a Lion is locust captured by a Falcon or Eagle May 28, 2024
@amdewitt amdewitt changed the title (RESOLVED) Chu Shogi counter-strike not being invoked when a Lion is locust captured by a Falcon or Eagle (PARTIALLY RESOLVED) Chu Shogi counter-strike not being invoked when a Lion is just captured May 28, 2024
@amdewitt amdewitt changed the title (PARTIALLY RESOLVED) Chu Shogi counter-strike not being invoked when a Lion is just captured Chu Shogi counter-strike not being invoked when a Lion is just captured May 29, 2024
WandererXII added a commit to WandererXII/scalashogi that referenced this issue May 29, 2024
@amdewitt amdewitt changed the title Chu Shogi counter-strike not being invoked when a Lion is just captured Chu Shogi counter-strike not being invoked when a Lion is locust-captured and the final destination is not a Lion square May 29, 2024
@WandererXII
Copy link
Owner

Applying the fix would mean the games where the illegal move occurred will get cut off at that move, this will affect old games and also currently played ones. Is this something I should try to remedy?

@daxx00
Copy link

daxx00 commented Jun 1, 2024

Applying the fix would mean the games where the illegal move occurred will get cut off at that move, this will affect old games and also currently played ones. Is this something I should try to remedy?

It's highly unlikely even a single game will be affected. The odds someone managed to promote a falcon/eagle, (in all likelihood) captured a piece next to a lion with it where the double-step threat would be applicable, the opponent not knowing the lion rules and in a position to counterattack the lion (and doing so instead of just taking the falcon/eagle)... It'll be fine.

@amdewitt
Copy link
Author

amdewitt commented Jun 4, 2024

I concur with daxx00.

@WandererXII
Copy link
Owner

Thank you for the detailed bug report, the fix is live now. If you find any other bug, please let me know!

@amdewitt
Copy link
Author

amdewitt commented Jul 3, 2024

I did find a bug involving the counter-strike rule not being invoked on the second part of a multi-move. I have posted a separate issue to explain, which is Issue #846.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants