02-09-2022, 12:15 PM
We wanted to make it the case that the identity of the king is updated for both players each time any player makes a move. As it is now, it is only updated for the mover after they make a move.
I though it would be as easy as parameterizing the ("UpdateKing") define, because it contains 4 occurrences of the keyword "Mover". I did this, so I could call (and ("UpdateKing" Mover) ("UpdateKing" Next)) where the old version just called ("UpdateKing"). But the result is not at all what I predicted. I also tried (do ("UpdateKing" Mover) next:("UpdateKing" Next)) and ("UpdateKing" Mover (then ("UpdateKing" Next))). Making sure to leave a parameter for the (then)-clause in the last case, of course. But I get different unexpected results.
Here is the relevant define:
I don't see any other variable whose value depends on whose turn it is, so I don't understand why it doesn't simply work. Any ideas?
I have attached the version with (and ("UpdateKing" Mover) ("UpdateKing" Next)). What happens is that, after move 3, the black piece loses the red ring.
I though it would be as easy as parameterizing the ("UpdateKing") define, because it contains 4 occurrences of the keyword "Mover". I did this, so I could call (and ("UpdateKing" Mover) ("UpdateKing" Next)) where the old version just called ("UpdateKing"). But the result is not at all what I predicted. I also tried (do ("UpdateKing" Mover) next:("UpdateKing" Next)) and ("UpdateKing" Mover (then ("UpdateKing" Next))). Making sure to leave a parameter for the (then)-clause in the last case, of course. But I get different unexpected results.
Here is the relevant define:
Code:
(define "UpdateKing"
(if
(= 1
(count Sites
in:(forEach
(sites Occupied by:#1)
if:(=
(size Stack at:(site))
(max
(results
from:(sites Occupied by:#1)
to:0
(size Stack at:(from))
)
)
)
)
)
)
(forEach Piece
(if
(=
(size Stack at:(from))
(max
(results
from:(sites Occupied by:#1)
to:0
(size Stack at:(from))
)
)
)
(set State at:(from) 1)
(set State at:(from) 0)
)
#1
top:True
)
//#2 //with the use of (then)
)
)
I have attached the version with (and ("UpdateKing" Mover) ("UpdateKing" Next)). What happens is that, after move 3, the black piece loses the red ring.