Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #38794 > unrolled thread
| Started by | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| First post | 2020-09-17 03:25 -0700 |
| Last post | 2020-09-24 22:58 -0700 |
| Articles | 20 on this page of 26 — 7 participants |
Back to article view | Back to comp.lang.javascript
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
Page 1 of 2 [1] 2 Next page →
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2020-09-17 03:25 -0700 |
| Subject | Logic conundrums in check |
| Message-ID | <05dec20a-bc09-49d0-907d-b36b2387ea73o@googlegroups.com> |
I am a bit baffeled about the complexity of checking for check. Checking if the opponent make you check is straightforward, it is just to scan the "occupied/controled tiles" of the opponent piece just moved. 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. 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? 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? Its clearly the most complex thing to program in chess so far.
[toc] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2020-09-17 03:28 -0700 |
| Message-ID | <62756cce-ba5c-45d8-ab3d-5d1211e38dffo@googlegroups.com> |
| In reply to | #38794 |
Den torsdag 17 september 2020 kl. 12:25:52 UTC+2 skrev Jonas Thörnvall: > I am a bit baffeled about the complexity of checking for check. > Checking if the opponent make you check is straightforward, it is just to scan the "occupied/controled tiles" of the opponent piece just moved. > > 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. > > 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? > > 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? > > Its clearly the most complex thing to program in chess so far. Worst thing is to do this you actually will have to move all your own pieces, you can't do as for King move to check just check the new tile.... Opponents occupied tiles/moves already rest in an array so those no problem having to move each of your own pieces to all positions however will cause me headache.
[toc] | [prev] | [next] | [standalone]
| From | John G Harris <niam@jghnorth.org.uk.invalid> |
|---|---|
| Date | 2020-09-17 14:09 +0100 |
| Message-ID | <1pn6mflgniurf3fr5cv5ihh7vnn2ne6vlg@4ax.com> |
| In reply to | #38794 |
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
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2020-09-17 07:25 -0700 |
| Message-ID | <afac0dbe-0a29-4451-8cfd-bdd898b0c71eo@googlegroups.com> |
| In reply to | #38796 |
Den torsdag 17 september 2020 kl. 15:09:23 UTC+2 skrev John G Harris: > 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. This case already seem done it automatically detect when bishop hide queen and moved to reveal chess position. "It make me curious if it also could be used for when own pieces reveal/expose King" > > >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. Yeah that really make me wonder if it should not be done on a copy of board instead, because it can be dropped after evaluation. > >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. Yeah that would indeed break the check earlier. > > >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. I think so for every position of your own you have to check every "owned/claimed" position/tile of the opponent. > > >Its clearly the most complex thing to program in chess so far. > > Did you really think this program was going to be easy? No i kind of did knew that the ruleset of chess was alot more hairy then for other board games. But i was expecting kind of direct checks between pieces involved, not these more elaborate third party checks. > John
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2020-09-17 23:50 -0700 |
| Message-ID | <c8282c1e-f203-4550-b512-30a79e9bc895o@googlegroups.com> |
| In reply to | #38797 |
Den torsdag 17 september 2020 kl. 16:25:27 UTC+2 skrev Jonas Thörnvall: > Den torsdag 17 september 2020 kl. 15:09:23 UTC+2 skrev John G Harris: > > 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. > > This case already seem done it automatically detect when bishop hide queen and moved to reveal chess position. "It make me curious if it also could be used for when own pieces reveal/expose King" > > > > > >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. > > Yeah that really make me wonder if it should not be done on a copy of board instead, because it can be dropped after evaluation. > > > >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. > > Yeah that would indeed break the check earlier. > > > > > >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. > I think so for every position of your own you have to check every "owned/claimed" position/tile of the opponent. > > > > > >Its clearly the most complex thing to program in chess so far. > > > > Did you really think this program was going to be easy? > > No i kind of did knew that the ruleset of chess was alot more hairy then for other board games. But i was expecting kind of direct checks between pieces involved, not these more elaborate third party checks. > > > John Ok i had the night to ponder a bit, i think the smartest way is to extend the king paths. If the straight paths do meet opponent queen or rock, that move mean you become check. If the diagonal path meet bishop or queen also check. I simply do not need to scan opponent king, pawn or knight it would already mean in check "when moving own pieces". It may seem backward to use the king, instead of the attacking pieces. But i have no idea where the attacking pieces are. So my realisation is that the scan must go outward from king. Strange realisation " i should scan king paths outside his territorial tile confinement/claim", but logical when I realise that scan kings potential positions is what i have to do for king move. But also a bit comforting, the idea that i had to scan thru all to all pieces did stress me out a bit. Luck i did not start program it yesterday would been alot of work for nothing.
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2020-09-17 07:32 -0700 |
| Message-ID | <d8dc371c-87fc-471c-8fef-2df517989a0bo@googlegroups.com> |
| In reply to | #38796 |
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".
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2020-09-17 07:54 -0700 |
| Message-ID | <c9a36086-fcab-4be7-b33f-e1cd25eb5f4do@googlegroups.com> |
| In reply to | #38796 |
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 Pokin into it, it seem all the checks already there "all? checks detected" but first after you already moved piece. So it is probably about just doing the "test moves" for each piece and save results but that is hairy enough.
[toc] | [prev] | [next] | [standalone]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Date | 2020-09-17 21:19 +0100 |
| Message-ID | <87k0wsm9zr.fsf@bsb.me.uk> |
| In reply to | #38796 |
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.
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2020-09-17 13:57 -0700 |
| Message-ID | <3fdae098-328a-443f-8014-1f463ae83978o@googlegroups.com> |
| In reply to | #38800 |
On Thursday, September 17, 2020 at 10:20:02 PM UTC+2, Ben Bacarisse wrote: > 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. I beleive i take care of both those cases Ben.
[toc] | [prev] | [next] | [standalone]
| From | Arno Welzel <usenet@arnowelzel.de> |
|---|---|
| Date | 2020-09-18 12:53 +0200 |
| Message-ID | <hsjhtgF7jajU1@mid.individual.net> |
| In reply to | #38794 |
On 17.09.20 12:25, Jonas Thörnvall wrote: > I am a bit baffeled about the complexity of checking for check. > Checking if the opponent make you check is straightforward, it is > just to scan the "occupied/controled tiles" of the opponent piece > just moved. > > 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. Why? You just execute the move and then check the result. > 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 Why don't you keep track on which tile the king is? > moving my own piece to a new position. And then do the above king vs > opponenet controled tiles. > > 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? No. This is just, because your data structures seem to lack information. Every piece you move can have a current position and a future position for a proposed move which is not done yet. So you can check with the positions the current status and the status which might be if a move will really be done. > 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? No. You just need to check the current positions and the *single* piece if you want to move it. > Its clearly the most complex thing to program in chess so far. Just because you did not break down the logic yet. As I mentioned a while ago already - there is a complete(!) chess implementation in JavaScript with less than 3 KB total: <https://nanochess.org/chess4.html> A working example: <https://nanochess.org/archive/toledo_javascript_chess_3.html> Yes - this is a bit brainfuck since the code is extremely optimized. But it really works. -- Arno Welzel https://arnowelzel.de
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2020-09-18 04:48 -0700 |
| Message-ID | <f00cef81-b9be-4f67-bdb0-4b2c73924680o@googlegroups.com> |
| In reply to | #38804 |
Den fredag 18 september 2020 kl. 12:53:47 UTC+2 skrev Arno Welzel: > On 17.09.20 12:25, Jonas Thörnvall wrote: > > > I am a bit baffeled about the complexity of checking for check. > > Checking if the opponent make you check is straightforward, it is > > just to scan the "occupied/controled tiles" of the opponent piece > > just moved. > > > > 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. > > Why? You just execute the move and then check the result. > > > 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 > > Why don't you keep track on which tile the king is? Of course its position recorded, but i made tiles an array object and pieces only properties of the tiles. "Of course i could have a variable named KingPosition, Queenposition and so on" > > moving my own piece to a new position. And then do the above king vs > > opponenet controled tiles. > > > > 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? > > No. This is just, because your data structures seem to lack information. > Every piece you move can have a current position and a future position > for a proposed move which is not done yet. So you can check with the > positions the current status and the status which might be if a move > will really be done. The position is one of 64 in a tile array, until you grab piece at tile. But of course i could hold positions for pieces as variables. No the future positions is recorded for each type of move and those, incorporate reachable tiles on an empty board. > > 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? > > No. You just need to check the current positions and the *single* piece > if you want to move it. That just seem wrong Arnold, and actually is. > > Its clearly the most complex thing to program in chess so far. > > Just because you did not break down the logic yet. > > As I mentioned a while ago already - there is a complete(!) chess > implementation in JavaScript with less than 3 KB total: > > <https://nanochess.org/chess4.html> > > A working example: > > <https://nanochess.org/archive/toledo_javascript_chess_3.html> > > Yes - this is a bit brainfuck since the code is extremely optimized. But > it really works. > > > -- > Arno Welzel > https://arnowelzel.de
[toc] | [prev] | [next] | [standalone]
| From | Arno Welzel <usenet@arnowelzel.de> |
|---|---|
| Date | 2020-09-19 15:17 +0200 |
| Message-ID | <hsmenkFq3o8U1@mid.individual.net> |
| In reply to | #38806 |
Jonas Thörnvall: > Den fredag 18 september 2020 kl. 12:53:47 UTC+2 skrev Arno Welzel: >> On 17.09.20 12:25, Jonas Thörnvall wrote: [...] >>> 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 >> >> Why don't you keep track on which tile the king is? > > Of course its position recorded, but i made tiles an array object and > pieces only properties of the tiles. "Of course i could have a > variable named KingPosition, Queenposition and so on" I would have done this the other way: every tile has the position as property. As there is a maximum of 32 pieces, checking their positions to decide wether a move is possible or not or if the king is in check would not take that long - just check position of the maximum of 31 other pieces and for the "check" test the fields they can move to. BTW: You should also learn how to use a *real* newsserver with a NNTP-client instead of Google Groups. -- Arno Welzel https://arnowelzel.de
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2020-09-19 07:58 -0700 |
| Message-ID | <ec1e8bc0-a039-4af0-8494-e1e3af8fb11eo@googlegroups.com> |
| In reply to | #38808 |
Den lördag 19 september 2020 kl. 15:17:51 UTC+2 skrev Arno Welzel:
> Jonas Thörnvall:
>
> > Den fredag 18 september 2020 kl. 12:53:47 UTC+2 skrev Arno Welzel:
> >> On 17.09.20 12:25, Jonas Thörnvall wrote:
> [...]
> >>> 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
> >>
> >> Why don't you keep track on which tile the king is?
> >
> > Of course its position recorded, but i made tiles an array object and
> > pieces only properties of the tiles. "Of course i could have a
> > variable named KingPosition, Queenposition and so on"
>
> I would have done this the other way: every tile has the position as
> property. As there is a maximum of 32 pieces, checking their positions
> to decide wether a move is possible or not or if the king is in check
> would not take that long -
Well the tile and their positions is just an array from 0-63, the tilename A1 and so on it is just a property. And each tile hold either a "B" or "W" or "" piece which has a type "K","Q","B","N","R". And also a startmark for castling, that i apparently forgot to use... Tilecolor is just for the draw i guess.
tileElement.push({tileColor:"W",tileName:"H1",occupied:true,pieceColor:"W",pieceType:"R",startMark:false});
just check position of the maximum of 31
> other pieces and for the "check" test the fields they can move to.
It would seem it could save alot of time in alalysis, doing it the other way, starting from King. 8 checks instead of 31.
> BTW: You should also learn how to use a *real* newsserver with a
> NNTP-client instead of Google Groups.
I kind of like webbased applications, when they fill their purpose.
Jonas
>
> --
> Arno Welzel
> https://arnowelzel.de
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2020-09-19 08:02 -0700 |
| Message-ID | <90406ed9-116c-4b05-9a8b-fdeb6aa701e5o@googlegroups.com> |
| In reply to | #38809 |
Den lördag 19 september 2020 kl. 16:59:02 UTC+2 skrev Jonas Thörnvall:
> Den lördag 19 september 2020 kl. 15:17:51 UTC+2 skrev Arno Welzel:
> > Jonas Thörnvall:
> >
> > > Den fredag 18 september 2020 kl. 12:53:47 UTC+2 skrev Arno Welzel:
> > >> On 17.09.20 12:25, Jonas Thörnvall wrote:
> > [...]
> > >>> 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
> > >>
> > >> Why don't you keep track on which tile the king is?
> > >
> > > Of course its position recorded, but i made tiles an array object and
> > > pieces only properties of the tiles. "Of course i could have a
> > > variable named KingPosition, Queenposition and so on"
> >
> > I would have done this the other way: every tile has the position as
> > property. As there is a maximum of 32 pieces, checking their positions
> > to decide wether a move is possible or not or if the king is in check
> > would not take that long -
>
> Well the tile and their positions is just an array from 0-63, the tilename A1 and so on it is just a property. And each tile hold either a "B" or "W" or "" piece which has a type "K","Q","B","N","R". And also a startmark for castling, that i apparently forgot to use... Tilecolor is just for the draw i guess.
>
> tileElement.push({tileColor:"W",tileName:"H1",occupied:true,pieceColor:"W",pieceType:"R",startMark:false});
>
> just check position of the maximum of 31
> > other pieces and for the "check" test the fields they can move to.
> It would seem it could save alot of time in alalysis, doing it the other way, starting from King. 8 checks instead of 31.
>
> > BTW: You should also learn how to use a *real* newsserver with a
> > NNTP-client instead of Google Groups.
>
> I kind of like webbased applications, when they fill their purpose.
>
> Jonas
> >
> > --
> > Arno Welzel
> > https://arnowelzel.de
Well actually it is alot more then 31 you would have to multiply it with possible moves i think. And of course doing with King would be same 8 * "possible queen moves". King pretending to be a queen must be the way to do it LoL.
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2020-09-19 08:05 -0700 |
| Message-ID | <45e07fc5-37c3-4e18-97cc-9009b9e3a39do@googlegroups.com> |
| In reply to | #38809 |
Den lördag 19 september 2020 kl. 16:59:02 UTC+2 skrev Jonas Thörnvall:
> Den lördag 19 september 2020 kl. 15:17:51 UTC+2 skrev Arno Welzel:
> > Jonas Thörnvall:
> >
> > > Den fredag 18 september 2020 kl. 12:53:47 UTC+2 skrev Arno Welzel:
> > >> On 17.09.20 12:25, Jonas Thörnvall wrote:
> > [...]
> > >>> 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
> > >>
> > >> Why don't you keep track on which tile the king is?
> > >
> > > Of course its position recorded, but i made tiles an array object and
> > > pieces only properties of the tiles. "Of course i could have a
> > > variable named KingPosition, Queenposition and so on"
> >
> > I would have done this the other way: every tile has the position as
> > property. As there is a maximum of 32 pieces, checking their positions
> > to decide wether a move is possible or not or if the king is in check
> > would not take that long -
>
> Well the tile and their positions is just an array from 0-63, the tilename A1 and so on it is just a property. And each tile hold either a "B" or "W" or "" piece which has a type "K","Q","B","N","R". And also a startmark for castling, that i apparently forgot to use... Tilecolor is just for the draw i guess.
>
> tileElement.push({tileColor:"W",tileName:"H1",occupied:true,pieceColor:"W",pieceType:"R",startMark:false});
>
> just check position of the maximum of 31
> > other pieces and for the "check" test the fields they can move to.
> It would seem it could save alot of time in alalysis, doing it the other way, starting from King. 8 checks instead of 31.
>
> > BTW: You should also learn how to use a *real* newsserver with a
> > NNTP-client instead of Google Groups.
>
> I kind of like webbased applications, when they fill their purpose.
>
> Jonas
> >
> > --
> > Arno Welzel
> > https://arnowelzel.de
https://www.youtube.com/watch?v=9V_pgo3vgiI
[toc] | [prev] | [next] | [standalone]
| From | luserdroog <luser.droog@gmail.com> |
|---|---|
| Date | 2020-09-19 11:27 -0700 |
| Message-ID | <a0fd35fa-23da-4c00-a8b4-4409b83dd6dao@googlegroups.com> |
| In reply to | #38809 |
On Saturday, September 19, 2020 at 9:59:02 AM UTC-5, Jonas Thörnvall wrote: > Den lördag 19 september 2020 kl. 15:17:51 UTC+2 skrev Arno Welzel: > > BTW: You should also learn how to use a *real* newsserver with a > > NNTP-client instead of Google Groups. > > I kind of like webbased applications, when they fill their purpose. > I do too. NB. If you format your paragraphs with explicit newlines, you get fewer of these sort of complaints. fwiw
[toc] | [prev] | [next] | [standalone]
| From | Arno Welzel <usenet@arnowelzel.de> |
|---|---|
| Date | 2020-09-20 00:10 +0200 |
| Message-ID | <hsndujF1umdU2@mid.individual.net> |
| In reply to | #38812 |
luserdroog: > On Saturday, September 19, 2020 at 9:59:02 AM UTC-5, Jonas Thörnvall wrote: >> Den lördag 19 september 2020 kl. 15:17:51 UTC+2 skrev Arno Welzel: > >>> BTW: You should also learn how to use a *real* newsserver with a >>> NNTP-client instead of Google Groups. >> >> I kind of like webbased applications, when they fill their purpose. >> > > I do too. NB. If you format your paragraphs with explicit newlines, > you get fewer of these sort of complaints. fwiw This is something Google groups should do in their application instead of forcing people to manually do things to make text better readable. -- Arno Welzel https://arnowelzel.de
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2020-09-19 16:09 -0700 |
| Message-ID | <ea34ab82-9472-4ba4-8ad2-048619a085eco@googlegroups.com> |
| In reply to | #38814 |
Den söndag 20 september 2020 kl. 00:10:36 UTC+2 skrev Arno Welzel: > luserdroog: > > > On Saturday, September 19, 2020 at 9:59:02 AM UTC-5, Jonas Thörnvall wrote: > >> Den lördag 19 september 2020 kl. 15:17:51 UTC+2 skrev Arno Welzel: > > > >>> BTW: You should also learn how to use a *real* newsserver with a > >>> NNTP-client instead of Google Groups. > >> > >> I kind of like webbased applications, when they fill their purpose. > >> > > > > I do too. NB. If you format your paragraphs with explicit newlines, > > you get fewer of these sort of complaints. fwiw > > This is something Google groups should do in their application instead > of forcing people to manually do things to make text better readable. > > > -- > Arno Welzel > https://arnowelzel.de Yeah of course they should.
[toc] | [prev] | [next] | [standalone]
| From | luserdroog <luser.droog@gmail.com> |
|---|---|
| Date | 2020-09-19 17:07 -0700 |
| Message-ID | <514e0af0-37f6-43e3-9191-d0c2c4ce86cbo@googlegroups.com> |
| In reply to | #38814 |
On Saturday, September 19, 2020 at 5:10:36 PM UTC-5, Arno Welzel wrote: > luserdroog: > > > On Saturday, September 19, 2020 at 9:59:02 AM UTC-5, Jonas Thörnvall wrote: > >> Den lördag 19 september 2020 kl. 15:17:51 UTC+2 skrev Arno Welzel: > > > >>> BTW: You should also learn how to use a *real* newsserver with a > >>> NNTP-client instead of Google Groups. > >> > >> I kind of like webbased applications, when they fill their purpose. > >> > > > > I do too. NB. If you format your paragraphs with explicit newlines, > > you get fewer of these sort of complaints. fwiw > > This is something Google groups should do in their application instead > of forcing people to manually do things to make text better readable. > True, and I've written feedback to them about it. It might be hard for them to find the constructive parts amid all the cursing, tho.
[toc] | [prev] | [next] | [standalone]
| From | Arno Welzel <usenet@arnowelzel.de> |
|---|---|
| Date | 2020-09-20 00:08 +0200 |
| Message-ID | <hsndqmF1umdU1@mid.individual.net> |
| In reply to | #38809 |
Jonas Thörnvall: [...]>> BTW: You should also learn how to use a *real* newsserver with a >> NNTP-client instead of Google Groups. > > I kind of like webbased applications, when they fill their purpose. Well - maybe for *you*. But for anyone else using a newsreader and NNTP server this is *very* annoying > Jonas >> >> -- Arno Welzel https://arnowelzel.de This is a *signature* which is *not* meant to be quoted. A real newsreader would limit the line length and automatically cut this way at the position with the "--" followed by a space character. -- Arno Welzel https://arnowelzel.de
[toc] | [prev] | [next] | [standalone]
Page 1 of 2 [1] 2 Next page →
Back to top | Article view | comp.lang.javascript
csiph-web