Author: Roman Hartmann
Date: 06:01:47 02/03/05
Go up one level in this thread
On February 03, 2005 at 05:52:40, Roman Hartmann wrote: >On February 03, 2005 at 05:01:08, Jose Cortes wrote: > >> >>Hi, I have a little doubt about finding the best way to, given a position, >>verify if it is check, using whatever data estructure, bitboard, etc. There are >>a lot of ways to do it, most of them using loops, but what is the most >>efficient?Someone can help me? >>Thx. > >Hello, >are you writing a chess engine or rather a GUI? If you're working on a GUI >performance won't matter that much and I guess the easiest way would be to use >an 8x8 array then. Basically you need to write/use a move generator. At least if >you want to distinguish if it's check/Stalemate/mate. > >best regards >Roman That's the way I'm checking if a king (or a square) is under attack in ROCE: I put a queen on the square where the king is and check if I can take any opposite coloured rooks/queens/bishops. After that I check if I can take any opposite coloured knights with a knight from the king square. Then I check if the king (square) is attacked by pawns (needs only two offsets here and no loop at all). In more detail my attack function just scans the board (I'm using a for loop for bishops/queen/rooks and an offset table for the knights) in all directions from the king square as long as it doesn't hit any own pieces or opp. coloured pawns (which are blocking opp. pieces) or the border of the board and returns TRUE as soon it hits an opposite piece. Otherwise it returns FALSE. best Regards Roman
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.