Looks like I'm stumped ... I've tried a number of methods to work out if the King is in check, but can't nail it down and I've ended up with a bunch of messy code that only half works. I'm half tempted to just leave it up to the players to use the honour system and work it out themselves.
Does anybody have any ideas?