Need to define a castling-prevention ... Log Out | Topics | Search
Moderators | Register | Edit Profile

Zillions of Games Discussion Forum » Designing Games for Zillions » Need to define a castling-prevention conditon « Previous Next »

Author Message
Harry Harris (Harry)
Posted on Thursday, July 29, 2004 - 5:41 am:   

I'd be grateful for any help with this.

I need to define a castling-prevention condition that's different from the corresponding one in standard chess.

In standard chess, castling is prevented if the intermediate square (the one the King would slide across if it castled) is attacked.

In my variant, I need castling to be prevented if the King would be in check if, instead of castling, it moved to the intermediate square.

This is a different condition, because in the game I'm writing, the King on its starting square can (depending on another condition) block an attack on the intermediate square coming from a certain kind of direction - and this block is removed if the King either moves to the intermediate square or castles.

In other words, when castling is being considered, it can happen that the intermediate square is not under attack now, but the King would nonetheless be putting itself into check if it actually moved there - which is a castling-prevention condition.

What's the best way of implementing this?

Can I move the King to the intermediate square somehow, test for whether it's in check, and if so, move it back again (do a reverse add?) and prevent castling? If so, how is this done?

Or remove the King from the board and test for attacks on the intermediate square from a certain direction?

Or???

Many thanks!

Harry
Harry Harris (Harry)
Posted on Friday, July 30, 2004 - 6:47 am:   

Still trying to figure this one out.

There would be a solution if I could verify that another square wasn't attacked from a certain direction and with a certain move-type. Can't find a way to verify not-attacked from a specified direction though! :(

Harry
Harry Harris (Harry)
Posted on Monday, August 09, 2004 - 6:58 pm:   

???
Sean Duggan (Dream)
Posted on Monday, August 09, 2004 - 9:52 pm:   

There is no actual checking for check in the language, so you'd have to define how to detect checkmate. Heck, or for that matter in your second post, figure out a condition for not being attacked from that certain direction. For instance, if you're checking exclusively for attacks from the NE with standard chess pieces:
(define VerifyPawnKingNE (set-flag isAttacked (or (piece? NE King) (piece? NE Pawn))))

(VerifyBishopQueenNE)
(VerifyPawnKingNE)
(VerifyKnightNE)

Checking for check is more difficult as there are more scenarios. Honestly, your question is very hard to answer without knowing more details of how your game works.

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: