Check out Glinski's Hexagonal Chess, our featured variant for May, 2024.


[ 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 by Fergus Duniho

Later Reverse Order EarlierEarliest
The Fairychess Include File Tutorial. How to use the fairychess include file to program games for Game Courier.[All Comments] [Add Comment or Rating]
🕸📝Fergus Duniho wrote at 02:20 AM UTC in reply to Fergus Duniho from Sun May 12 10:29 PM:

I was thinking of splitting the checked function into separate checked-real and checked-potential functions, but as I was looking into which would be which, it looked like there was never any time when it was passed an empty space after the King just moved. In the Pre-Move sections, kpos or Kpos would be updated before calling the function, and in stalemated, it would check whether the King was the moving piece and pass the King's new position if it was. This meant I could reduce the function to this:

def checked anytrue lambda (fn const alias #0 var key var king) 
cond isupper space var king (onlylower) (onlyupper) 
=movetype CHECK 
=king;

Just in case, I ran this code in Ultima as a test:

sub checked king:
  my from piece;
  local movetype;

  set movetype CHECK;
  if empty var king:
    die "The King space at {#king} is empty.";
  endif;
  if isupper cond empty var king $moved space var king:
    def enemies onlylower;
  else:
    def enemies onlyupper;
  endif;
  for (from piece) fn enemies:
    if fn const alias #piece #from var king:
      return #from;
    endif;
  next;
  return false;
endsub;
def checked sub checked #0;

This code would exit right away with an error message if the subroutine, which was called by the function here, got passed an empty space. I then looked at completed games using the same include file, and they did not exit with the error message. So, I got rid of this code and modified the function, tested Ultima again, and it still worked for both actual checks and for moves that would move the King into check.

With that change made, I ran the speed tests again and got these results:

Elapsed time: 1.0438919067383 seconds

Elapsed time: 0.46452307701111 seconds

Elapsed time: 1.013090133667 seconds

Elapsed time: 0.48957395553589 seconds

Elapsed time: 1.1313791275024 seconds

Elapsed time: 0.49660110473633 seconds

In each pair the subroutine is first, and the function is second, and in each case the function takes less than half the time. In both this case and the previous one, these tests were done on the opening position in Chess, in which the King is not in check, meaning that it checks for check from every enemy piece without exiting early.


Rococo. A clear, aggressive Ultima variant on a 10x10 ring board. (10x10, Cells: 100) (Recognized!)[All Comments] [Add Comment or Rating]
🕸Fergus Duniho wrote on Sun, May 12 10:39 PM UTC in reply to NeodymiumPhyte from 08:35 PM:

I asked David Howe about the situation where a Chameleon can capture a Cannon Pawn by hopping over an enemy Long Leaper, and he says "The Long Leaper is not captured. The Long Leaper capturing move requires moving to a vacant square."


The Fairychess Include File Tutorial. How to use the fairychess include file to program games for Game Courier.[All Comments] [Add Comment or Rating]
🕸📝Fergus Duniho wrote on Sun, May 12 10:29 PM UTC:

The changes to Game Courier I described here were for the purpose of writing a checked function that would do the same job as the checked subroutine but even faster. This is for the sake of illustrating the gains in speed of using functions rather than subroutines when a function will do the job. Here's the code for the subroutine and the function:

sub checked king:
    my from piece;
    local movetype;

    set movetype CHECK;
    if isupper cond empty var king $moved space var king:
        def enemies onlylower;
    else:
        def enemies onlyupper;
    endif;
    for (from piece) fn enemies:
        if fn const alias #piece #from var king:
            return #from;
        endif;
    next;
    return false;
endsub;

def checked anytrue lambda (fn const alias #0 var key var king) 
cond isupper cond empty var king $moved space var king (onlylower) (onlyupper) 
=movetype CHECK 
=king;

I have tested the function out in Ultima, because its stalemated subroutine is not widely used in other presets, and its piece functions make use of the movetype value to determine whether it is a regular move or a checking move. Things appear to be working in Ultima. In speed tests comparing 1000 repetitions of each, the function is around twice as fast. In these results, the first, third, and fifth are the subroutine, and the second, fourth, and sixth are the function.

Elapsed time: 0.92847084999084 seconds

Elapsed time: 0.45569705963135 seconds

Elapsed time: 0.87418103218079 seconds

Elapsed time: 0.46827101707458 seconds

Elapsed time: 1.1367251873016 seconds

Elapsed time: 0.65254402160645 seconds

Game Courier History. History of the Chess Variants Game Courier PBM system.[All Comments] [Add Comment or Rating]
🕸💡📝Fergus Duniho wrote on Sun, May 12 08:53 PM UTC:

I made a change to the following functions that can run lambda functions on array values: aggregate, allfalse, nonetrue, alltrue, anyfalse, anytrue, any. These will now have access to the variable key, which will contain the key of the array value currently passed to the lambda function. This should be accessed with the var keyword to make sure that a previously defined variable is not being used.

To prevent expressions using these from changing the value of a previous variable called key, I had to raise the scope of every expression. But to get this to work, I had to rewrite each built-in function that exited the PHP function for evaluating expressions with a return. Instead of using return, I had each one set $output to a single element array with the return value, and I set $input to an empty array so that the condition on the while loop would be false. Doing this makes sure that it decrements the scope before exiting the function.

Raising the scope of an expression also makes sure that the mechanism for adding named variables to a function cannot be used in an expression to set a variable that lasts beyond the expression. The following code prints 6468, then it prints 63. This is because it raises the scope for the assignments in the expression, and when it completes the expression, it closes that scope.

set o 9;
set y 7;
set pp * var o var y =o 98 =y 66;
echo #pp;
print * #o #y;

Home page of The Chess Variant Pages. Homepage of The Chess Variant Pages.[All Comments] [Add Comment or Rating]
🕸📝Fergus Duniho wrote on Sat, May 11 06:14 PM UTC:

I noticed today in the comments section that Smess was being given the description for Take the Brain. So, I made some corrections to make sure that the correct description was given for the name it was paired up with in IndexEntry. In the comments section, the primary name and description should now be used. In queries of the database on the names of games, each description will now show up for the name it goes with. On the What's New page, the name should be the primary name, and the description should be the Whatsnew text if it is available. Otherwise, it will fall back to using the primary description. All of this now works correctly for Smess, All the King's Men, and Take the Brain, though I have not tested other games with multiple names.


Smess. (Updated!) Produced and sold in the early 70's by Parker Brothers. Arrows on squares determine direction pieces can move. (7x8, Cells: 56) (Recognized!)[All Comments] [Add Comment or Rating]
🕸📝Fergus Duniho wrote on Sat, May 11 05:03 PM UTC in reply to Fergus Duniho from 12:38 AM:

Because the Ivorytower pieces looked a little small on the board, I reduced the size of the board from 83x83 squares to 73x73 squares. The original board had 83x73 squares to give it a more square shape with a 7x8 layout, but the 73 pixel width works better for the Ivorytower pieces, because they can now fully cover up the oval on some spaces that names the piece starting from that position. I also tried 60x60 spaces, as that is the size used in Storm the Ivory Tower, but the Blue Brain was covering up too much of the forward arrow on its space. So I reverted to 73x73.

While the Ivorytower pieces do look better, they are still rough around the edges. and I think they would look better as SVG pieces.


🕸📝Fergus Duniho wrote on Sat, May 11 12:38 AM UTC in reply to HaruN Y from Fri May 10 01:43 AM:

I got your diagram to display correctly and added it to the page with some modifications. To make the board display correctly without tiling, I removed the firstRank assignment and set borders to 0. I replaced the graphics with ones I created for Smess. The board is a stretched version of one I made for Game Courier, and the pieces are the ones I made for Storm the Ivory Tower, which have smoother edges. I set useMarkers to 1 to stop it from changing the background color of a space when highlighting it, but this doesn't work for moves made by the opponent. Since it is important to not hide the arrows on the board, it would be helpful if useMarkers would also change how the opponent's moves are highlighted.


🕸📝Fergus Duniho wrote on Fri, May 10 09:30 PM UTC in reply to Fergus Duniho from 09:10 PM:

I created and used a new board with 83x83 spaces, and I set squareSize to 83, but now the board is starting halfway into the first rank and tiling on the right side. What can I do to fix that?


🕸📝Fergus Duniho wrote on Fri, May 10 09:22 PM UTC in reply to Fergus Duniho from 09:10 PM:

I changed the board image to the one that goes with the pieces, and it looks a lot better, but there are still some alignment issues. The spaces on the board are rectangular with a width of 83 and a height of 73, but the squareSize parameter seems to expect one value that gets used for both height and width. Is there any way to specify height and width separately? In the meantime, I'll make a resized copy of the board with square spaces.


🕸📝Fergus Duniho wrote on Fri, May 10 09:10 PM UTC in reply to Fergus Duniho from 09:06 PM:

Also, I added the same code to the Smess diagram, and it is now tiling with the pieces on it. Since I made those pieces for a larger board, I think the board image and the pieces are not at the same scale.


🕸📝Fergus Duniho wrote on Fri, May 10 09:06 PM UTC in reply to H. G. Muller from 08:02 PM:

For some reason this does not work anymore. The I.D. on the Eurasian Chess page also lost its background, and I am sure this worked before. Is there some global style definition now that gives elements a background color?

Looking at it with Web Developer Tools in Firefox, I see that TABLE TR has the background-color value of var(--nav-bgcolor), and when I turn it off, the background image shows up. With that in mind, I added this to the Eurasian Chess page, and that fixed it:

<STYLE>
TABLE#board0 TR {background-color: inherit;}
</STYLE>

Would it be a good idea to add this to global.css?


Game Courier Logs. View the logs of games played on Game Courier.[All Comments] [Add Comment or Rating]
🕸📝Fergus Duniho wrote on Fri, May 10 04:09 PM UTC in reply to H. G. Muller from 02:54 PM:

The reliable method would try out all pseudo-legal moves, and then generate opponent moves in each of the resulting positions, to see if any of those captures the King. All opponent moves will have to be tried to conclude the move is legal (which usually is the case), and on a large variant this can take very long (to the point where GC aborts the GAME-code execution).

Thanks to GAME Code being an interpreted language written in another interpreted language, it is not as quick at things compiled languages would do more quickly, and it will sometimes exceed the time limit that PHP imposes on script execution. This makes optimizations and short cuts more important, and in hand-written code, I have done this. See my previous comment about how I handled the spotting of check in Ultima as an example.

In automatically-generated code, it might be harder to get in the optimizations needed for particular games. So I would suggest a compromise between your quick method and your reliable method. Flag pieces that can capture a piece without moving to its space, and use your reliable method on these while just checking if other pieces can move to the King's space.


Smess. (Updated!) Produced and sold in the early 70's by Parker Brothers. Arrows on squares determine direction pieces can move. (7x8, Cells: 56) (Recognized!)[All Comments] [Add Comment or Rating]
🕸📝Fergus Duniho wrote on Fri, May 10 03:56 PM UTC in reply to HaruN Y from 01:43 AM:

This isn't showing up well on any browser or OS I've seen it on. On my iPad, I see the arrowed board both above and below the blank 7x8 board with the pieces, and the one above is tiled. On Android and Windows, the tiled board is not appearing at the top, but the pieces are still not appearing on the same board as the arrows.


Game Courier Logs. View the logs of games played on Game Courier.[All Comments] [Add Comment or Rating]
🕸📝Fergus Duniho wrote on Fri, May 10 01:16 PM UTC in reply to H. G. Muller from 05:58 AM:

You did not get the point. Does the preset say 'check' when you check with any other piece than an Advancer? I think it doesn't. So then this has nothing to do with the piece being an Advancer.

I dug back into this thread to find the preset he was talking about. He linked to a particular game in which neither Advancer checked the opponent's King. Continuing this game by choosing Annotate and then Move, I played some moves to get a White Flying Dragon to check the Black King, and when I did, it said "check!". After moving the King out of check, I tried to move White's Advancer, but no legal moves are being highlighted on the board for it. However, its legal moves do show up in the Moves field, and when I tried one, it worked. At the top of the Moves field, I see the legal move "A e1-#to; A #to-b1". I think this is not a properly formatted move, and it may be interfering with the ability to recognize the Advancer's legal moves. Also, when I entered it, it did not recognize it as legal, and it gave the error message "#to is not a valid square".

Here are the moves to the position in question so that you can see what's going on.

1. P f2-f5 
1... p f9-f6 
2. P e2-e4 
2... p e9-e7 
3. F i1-h3 
3... f i10-h8 
4. P i2-i3 
4... p d9-d8 
5. B h1-i2 
5... c g10-f7 
6. C d1-f3 
6... f b10-c8 
7. C g1-e3 
7... c d10-f8 
8. K f1-i1 
8... p g9-g7 
9. P b2-b3 
9... c f8-e5 
10. P d2-d4 
10... c e5-f8 
11. B c1-b2 
11... a e10-h7 
12. F b1-e2 
12... p i9-i8 
13. P g2-g5 
13... c f7-e8 
14. P g5-g6 
14... a h7-f9 
15. P c2-c4 
15... p b9-b6 
16. F h3-g2 
16... c e8-d7 
17. P d4-d5 
17... f c8-d6 
18. F e2-h3 
18... p c9-c7 
19. C f3-e6 
19... c d7-e6 
20. P d5-e6 
20... p j9-j8 
21. B b2-a3 
21... b c10-a8 
22. B a3-d6 
22... p e7-d6 
23. R h1-f1 
23... p j8-j7 
24. F g2-d3 
24... b h10-j8 
25. C e3-g1 
25... f h8-i6 
26. P j2-j3 
26... p d8-d7 
27. P a2-a5 
27... p b6-a5 
28. R a1-a5 
28... b a8-b9 
29. P e6-d7 
29... f9-e8;@-d7 
30. C g1-a7 
30... f i6-h4 
31. C a7-d8 // - check! -
31... k f10-f9

Just click on Annotate for Butterfly Chess and paste these in to see the same position.


🕸📝Fergus Duniho wrote on Thu, May 9 10:18 PM UTC in reply to Kevin Pacey from 08:57 PM:

Yes, I originally would have thought when an Advancer made a move that threatened a King, an enforcing preset would automatically announce check.

However, maybe the Advancer, being an Ultima-like piece, does not actually make a check in an Ultima-like game (which Butterfly Chess is not)?

So I now ask, is that the usual assumption that Applet generated preset code makes for every CV put through the generating process?

I don't know how a generated preset works, but the checked subroutine I use in the fairychess include file normally checks for captures by displacement by checking if each enemy piece on the board can move to the King's position. This would not normally work with Ultima pieces, which do not normally capture by displacement, but I have managed to use this subroutine with Ultima without modifying it. First, let's look at the subroutine:

sub checked king:
    my from piece;
    local movetype;

    set movetype CHECK;
    if isupper cond empty var king $moved space var king:
        def enemies onlylower;
    else:
        def enemies onlyupper;
    endif;
    for (from piece) fn enemies:
        if fn const alias #piece #from var king:
            return #from;
        endif;
    next;
    return false;
endsub;

The key to working with Ultima is that it sets movetype to CHECK. With this in mind, I have written functions for Ultima pieces like this:

def Black_Withdrawer fn join "Black_Withdrawer_" var movetype #0 #1;

Depending upon the value of movetype, it will call either Black_Withdrawer_MOVE or Black_Withdrawer_CHECK, which I have defined separately and differently. Thanks to setting movetype to CHECK, the checked subroutine will use the *_CHECK functions for Ultima pieces. Instead of going through a normal move, one of these functions will check whether the piece at the first coordinate can capture the piece at the second. For example:

def Black_Withdrawer_CHECK 
empty where #frm - file #frm file #to - rank #frm rank #to
and == distance #frm #to 1
and not near #frm I 1
=frm =to;

This first makes sure that the piece is not next to a White Immobilizer (designated as I). It then verifies that the two spaces are adjacent. Calculating the direction away from the piece at #to, it checks whether there is an adjacent empty space in that direction. If there is, it returns true.


Crossroads. Members-Only Crossing the diagonals generate figures. (9x9, Cells: 81) [All Comments] [Add Comment or Rating]

Since this comment is for a page that has not been published yet, you must be signed in to read it.

Since this comment is for a page that has not been published yet, you must be signed in to read it.

Since this comment is for a page that has not been published yet, you must be signed in to read it.

Since this comment is for a page that has not been published yet, you must be signed in to read it.

Since this comment is for a page that has not been published yet, you must be signed in to read it.

Since this comment is for a page that has not been published yet, you must be signed in to read it.

Game Courier. PHP script for playing Chess variants online.[All Comments] [Add Comment or Rating]
🕸💡📝Fergus Duniho wrote on Thu, May 9 04:12 PM UTC in reply to Aurelian Florea from 06:59 AM:

You need code in your Post-Move sections to control what is allowed on the first turn. Setting legal moves in the Post-Game section is not enough, because these will only be used for which legal moves are highlighted for the player. They will not control which legal moves are allowed.


Play-test applet for chess variants. Applet you can play your own variant against.[All Comments] [Add Comment or Rating]
🕸Fergus Duniho wrote on Sun, May 5 04:59 PM UTC in reply to H. G. Muller from 08:18 AM:

The only thing I am still in doubt about is whether the current betza.txt include file on which the PTA-generated code relies tests for a move being the final one in a safe and reliable way. Because it uses mln for the test rather than turn.

I have just added thismovenum and maxmovenum. These will return $mline[$mln]->movenum and $mline[$maxmln]->movenum. It's likely that maxmovenum will be returning the same value as movenum, which returns $movenum, but using it will add clarity to your code.


About Game Courier. Web-based system for playing many different variants by email or in real-time.[All Comments] [Add Comment or Rating]
🕸💡📝Fergus Duniho wrote on Sun, May 5 04:34 PM UTC in reply to Daniel Zacharias from 03:38 PM:

You're using k/K for the general, but the code you copied is using g/G. So kpos and Kpos are not being updated.


🕸💡📝Fergus Duniho wrote on Sun, May 5 01:16 PM UTC in reply to Daniel Zacharias from 12:38 PM:

Your link is missing a query string.


25 comments displayed

Later Reverse Order EarlierEarliest

Permalink to the exact comments currently displayed.