Check out Grant Acedrex, our featured variant for April, 2024.


[ Help | Earliest Comments | Latest Comments ]
[ List All Subjects of Discussion | Create New Subject of Discussion ]
[ List Earliest Comments Only For Pages | Games | Rated Pages | Rated Games | Subjects of Discussion ]

Single Comment

PawnX: new modest vatiant[Subject Thread] [Add Response]
Matteo Perlini wrote on Tue, Dec 4, 2012 08:40 PM UTC:
Mats, thanks. This solves part of the problem. The whole solution is this one:

(define shift1-check (
(set-flag found false)
START
(while (and (on-board? next) (not-flag? found))
(if (and (piece? King) friend?) (verify attacked?) (set-flag found true))
next
) (verify (flag? found))
back
$1
(verify not-friend?)
(set-flag found? false)
add
))

But, the problem is the huge computational complexity of this implementation. It takes some seconds just to calculate the movable pieces. So this solution is not a practical one.

I have tried to implement a solution with a dummy piece that check whether there is an attacked king, if so move a dummy piece. But it seems I don't know some basic concepts.

At the end of each players' moves, I want the dummy player do that:
- clear the position "king-check"
- scan all the boar
- if the king is attacked, then create a marker in position "king-check"

This is what I have implemented:

(define checking
(
cascade
(capture king-check)
add
(set-flag found false)
START
(while (and (on-board? next) (not-flag? found))
(if (and (piece? King) friend?) (verify attacked?) (set-flag found true))
next
)
(verify (flag? found))
back
(create Marker king-check)
)
)


Unlucky this solution doesn't work. Any ideas? :-)