ID:78974
 
Keywords: bgc, chess, development
Today I took a bit more of a relaxed approach and just did some light work on the presentation aspects.

Audeuro had suggested that, instead of making a piece disappear entirely when dragged around to move it, that it leave a translucent "ghost" piece behind to mark its' original location. This seemed like a pretty good idea, so a short modification to my resource preloader and I end up with something like this (again, I'm only using print screen so the piece graphic being set to the mouse pointer isn't shown):



You'll also notice that I've dropped a board border in there since yesterday, and also the rank/file marker images. I'm not sure how I'm going to allow it to be done properly on the finished product, but the "blar" verb that appeared since yesterday rotates the board 90 degrees clockwise and modifies the rank and file characters along the top and right side to match the board orientation:



The border and rank/file characters are all screen objects, since those all stay in a static location while the remainder of the map rotates with client.dir.

You'll probably also notice the new Chess Options tab which contains... well, chess game options. Presently only the "legal moves" highlight and right-click piece info options actually do anything, but the remainder isn't really that difficult.

What I'm fearing getting into again is the complexities of the king piece. Even though I did it once and have a few ideas on how to avoid some speed bumps, I'm not particularly looking forward to all the game considerations that have to be made involving the king piece. One of my least favorite areas is maintaining a record of every "threatened" tile that a king cannot occupy, which I used a second list for in the last incarnation of chess; one list of "legal movement" turfs, and a list of "king threat" turfs. Consider things like a rook one file away from a king blocking off its escape route, or an enemy queen preventing the capture of an enemy pawn. The reverse is also loads of fun, such as an enemy rook pinning a friendly bishop to the king (making the bishop unable to move due to putting themself in check). On the bright side, bitwise operations are going to make a little bit of the process easier, considering I can just take an enemy rider's (queen, bishop, rook) movement cells, all friendly pieces' legal movements, and & them together to gather which pieces can make an imposition move, which was an arduous process in the previous incarnation without that huge timesaver.

I can only hope what I've picked up since the previous incarnation of chess can help me out when I get to that point, since I'm not looking forward to the royal piece considerations in the least. ANy insights anyone has on the subject are welcome, considering the only way I know how to do it is making a secondary list of turfs for each piece containing areas they can't actually move to but would illegally cause check if the enemy moved a king there.
How about a bot to play against?
I gave this very little thought but...

- Could you maintain a list of attack locations for each piece? The queen would collect and maintain a list of all squares that she could move to including any attack location which blocks her movement in that direction.

- Could you then compare the Kings available move spots against each list of attacks?

- Remove any matches and whatever the King has left, is a valid move spot.

I think this covers the King being protected by the bishop scenario as well because attack locations are added to the list. Although, you still have to determine what to do when someone attempts to move the bishop.

ts
SuperAntx wrote:
How about a bot to play against?

I'm scared of the concept of chess AI. Not only does making one require a level of understanding of game mechanics that I don't have, I don't know how I could make it prone to error (I.E., defeatable).


Tsfreaks wrote:
I gave this very little thought but...

- Could you maintain a list of attack locations for each piece? The queen would collect and maintain a list of all squares that she could move to including any attack location which blocks her movement in that direction.

- Could you then compare the Kings available move spots against each list of attacks?

- Remove any matches and whatever the King has left, is a valid move spot.

I think this covers the King being protected by the bishop scenario as well because attack locations are added to the list. Although, you still have to determine what to do when someone attempts to move the bishop.

This is essentially the method I've already employed in the last chess version; any destination movement a piece could otherwise make that's being occupied by another piece is added to a list of "threat" movements. The king's list of movements then has the legal movements and "threat" movements of every enemy piece shaved off its' own list. This method is somewhat clunky, though, as can be seen in practice on the current chess game.
What Tsfreaks suggested is pretty much how chess works on my cellphone. It seems like it's only able to think ahead one move.
Out of interest, is there any game on Byond that displays great AI that you guys know of?

ts