The Chess Variant Pages
Custom Search




[ Help | Earliest Comments | Latest Comments ]
[ List All Subjects of Discussion | Create New Subject of Discussion ]
[ List Latest Comments Only For Pages | Games | Rated Pages | Rated Games | Subjects of Discussion ]

Comments/Ratings for a Single Item

Later Reverse Order EarlierEarliest
This item is a play-by-email page
It belongs to categories: Orthodox chess, 
It was last modified on: 2016-12-11
 Author: Fergus  Duniho. Chess. Play Chess online with other people, using Game Courier, a PBM system that works with any web browser on any computer.[All Comments] [Add Comment or Rating]
Fergus Duniho wrote on 2020-02-07 UTC

The presets on this page now use newly designed fairychess code instead of Chess3, though existing games will not be affected by this. The fairychess include file is designed to be easily adapted for other games. Unlike Chess3, it identifies pieces by name instead of label, and it uses constants to associate labels with piece names. It also contains many more piece definitions, and I'll add more as need for them comes up. Just assign piece names to piece labels using constants. If you want to change the name of a piece, you can copy its functions (and subroutine if need be) to another name, then assign your constants to the new name. Here's an example of what could be done in Chinese Chess:

copyfn Chinese_Elephant Elephant;
copyfn Chinese_Elephant-Range Elephant-Range;
copyfn Chinese_Elephant Minister;
copyfn Chinese_Elephant-Range Minister-Range;
setconst e Elephant;
setconst E Minister;

Note that copying functions should be done after the file has been included, since it contains the functions to be copied. I'm not sure what to do about copying subroutines except to copy the whole code and change its name, but few pieces use subroutines.


Kevin Pacey wrote on 2019-09-17 UTC

Not sure this is the right place for my comment, as it may apply much more to Game Courier than Chess. Anyway, I was trying to use the Record feature for the chess preset. I entered 1.e2-e4 1.e7-e5 2.f1-c4 b8-c6 3.d1-f3 c6-d4 4.f3-f7 successfully (a version of Scholar's mate trap). However, when I tried to do the same thing but also insert "| 3.g8-f6 //is a better move." after Black's 3rd move, I got an error message saying I cannot move my opponent's piece, after I clicked on the 'View' button (that is, I unsuccessfully tried to enter a variation plus comment after the 3rd Black move of the main continuation).

I'm wondering if Game Courier's Record feature isn't fully working properly. In any event, I've yet to see a single webpage on CVP where a recorded game(s) have been offered by the author, and maybe that's no coincidence. [edit: I had missed the example game using the Record feature on the Voidrider CVP webpage. The moves were given, although no variations were offered (just Comments here and there), but more importantly, perhaps, I couldn't view a board from the Voidrider page for the example game.]


Fergus Duniho wrote on 2015-11-21 UTC
I changed #wpr and #bpr to var wpr and var bpr, because these values might be changed by a preset that uses the chess include file. As a general rule, you should use the var operator to get the value of a variable in an expression, because using # plugs the current value directly into the expression, but a function may be used multiple times when a variable has different values.

Fergus Duniho wrote on 2015-11-21 UTC

I seem to have gotten it to work now. I changed

def P 
remove #ep
checkleap #0 #1 1 1
and == var ep join filename #1 rankname #0
or and checkatwostep #0 #1 0 1 0 1 == rankname #0 #wpr 
or checkleap #0 #1 0 1 
and empty #1 
or and islower space #1 checkleap #0 #1 1 1
and > rank #1 rank #0;

to this

def P 
remove var ep
and checkleap #0 #1 1 1
and == var ep join filename #1 rankname #0
or and checkatwostep #0 #1 0 1 0 1 == rankname #0 #wpr 
or checkleap #0 #1 0 1 
and empty #1 
or and islower space #1 checkleap #0 #1 1 1
and > rank #1 rank #0;

