Page 1 of 1

JavaScript Peace-Chess engine

Posted: Wed Sep 27, 2017 10:48 pm
by hgm
I wrote a simple engine written in JavaScript, powering a demo page for Paco Shako ('Peace Chess'). It is intended to give Chess players who have never seen this game before an impression of how it is played.

I posted the page at http://hgm.nubati.net/paco .

Feedback is welcome!

Re: JavaScript Piece-Chess engine

Posted: Wed Sep 27, 2017 11:11 pm
by cdani
Nice!
A presentation bug after e4 Nf6 e5 d5 ef6 e5:

Image

Re: JavaScript Piece-Chess engine

Posted: Wed Sep 27, 2017 11:22 pm
by Sven
hgm wrote:I wrote a simple engine written in JavaScript, powering a demo page for Paco Shako ('Piece Chess'). It is intended to give Chess players who have never seen this game before an impression of how it is played.

I posted the page at http://hgm.nubati.net/paco .

Feedback is welcome!
Wasn't the name of this game "Peace Chess"?

But anyway: thanks for the engine! I lost all games against it so far, as expected.

Re: JavaScript Piece-Chess engine

Posted: Wed Sep 27, 2017 11:33 pm
by MonteCarlo
I find this variant rather intriguing.

Tactics are pretty interesting. I've managed 1/3 so far, but I've spent a lot more time than the engine has :)

For now it doesn't seem like the game actually ends when you form a union with the king (i.e., you get to keep making moves even though the game is done); is that known/expected?

I haven't been able to reproduce these next reliably yet, but the very first game I played it was letting me move a pawn backwards after a union on the 6th or 7th rank.

I've also had it where it gives me the option to move non-unioned opposing pieces; in those cases the engine stopped moving altogether and let me make unlimited moves with its pieces:

https://ibb.co/b8ua8k
https://ibb.co/dX6Nok

Thanks for the engine! I had tried the puzzles at the pacosaco site and was curious for some more exercises, so this scratches that itch nicely :)

Re: JavaScript Piece-Chess engine

Posted: Thu Sep 28, 2017 12:02 am
by hgm
Sven wrote:Wasn't the name of this game "Peace Chess"?
Oops! :oops: I corrected that now, thx.

Re: JavaScript Piece-Chess engine

Posted: Thu Sep 28, 2017 12:25 am
by hgm
MonteCarlo wrote:For now it doesn't seem like the game actually ends when you form a union with the king (i.e., you get to keep making moves even though the game is done); is that known/expected?
Well, if you hug the King of the color the computer is playing, it should prirint "XXX wins" above the board. If the computer hugs your king, it would only report it when you make another move. I guess I should test for the mate score, and already print the message then. (But I was not yet completely sure the score would always be correct.)
I haven't been able to reproduce these next reliably yet, but the very first game I played it was letting me move a pawn backwards after a union on the 6th or 7th rank.
This was probably a very temporary thing, because I was messing with the GUI script. When I first opened this thread, the GUI did not generate move highlights for the unions at all, and I though I could still quickly slip that in. But I made an error in the side-to-move detection, which took me a few minutes to correct.
I've also had it where it gives me the option to move non-unioned opposing pieces; in those cases the engine stopped moving altogether and let me make unlimited moves with its pieces:
The GUI allows you to cheat without limit. It does not enforce pseudo-legality of the moves, and not even turn order. It was derived from a fairy-diagram generator that was always in setup mode. So it had no concept of a turn, which was also useful for games that allowed double moves.

But that made it somewhat difficult to know the the engine should move. I used the rule that a move with a piece of one color would imply the other color would then be on move. If the move did not release anything. But when a union is moved, you don't know to which side it belongs. So in that case, I just toggle the side.

So if the computer is set to play black, and you move a black piece, it thinks it is now white's turn, and so it would not move. It should oly move in reply to moving of white pieces or unions when it plays black.

Perhaps I should enforce turn order and pseudo-legality. But then you canot easily set up problems. And if there is a setup mode, people could switch to it to cheat. So I figured: "why just not leave it in setup mode all the time?". :?

Re: JavaScript Piece-Chess engine

Posted: Thu Sep 28, 2017 12:51 am
by cdani
cdani wrote:Nice!
A presentation bug after e4 Nf6 e5 d5 ef6 e5:

Image
I confused the name. Now I understood :-)

Re: JavaScript Piece-Chess engine

Posted: Thu Sep 28, 2017 2:38 am
by MonteCarlo
hgm wrote:
MonteCarlo wrote:For now it doesn't seem like the game actually ends when you form a union with the king (i.e., you get to keep making moves even though the game is done); is that known/expected?
Well, if you hug the King of the color the computer is playing, it should prirint "XXX wins" above the board. If the computer hugs your king, it would only report it when you make another move. I guess I should test for the mate score, and already print the message then. (But I was not yet completely sure the score would always be correct.)
I haven't been able to reproduce these next reliably yet, but the very first game I played it was letting me move a pawn backwards after a union on the 6th or 7th rank.
This was probably a very temporary thing, because I was messing with the GUI script. When I first opened this thread, the GUI did not generate move highlights for the unions at all, and I though I could still quickly slip that in. But I made an error in the side-to-move detection, which took me a few minutes to correct.
I've also had it where it gives me the option to move non-unioned opposing pieces; in those cases the engine stopped moving altogether and let me make unlimited moves with its pieces:
The GUI allows you to cheat without limit. It does not enforce pseudo-legality of the moves, and not even turn order. It was derived from a fairy-diagram generator that was always in setup mode. So it had no concept of a turn, which was also useful for games that allowed double moves.

But that made it somewhat difficult to know the the engine should move. I used the rule that a move with a piece of one color would imply the other color would then be on move. If the move did not release anything. But when a union is moved, you don't know to which side it belongs. So in that case, I just toggle the side.

So if the computer is set to play black, and you move a black piece, it thinks it is now white's turn, and so it would not move. It should oly move in reply to moving of white pieces or unions when it plays black.

Perhaps I should enforce turn order and pseudo-legality. But then you canot easily set up problems. And if there is a setup mode, people could switch to it to cheat. So I figured: "why just not leave it in setup mode all the time?". :?
Ah, that makes sense. Thanks!

Re: JavaScript Piece-Chess engine

Posted: Sat Sep 30, 2017 6:30 pm
by hgm
I posted a Peace-Chess puzzle that I composed myself:

http://hgm.nubati.net/paco/puzzle1.html