Drag and Drop Chess

I've played chess on and off for about 40 yrs. I'm pretty sure there's no triple check you'll be glad to hear.

But you're gonna hate me. "Check" out this attachment.

Chris

p.s. bedtime in the northern hem. so I won't trouble you again tonight :)
 

Attachments

A new version, Version 3.8 2011-01-25, has been uploaded in post #1 in this thread.

Hopefully fixed the double check after promotion, if nothing else it trashed 64 lines of code. :)

Edit:
As a test of the promotional double check I’ve uploaded your game.
Black should only be allowed to move the King to one of three squares, E6, E1 and F6.

Regards,
Chris.
 

Attachments

Last edited:
Knight can't move to g2

See attached. I can't seem to play Knight g2-f3 for white's second move. Knight g2-h3 is fine though. Maybe white thinks he's in check by his own knight?
 

Attachments

Capture into check

Here's one where the king is in check and is able to get out of check by capturing a piece and still be in check.
 

Attachments

A new version, Version 3.9 2011-01-25, has been uploaded in post #1 in this thread.

I think it fixes the Knight problem but the King capturing and moving into check seems to be another ‘Z’ order problem.

They’re not so easy to track down so leave it with me.

For anyone interested, a ‘Z’ order problem arises when two pieces are on the same square. That situation arises because we are dropping one piece on top of another, maybe. When code interrogates a square name, and tries to return the piece on the square, it can return none, one or one of two piece names. Depending on the piece name returned different actions need to be taken.

Thinking out loud here but what I think I really need to write is a GetPiecesFromSquare(XX) function which returns an array of pieces, 0, 1 or 2.
But, with luck, tomorrow is another day.

Thanks again for the testing, Chris.

Regards,
Chris.
 
A new version, Version 4.0 2011-01-26, has been uploaded in post #1 in this thread.

The game logic seems correct.

There is still a display problem when stepping or auto running a game under very specific conditions, it works okay playing manually.
When a piece which is promoted places the King in check it is highlighted.
If a piece blocks that check the check it is un-highlighted.
If the promoted piece takes the blocking piece the check remains un-highlighted.
The King is still in check and the logic seems to work okay however the display is incorrect.
See Rocky v Bullwinkle.

I’ll fix the display but I think the game logic is correct.

Regards,
Chris.
 
Pawn check

When a pawn checks the king, the pawn cannot be captured by any piece except the king (attached).
 

Attachments

Yep, and it’s still a ‘Z’ order problem.

There are times it can be done, not in the game you uploaded, but it depends on which piece is on top.
It can also interfere with how a game replay is displayed for a check.

Leave it with me, I’m going in circles but will have another look at it in the morning.

Thanks again,
Chris.
 
A new version, Version 4.1 2011-01-26, has been uploaded in post #1 in this thread.

I’ve loaded all test games and they seem to be working okay, even the replays.

Getting tired, going to bed or just vegetate for awhile and have a drink.

Thanks again for all the testing, Chris.

Regards,
Chris.
 
I can't find any more problems. Well done, you can break out the champagne.

Next challenge... testing for checkmate!

Chris
 
Thank you, Chris, it was a bit of a slog and it couldn’t have been done without your help in testing it.
I wonder how many people really understand how long it takes to write and test these things.
In any case I really do appreciate the time you have put into this so thanks again.

There is still a little bit of work for me in cleaning up and trying to make it easier to use. Silly little things like defaulting the directory to ‘My Documents’. It seems like Outlook will automatically save to that directory so I guess it should be the default. There are other things as well but they are minor.


The checkmate will have to wait, if ever done at all. It sounds too complicated and would only slow the game down. And maybe a checkmate would not happen, a player could resign. Perhaps a manually induced 90 deg. rotation of the King is in order?
(Shouldn’t be too hard to do that via the shortcut menu?)

So, in the next few days I’ll tidy it up a bit and perhaps put it in the sample database forum.

And indeed, the champagne is flowing. :D

Cheers, thanks again and regards,
Chris.
 
And thank you John. It was remiss of me not to mention you were the first to post the results of your testing.
That’s how these things get done, somebody writes and somebody tests.

Thanks again and regards,
Chris.
 
It's been an interesting project to follow, and to have been involved in, if only indirectly :) I'll look forward to future tweaks and developments :D
 
A new version, Version 4.2 2011-01-30, has been uploaded in post #1 in this thread.

The main addition to this version was to add the ability to resign.
(Available at the top of the right click shortcut menu.)

Regards,
Chris.
 
Hi Chris, I'm not sure if it's me but there seems to be a problem with check.

I have the black king under attack from a knight at d6, the king and all pieces in his surrounding square have not been moved. I am not permitted to remove the knight using the pawn at e6, this would remove the threat to the king and not open him to an alternate immediate threat. I was not allowed to resign there seemed to an error, that could well have been me fiddling around :o
 

Attachments

The short cut menu to allow export of the game produces a Run Time error 76 path not found. An attempt to resign produces the error (screen shot) in my previous post, which then causes a Run time 91 error.
 
Have just recreated the error with the black king under threat from a knight at f6. I'm unable to use either of the pawns at e7 or g7, or the black knight at g8 to counter this threat. Black has at this point only moved the pawn that originated from b7. Resignation was allowed this time, perhaps I managed to get something out of whack in my previous game.
 
Seems to the error is specific to a threat from the white knight, will see if I can replicate it with the black knight.
 

Attachments

The error would appear to be specific to an attack from the white knight only. A similar threat from the black knight can be suppressed.
 

Users who are viewing this thread

Back
Top Bottom