Ludii Forum
Issue with (is Threatened at:X) - Printable Version

+- Ludii Forum (https://ludii.games/forums)
+-- Forum: Questions (https://ludii.games/forums/forumdisplay.php?fid=13)
+--- Forum: About the Ludii Grammar (https://ludii.games/forums/forumdisplay.php?fid=15)
+--- Thread: Issue with (is Threatened at:X) (/showthread.php?tid=402)



Issue with (is Threatened at:X) - slimy_asparagus - 01-29-2021

I got most of the way through implementing Spartan Chess. However I am finding that (is Threatened....) is not coming out correctly. I attach the .lud and a trial.

Using the Test Ludeme dialog. I would expect that that (is Threatened at:12) should return true, because the Lieutenant at 26 can capture the White King at 12. However it comes out as false as indicated by the fact that White has many more legal moves than it should. In particular Ludii is not requiring White to move the King out of danger.

The expanded code for the Lieutenant is:

Code:
            (piece "Lieutenant"
                P2
                (or
                    {
                        (move
                            Step
                            Diagonal
                            (to
                                if:(or
                                    (is Empty (to))
                                    (is Enemy (who at:(to)))
                                )
                                (apply
                                    (if
                                        (is Enemy (who at:(to)))
                                        (remove (to) (then (set Counter)))
                                    )
                                )
                            )
                        )
                        (move
                            Hop
                            Diagonal
                            (to
                                if:(or
                                    (is Enemy (who at:(to)))
                                    (is Empty (to))
                                )
                                (apply
                                    (if
                                        (is Enemy (who at:(to)))
                                        (remove (to) (then (set Counter)))
                                    )
                                )
                            )
                        )
                        (move
                            Step
                            (directions { W E })
                            (to if:(is Empty (to)))
                        )
                    }
                )
            )



RE: Issue with (is Threatened at:X) - Eric Piette - 01-29-2021

Hi,

To fix your problem you should modify your define called "IsInOmnicheck" in doing that inside

("IsInCheck" "King" #1)

That's the ludemeplex used to in all the chess like games to check if the king is threatened (just look Chess.lud)

But still we will look why you current define is not also doing the job.

Regards,
Eric


RE: Issue with (is Threatened at:X) - slimy_asparagus - 01-29-2021

(01-29-2021, 09:33 AM)Eric Piette Wrote: Hi,

To fix your problem you should modify your define called "IsInOmnicheck" in doing that inside

("IsInCheck" "King" #1)

That's the ludemeplex used to in all the chess like games to check if the king is threatened (just look Chess.lud)

But still we will look why you current define is not also doing the job.

Regards,
Eric


Eric,


That won't work because Black has two Kings. I need to be able to check that both Kings are in check (or that Black has lost one).  The only way I can do that as far as I can see is to check by site index.

I put some comments in that explained why I handled the Check code the way I did. In particular the omnicheck concept allows my to handle the Check rules uniformly. I could do what you suggest for White, but it will never work for Black.


RE: Issue with (is Threatened at:X) - Eric Piette - 01-29-2021

Hi,

Ok so in that case, I advise you to look at "Double Chess.lud" the game uses also 2 kings.

Regards,
Eric


RE: Issue with (is Threatened at:X) - slimy_asparagus - 01-29-2021

(01-29-2021, 09:42 AM)Eric Piette Wrote: Hi,

Ok so in that case, I advise you to look at "Double Chess.lud" the game uses also 2 kings.

Regards,
Eric


Eric,

I am at work so I cannot check the .lud file. However googling double chess, I suspect it is not relevant.

As I understand it in Double Chess you must not allow either of your Kings to remain in check. The current chess implementation would work fine for that. I am guessing it uses ("IsInCheck" "King" #1) as you suggest.

In Spartan chess having exactly one King in check does not limit the Black player in any way. Black is only forced when both Kings are in check. It is perfectly valid to capture a Black King, in which case the Check rules become similar except that then a hoplite (pawn equivalent) may be promoted to King.


RE: Issue with (is Threatened at:X) - Eric Piette - 01-29-2021

Hi,

Ok Dennis took a look to your original define and he fixed it.
It works now as excepted. So that will be fixed in the next release.

Regards,
Eric


RE: Issue with (is Threatened at:X) - slimy_asparagus - 02-13-2021

(01-29-2021, 12:43 PM)Eric Piette Wrote: Hi,

Ok Dennis took a look to your original define and he fixed it.
It works now as excepted. So that will be fixed in the next release.

Regards,
Eric

Eric,

I am not actually seeing any difference. I have updated my Ludii to version 1.1.14, updated the .lud file with the new version number, and manually regenerated a fresh trial file. Still when I test "(is Threatened at:12)" I get false and White has more legal moves than it should.


RE: Issue with (is Threatened at:X) - Eric Piette - 02-13-2021

Hi,

Ok that's weird but apparently a part of the code we did to fix that issue was removed.... I just re add it and now that works.
Soooo sorry for that, but that will be in the next release.

Regards,
Eric


RE: Issue with (is Threatened at:X) - slimy_asparagus - 02-13-2021

(02-13-2021, 12:43 PM)Eric Piette Wrote: Hi,

Ok that's weird but apparently a part of the code we did to fix that issue was removed.... I just re add it and now that works.
Soooo sorry for that, but that will be in the next release.

Regards,
Eric


Thanks for the update.


RE: Issue with (is Threatened at:X) - xenos1984 - 01-28-2024

Could it be that also in the current version 1.3.12 there is an issue with is Threatened? I just encountered this behavior while implementing chess on a cylinder, and at first I thought this is due to something wrong in my implementation, but it seems to be present even in regular chess. I have attached a trial.

White should be checkmate after ... Qh4, but is happily allowed to move again, and ... Qxe1 captures the king.

Could it be that also in the current version 1.3.12 there is an issue with is Threatened? I just encountered this behavior while implementing chess on a cylinder, and at first I thought this is due to something wrong in my implementation, but it seems to be present even in regular chess. I have attached a trial.

White should be checkmate after ... Qh4, but is happily allowed to move again, and ... Qxe1 captures the king.

(Sorry if this is a double post. I tried to edit my original post since the attachment was missing, but could not find a way to do so.)