Remember that Game Courier reads all of this backwards, and this is just one of two Pawn functions. The first change I made was to the logic of the function. I put an and in front of the second to last operation, checkleap #0 #1 1 1, so that nothing would be left on the stack when it got to the last operation. Since it still didn't work, I changed #ep to var ep. That worked. Now, why would I need var ep but get away with using #wpr. The difference is that wpr is effectively a constant, keeping the same value throughout execution of the program. So, when I define the function, wpr already has the value I will need it to have whenever I use the function. But ep is a true variable whose value keeps changing. To make sure the function uses its current value, I need to use var ep instead of #ep.

The remove built-in function is a new one for removing a piece from a space. It exits automatically with the value of an assignment to '@'. Most built-in functions do not change anything, focusing instead on returning values. But I wanted to check possible Pawn moves with a function alone instead of using a subroutine.


Fergus Duniho wrote on 2015-11-21 UTC


Fergus Duniho wrote on 2015-11-20 UTC
The chess include file is now storing legal moves. To do this, it has had to become less optimized than it used to be. It is now more like the chess2 include, the main difference being that is still uses a specialized function instead of a generalized subroutine to check whether the King is in check. This is more efficient but needs to be changed for games with additional pieces. The functions in the include file cover all pieces in Chess plus the Marshall (K+R) and Archbishop (K+B).

While this is working for Chess, I may have to continue working on it later to get it to work right with other games that do castling differently. For the time being, I will leave in old functions and subroutines that might be used in presets or include files that include this one.

Fergus Duniho wrote on 2015-11-20 UTC
I'm currently working on updating the chess include file to store legal moves for onclick display, but until I get it working, Chess and many other games using this include file may not work properly.

Fergus Duniho wrote on 2015-11-18 UTC
The Chess2 include file is now updated to use a stalemated subroutine that records all legal moves, which allows Game Courier to display the legal moves for a piece when a player clicks to move it. This does not affect the main Chess preset, but it does affect other presets that use the Chess2 include file, such as Hexagonal Chess and Caissa Britannia.

Fergus Duniho wrote on 2012-04-27 UTC
I have just added support for the 50 moves rule in Chess. Here is how it was done. I created a counter called nopvc, which means no Pawn or capture, and set it to zero. Whenever a Pawn moved or a piece was captured, it got reset to zero. Otherwise, it got incremented by 1. In the post-game part, I compared its value with 50. This is done after checkmate and stalemate are checked for just in case the 50th move resulted in a checkmate.

Also, I realized I was using a global variable for posvar in the code for enforcing three-times repetition. So I removed the code in the post-game part for computing the value of posvar. The value it needs to be has already been set the last time posvar was given a value.

Fergus Duniho wrote on 2012-04-27 UTC

I have just added support for the three-times repetition rule in Chess. When a player creates the same board position for the third time, and all the same moves are available, as in castling and en passant conditions are the same, then the game ends in a draw.

Here is how it is done. At the end of each post-move section, a variable representing the current state of the game is incremented, using code like this:

set posvar join "w" join fencode boardflags;
inc #posvar;

In the post-game section, the variable name for the current state of the board is computed, and its value is compared with 3, using code like this:

set posvar join "w" join fencode boardflags;
if >= var #posvar 3:
  say Three Times Repetition! Drawn Game!;
  drawn;
endif;

The code I've shown is for White. For Black, substitute "b" for "w".

I wrote the boardflags operator today. It returns an ordered string of all the flags that are turned on and whose names match coordinate positions. The variable posvar gets set to a long string that will be used as a variable name. #posvar returns the value of posvar, and var #posvar returns the value of the variable whose name is stored in the variable posvar.


M Winther wrote on 2010-12-27 UTC
I've already had good use of the 'continuemove' command in my
Twinmove Chess (compulsory) and Twinmove Chess (uncompelled)
These are two attractive presets now, much easier to handle. And
these double-move variants are really interesting.
/Mats

Fergus Duniho wrote on 2010-12-26 UTC
I guess I lost the original versions of continuemove and redomove by overwriting a newer file with an earlier file. So I rewrote them, doing it differently this time, because I didn't remember exactly what I did before. But the functionality should be the same. Continuemove is another name for extendmove. Redomove is just like continuemove except that it does not retain any past moves. They use the same code, differing only in what they set the pastmovesfield string to. I am using the names continuemove and redomove to reflect their similarity to the continue and redo commands used for loop control. Like these commands, they are used for a kind of loop control, except that instead of the loop existing inside a single program, the loop is between moves executed by different programs. Like continue and redo, unconditional or improper use of continuemove and redomove can create infinite loops.

