Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #38800

Re: Logic conundrums in check

From Ben Bacarisse <ben.usenet@bsb.me.uk>
Newsgroups comp.lang.javascript
Subject Re: Logic conundrums in check
Date 2020-09-17 21:19 +0100
Organization A noiseless patient Spider
Message-ID <87k0wsm9zr.fsf@bsb.me.uk> (permalink)
References <05dec20a-bc09-49d0-907d-b36b2387ea73o@googlegroups.com> <1pn6mflgniurf3fr5cv5ihh7vnn2ne6vlg@4ax.com>

Show all headers | View raw


John G Harris <niam@jghnorth.org.uk.invalid> writes:

> On Thu, 17 Sep 2020 03:25:44 -0700 (PDT), Jonas Thörnvall
> <jonas.thornvall@gmail.com> wrote:
>
>>I am a bit baffeled about the complexity of checking for check.
>
> Didn't you write down all the cases before you started coding? Looks
> like you didn't.>
>
>>Checking if the opponent make you check is straightforward, it is just
>>to scan the "occupied/controled tiles" of the opponent piece just
>>moved.
>
> It's worse than that. For example, he moves a knight and this now
> causes your king to be in check from his queen.

And a promoted pawn can put you in check.

>>Similar to check if the king move into an opponent
>>"occupied/controled" tile you just do two loops first scan thru kings
>>possible "normal moves" and the other loop compare possible kingtiles
>>with the opponents "occupied/controlled" tiles.
>>
>>But knowing if you move one of your own pieces to cause your own king
>>to be checked seem to be a complete different animal.
>>
>>First you have to find your kings position "tile" i don't keep track
>>of it.  Then it seem i actually have to make a "test move" actually
>>moving my own piece to a new position. And then do the above king vs
>>opponenet controled tiles.
>
> If the "test move" puts the king in check then it is an illegal move.
> You then have to undo the move and replace any piece that it captured.

And that can include castling "through" check.  Such a move is not
allowed, despite the king not ending up in check.

-- 
Ben.

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Logic conundrums in check Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-09-17 03:25 -0700
  Re: Logic conundrums in check Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-09-17 03:28 -0700
  Re: Logic conundrums in check John G Harris <niam@jghnorth.org.uk.invalid> - 2020-09-17 14:09 +0100
    Re: Logic conundrums in check Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-09-17 07:25 -0700
      Re: Logic conundrums in check Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-09-17 23:50 -0700
    Re: Logic conundrums in check Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-09-17 07:32 -0700
    Re: Logic conundrums in check Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-09-17 07:54 -0700
    Re: Logic conundrums in check Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-09-17 21:19 +0100
      Re: Logic conundrums in check Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-09-17 13:57 -0700
  Re: Logic conundrums in check Arno Welzel <usenet@arnowelzel.de> - 2020-09-18 12:53 +0200
    Re: Logic conundrums in check Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-09-18 04:48 -0700
      Re: Logic conundrums in check Arno Welzel <usenet@arnowelzel.de> - 2020-09-19 15:17 +0200
        Re: Logic conundrums in check Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-09-19 07:58 -0700
          Re: Logic conundrums in check Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-09-19 08:02 -0700
          Re: Logic conundrums in check Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-09-19 08:05 -0700
          Re: Logic conundrums in check luserdroog <luser.droog@gmail.com> - 2020-09-19 11:27 -0700
            Re: Logic conundrums in check Arno Welzel <usenet@arnowelzel.de> - 2020-09-20 00:10 +0200
              Re: Logic conundrums in check Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-09-19 16:09 -0700
              Re: Logic conundrums in check luserdroog <luser.droog@gmail.com> - 2020-09-19 17:07 -0700
          Re: Logic conundrums in check Arno Welzel <usenet@arnowelzel.de> - 2020-09-20 00:08 +0200
  Re: Logic conundrums in check Scott Sauyet <scott@sauyet.com> - 2020-09-22 09:55 -0700
    Re: Logic conundrums in check Scott Sauyet <scott@sauyet.com> - 2020-09-22 10:01 -0700
      Re: Logic conundrums in check Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-09-23 02:26 -0700
        Re: Logic conundrums in check Scott Sauyet <scott.sauyet@gmail.com> - 2020-09-24 19:41 -0700
          Re: Logic conundrums in check Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-09-24 22:45 -0700
          Re: Logic conundrums in check Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-09-24 22:58 -0700

csiph-web