Search the Community
Showing results for tags 'grid overlay'.
I want to do a chess program that record the move and make sure no check was forgotten (it recently happened and we had to restart the game ). I think ECMAScript would be a good option. Each pieces would be assigned its color and type and when moved verify if an attack pattern arrived to the opposite color king. Instead of making function for all of this, I wonder if there would be some grid library or perhaps simply bitmaps that could do the trick.There would be a group A with 3 grids, past pieces positions for each color and new positions, right away the display would show the new positions; then there would group B with the grids for each move, like + for rook and × for bishop.Then the grid for the new move would be put on top of its opposing color past positions then going from its center would check if it reaches/touches something, either the border or a non-king piece and if so stop verifying further that path ; but if the king is reached, right away it the display would highlight the king and stop the verification process. Along with the missed check eye-candy/visuals, there would an alert asking to revert the previous move, and if yes the corresponding grids would be replaced then the highlight dropped.So... do I need to do all of this programmatically, or are there grid function with verification from its center? By programmatically I mean for knight go from new move position 2 positions up then right, is it outside the board limits then is it a king then 2 positions left, etc. By grid function I mean for the same move to be fed for knight possible attacks along with the new position of the knight along the grid of the opposite positions along with a filter options so it only consider kings (although there should only be 1), so it will start from the "x" and check for what's under all the "O"s ; implying its placed over the filtered kings from the opposite positions. Although for the sliding pieces after finding a king, the non-king would then be replaced to see if there was another piece (non-king) between it (king) and the center ("x"). One can also think of those punch-cards test verifiers or teachers use to assign score on an exam. Although in this case its more like students had to use a different color for a single answer and the verifier was--mainly--looking for that color ; I was going to put only instead of mainly but although only would be the case of pieces that doesn't slide from its center, like pawns & knights, for pieces that slide, like queens & rooks, the sliding would stop as soon as a non-king piece would be reached (and the board limit of course) ; so even if the different color (king) was in the punched-through overlay (piece attacks for the moved piece), if the regular color (non-king) was between it and the overlay center, the search wouldn't be successful, actually it could save processing by returning a fail right away (instead of continuing the search).I hope I'm being clear but please let me know which section need clarification (please be precise) and I'll be glad to oblige. Please consider the title. :)Thank you kindly for your help