Command: get the current position of ... Log Out | Topics | Search
Moderators | Register | Edit Profile

Zillions of Games Discussion Forum » Desired Features for Zillions of Games » Command: get the current position of the King « Previous Next »

Author Message
Shigeki Watanabe (Watanabe)
New member
Username: Watanabe

Post Number: 10
Registered: 3-2018
Posted on Friday, March 16, 2018 - 5:22 am:   

I would like Zillion to implement a command that gets/refers to the current position of own or enemy King.
If there is this command, by going to the King's position, I can determine whether the the King is currently attacked, within a moving block of another piece.
Malcolm James Webb (Mjw)
New member
Username: Mjw

Post Number: 32
Registered: 5-2008
Posted on Saturday, March 24, 2018 - 6:21 am:   

Zillions was created many years ago, and I don't think they're going to upgrade it very soon.

To find your King (in standard Western chess):
STEP ONE:
In the Board Definitions part of your file include the link "next" which links all the squares thus:

(links next ; loops through board positions
(a1 a2) (a2 a3) (a3 a4) (a4 a5) (a5 a6) (a6 a7) (a7 a8) (a8 b1)
(b1 b2) (b2 b3) (b3 b4) (b4 b5) (b5 b6) (b6 b7) (b7 b8) (b8 c1)
(c1 c2) (c2 c3) (c3 c4) (c4 c5) (c5 c6) (c6 c7) (c7 c8) (c8 d1)
(d1 d2) (d2 d3) (d3 d4) (d4 d5) (d5 d6) (d6 d7) (d7 d8) (d8 e1)
(e1 e2) (e2 e3) (e3 e4) (e4 e5) (e5 e6) (e6 e7) (e7 e8) (e8 f1)
(f1 f2) (f2 f3) (f3 f4) (f4 f5) (f5 f6) (f6 f7) (f7 f8) (f8 g1)
(g1 g2) (g2 g3) (g3 g4) (g4 g5) (g5 g6) (g6 g7) (g7 g8) (g8 h1)
(h1 h2) (h2 h3) (h3 h4) (h4 h5) (h5 h6) (h6 h7) (h7 h8) (h8 END))
{END can be a dummy position}

STEP 2:
In the move logic locate your King thus:

a1 (while (and (not-position? END) (or (not-piece? King) enemy?)) next) ;locate own King

STEP 3:
Check whether this position is attacked
(set-flag in-check attacked?)

STEP 4:
Return to the piece you are moving:
back

Then continue with the move logic. The flag in-check has been set as true or false depending on whether you are in check. Test it by

(if (flag? in-check) {instruction-if-you-are-in-check} else {instruction-if-you-are-not-in-check})
Shigeki Watanabe (Watanabe)
New member
Username: Watanabe

Post Number: 12
Registered: 3-2018
Posted on Tuesday, March 27, 2018 - 4:22 pm:   

Thank you for telling me the solution.
I understood the way you taught me.
It is a method to explore all squares on the board continuously as a sequential link.
It was very helpful!!

Add Your Message Here
Post:
Username: Posting Information:
This is a private posting area. Only registered users and moderators may post messages here.
Password:
Options: Enable HTML code in message
Automatically activate URLs in message
Action: