Comments/Ratings for a Single Item
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.]
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.
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.
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.
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.
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.
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.
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.
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, what are these commands 'continuemove' and 'redomove' in the Developer's Guide? They don't seem to be implemented yet(?) /Mats
Yes, that was how my plycount worked, and it obviously works now. Thanks. /Mats
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.
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
Good, however I can make do without constants. My Fischer Placement Chess works excellently now, with automatic pawn promotion, castling, et al. /Mats
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
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
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.
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.
Fergus, I am having problems with the *ask* command. It seems to end up in an eternal loop. When I choose an alternative it merely asks again. I even use a constant to prevent eternal loops, but it doesn't help. (In the following code I use 'skip' for testing purposes): [...] elseif equal moved K; set legal or checkleap origin dest 1 1 checkleap origin dest 1 0; if var legal; if and equal dest c1 equal #wcastletest 0; unsetconst wcastletest; setconst wcastletest 1; if or and equal origin b1 and equal @ space d1 equal R space a1 and equal origin d1 and equal @ space b1 equal R space a1; ask 'Do you want to castle long?' 'y' 'skip' 'n' 'skip'; endif; endif; else; [...] endif; endif; Nor can I get 'askpromote' to work. This generates an eternal loop: if and var legal equal rankname dest 8; askpromote Q R B N; endif; /Mats
Of course, 'extendmove' must be conditioned, but it seems like the flags don't change their value when 'extendmove' is used(?). Correct me if I'm wrong; if I change a flag in order to make extendmove conditional, the flag doesn't actually change its value until the other *colour* gets the turn. Example: if flag firstturn; if == origin e1 and == dest g1: setsystem moves 'swap e1 g1'; add K g1 N e1; endif; unsetflag firstturn; setflag secondturn; extendmove; elseif flag secondturn; if equal moved Q; setsystem moves 'swap origin dest'; add moved origin moved dest; endif; unsetflag secondturn; endif; In the above code 'secondturn' is executed by the same colour. But this code is never executed because the flag 'secondturn' does not actually change its value until the other player gets the turn. The command extendmove seems to have this effect, if I'm correct. /Mats
Good. How about the problem that the board does *not* turn (in single mode) when first player is set to Black? /Mats
Okay, the problem on my end is that the extendmove
command is not yet working properly in solitaire mode. But my tests indicate that it is working properly in correspondence mode.
The problem on your end is that putting extendmove
as the final command in the postmove code creates an infinite loop. It's not a proper use of the command. It should only be used within a conditional statement that checks whether it needs to be called. In this Chess game between myself and my alter ego, extendmove
is the only command, occurring in post-move1 by itself. It does not turn the board around, but it creates an infinite loop in which White can keep moving one piece after another but is never able to send the move to his opponent. You can try it yourself.
Fergus, if I insert it *last* in the post-move code, as the final command (or as the only command), then the move is extended, but the board turns. You can test it yourself, it takes 15 seconds. /Mats
But I'm not doing anything. I just insert the statement 'extendmove' and the board still turns. So there is nothing to look at. It works, because I can move the same colour again, but from the top of the board. This is confusing, of course. /Mats
Fergus, why don't you try to implement your Janggi with two relocation moves in a row, and make use of extendmove. /Mats
I need you to show me the preset you are using the extendmove command in.
When I use extendmove I hoped to be able to make one more move with the same player. This seems to work, however, the board has turned. If white is going to make one more move, he has to do it with his pieces at the top of the board, and this is awkward. /Mats
However, I have a problem. If the game is started with Black as the first party to move, then the board doesn't turn when a move is made. It's a bug in Game Courier. (This is regardless of extendmove.) Moreover, after 'extendmove' the board is still turned, which forfeits the purpose of the command, I think. /Mats
Wonderful! Thanx! I think I can attract more chessplayers to the site to test my Relocation variants, when I have implemented them, because this is chess close to Fide chess. What was the latest Anand vs. Carlsen game all about? I say computer preparation far into the middle game. I don't believe in this development. /Mats
The extendmove command should do what you want. It does not change the turn order, and it does not force anyone to pass a turn. What it does is return the player to the form for making a move, showing the moves as they have already been made for that turn, and allowing the player to make another move. It then appends the new move to the past moves. It may be used once or multiple times for longer moves, depending on what is called for. When using this command, care should be taken that it only be used for the current move. This may involve writing code that distinguishes between partial moves and complete moves. Basically, it lets you use the mouse to do what you could always do previously by typing moves manually. See my current code for Korean Chess for an example similar to what you want. It allows the player to swap one or both pairs of Knight and Elephant, then immediately make a move, all using the mouse. But I'm going to change this in a new preset, because this doesn't follow the rules of Korean Chess strictly.
e.g. give a command, for instance, 'keepturn' and the turn remains with
the player who just moved. In this way I can implement my revolutionary
Relocation Variants. Perhaps this could be implemented by forcing a pass move(?).
/Mats
I did some more debugging this evening. I fixed a bug, reported by Antoine, that allowed a piece to capture another piece of its own color. I also fixed a bug in my Polish notation calculator that caused it to ignore checks from Knights. I spent the past hour or so entering moves from a game between Captain Smith and Philidor. The entire game played through, and I caught the Knight bug while trying to make illegal moves on occasion. At the end, I tested the checkmated King's moves, and none were allowed. One was because it couldn't capture a piece on the same side, and the rest were because it couldn't move into check. I also tried moving another piece, but the King remained in check, so the move wasn't allowed. The one remaining bug that I know of has to do with being able to enter illegal moves by entering multiple moves with semicolons or by entering commands. This has to do with what kind of entry data is allowed and not with the preset per se. If I included an option for restricting entry data, I could stop the entry of illegal moves. But for now at least, I am going to consider this bug acceptible. The preset is good enough to keep you from making illegal moves by mistake. It just won't prevent you from deliberately making some kinds of illegal moves. But on those occasions when you did deliberately make an illegal move, it would be obvious to your opponent that your move wasn't well-formed. Other than that, it seems to be in full working order. Try it out and let me know if you find anything amiss.
52 comments displayed
Permalink to the exact comments currently displayed.
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:
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.