JavaScript Peace-Chess engine

Discussion of anything and everything relating to chess playing software and machines.

Moderators: hgm, Rebel, chrisw

User avatar
hgm
Posts: 27811
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

JavaScript Peace-Chess engine

Post 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!
Last edited by hgm on Thu Sep 28, 2017 8:46 am, edited 2 times in total.
User avatar
cdani
Posts: 2204
Joined: Sat Jan 18, 2014 10:24 am
Location: Andorra

Re: JavaScript Piece-Chess engine

Post by cdani »

Nice!
A presentation bug after e4 Nf6 e5 d5 ef6 e5:

Image
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: JavaScript Piece-Chess engine

Post 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.
MonteCarlo
Posts: 188
Joined: Sun Dec 25, 2016 4:59 pm

Re: JavaScript Piece-Chess engine

Post 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 :)
User avatar
hgm
Posts: 27811
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: JavaScript Piece-Chess engine

Post by hgm »

Sven wrote:Wasn't the name of this game "Peace Chess"?
Oops! :oops: I corrected that now, thx.
User avatar
hgm
Posts: 27811
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: JavaScript Piece-Chess engine

Post 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?". :?
User avatar
cdani
Posts: 2204
Joined: Sat Jan 18, 2014 10:24 am
Location: Andorra

Re: JavaScript Piece-Chess engine

Post by cdani »

cdani wrote:Nice!
A presentation bug after e4 Nf6 e5 d5 ef6 e5:

Image
I confused the name. Now I understood :-)
MonteCarlo
Posts: 188
Joined: Sun Dec 25, 2016 4:59 pm

Re: JavaScript Piece-Chess engine

Post 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!
User avatar
hgm
Posts: 27811
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: JavaScript Piece-Chess engine

Post by hgm »

I posted a Peace-Chess puzzle that I composed myself:

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