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


Groups > comp.lang.javascript > #38798

Re: Logic conundrums in check

Newsgroups comp.lang.javascript
Date 2020-09-17 07:32 -0700
References <05dec20a-bc09-49d0-907d-b36b2387ea73o@googlegroups.com> <1pn6mflgniurf3fr5cv5ihh7vnn2ne6vlg@4ax.com>
Message-ID <d8dc371c-87fc-471c-8fef-2df517989a0bo@googlegroups.com> (permalink)
Subject Re: Logic conundrums in check
From Jonas Thörnvall <jonas.thornvall@gmail.com>

Show all headers | View raw


On Thursday, September 17, 2020 at 3:09:23 PM UTC+2, John G Harris wrote:
> 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.
> 
> 
> >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.
> 
> 
> >So to check if your king actually will become checked when you move a piece seem to be the most computing intensive part of rules?
> 
> The test for each kind of piece can be split into two parts - a quick
> No/Maybe check, then the full Yes/No check if it was Maybe. For
> example, if a rook is on a different file and a different rank to the
> king then it cannot possibly put the king in check so the answer is
> immediately No.
> 
> 
> >So all your own pieces and their possible moves multiplied by opponents all pieces and their possible moves compared with your king position, to see if King is checked?
> 
> "Multiplied" : that doesn't sound right.
> 
> 
> >Its clearly the most complex thing to program in chess so far.
> 
> Did you really think this program was going to be easy?
> 
> 
>   John

Doing afterchecks and redraws i probably easily could do, but i want my methodology more coherent. I want it to detect/show legal and not legal moves on "mark" of own piece, so i plan not just to remove that "possible tile" but instead replace it with a red/purple king tile to show that you put king in checked position by that move. 

It may be unnecessary but i think it is kind of nice.
And apparently done all the rules to start doing evaluation it will be necessary, to mark all possible moves at each level. "Can't wait for opponent to grab a piece".

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