Fergus Duniho wrote on 2010-12-25 UTC
It appears I lost some changes I recently made, and I'm going to have to redo them.

M Winther wrote on 2010-12-24 UTC
Fergus, what are these commands 'continuemove' and 'redomove' in the Developer's Guide? They don't seem to be implemented yet(?) 
/Mats

M Winther wrote on 2010-12-21 UTC
Yes, that was how my plycount worked, and it obviously works now. Thanks.
/Mats

Fergus Duniho wrote on 2010-12-21 UTC

Okay, I programmed Chess - Test to count plyturns, and after making a few changes to how constants work, I got it to work. You can try it before I change the code to something else. Let me know if it works the same as yours.


M Winther wrote on 2010-12-21 UTC
No, I don't use constants in this preset anymore, and Fischer Placement Chess
isn't randomized. It is a manual method of generating 25 Chess960 positions.
However, I again inserted the old code, which uses a constant. And it has
ceased working. I then changed this constant to a variable, and it works
again.

I suggest that you revert to the old way of how constants function. There
might be many presets that have stopped working now.

The way in which I used the constant is this: I first, in the precode, make
setconst plyturn 1;, then I call unsetconst plyturn; setconst plyturn 2;,
etc., and increment plyturn in order to keep count of which turn it is.
This simple method doesn't work anymore. (I just happened to use it
because you recommended constants in the problems with the ask command.)
/Mats

Fergus Duniho wrote on 2010-12-21 UTC
I can't find your Fischer Placement Chess, but if it is letting players place their pieces as they wish instead of randomly placing pieces, then it doesn't need constants to store the initial positions. The games of Fischer Random Chess I've checked are all working fine, and the tests I've run to check whether constants are working have worked fine.

Fergus Duniho wrote on 2010-12-20 UTC
I originally created constants because the algorithm for picking random numbers changed, which broke all games of Fischer Random Chess and other random variants. I used to rely on reusing the same seed value, which worked fine as long as the algorithm for picking random numbers didn't change. If it doesn't change again, constants are unnecessary for these games. But if it ever does change again, the constants will preserve games started before the change.

M Winther wrote on 2010-12-20 UTC
Good, however I can make do without constants. My Fischer Placement Chess works excellently now, with automatic pawn promotion, castling, et al.
/Mats

Fergus Duniho wrote on 2010-12-20 UTC
I'll look into it.

M Winther wrote on 2010-12-20 UTC
Fergus, are you certain that you haven't compromised the function of certain presets now that you have changed how constants function? Today I discovered that my Fischer Placement Chess preset has stopped working. I make use of a constant in it (however, I can change that to a variable). 
/Mats

M Winther wrote on 2010-12-20 UTC
Thanks, but you really must explain this better in the documentation about ask and askpromote, otherwise it will be an eternal source of frustration. 
/Mats

Fergus Duniho wrote on 2010-12-20 UTC

It looks like I now have constants working in solitaire mode. Still, it can be more effective to test whether ask is required by checking whether the move entered by the player is incomplete. This keeps it from unnecessarily calling ask when it isn't needed. And once the move is completed, it wouldn't have to call ask again.


Fergus Duniho wrote on 2010-12-19 UTC

Now that I think about it, constants will not work in solitaire mode, because it never writes anything to a log. I am going to work on including constants in the forms that pass variable values. In the meantime, you might write your code to check the contents of the move, which you can check with the thismove keyword in an expression. Since the ask command will append to the move, all you have to check is whether the move is complete. For example, if your short and long castling moves differ on the position the Rook moves to, check the move for a Rook move, calling on ask only if the Rook move isn't present. Doing it this way also stops ask from being used when a player manually enters in the full move.


25 comments displayed

Later Reverse Order EarlierEarliest

Permalink to the exact comments currently displayed.