[ List Earliest Comments Only For Pages | Games | Rated Pages | Rated Games | Subjects of Discussion ]
Comments/Ratings for a Single Item
<P>Here's what the most recent changes to Game Courier are about. Previously, the entire GAME Code program would be interpreted in one big <B>for</B> loop. I put this into a function so that GAME Code's subroutines could be handled through recursive function calls. This made it easier for me to have subroutines return values. So easy, in fact, that the Polish Notation calculator now includes the sub operator, which calls the named subroutine with a list of arguments, runs it, and returns its value. In this way, multiple subroutine calls can be included in a single Polish Notation expression.</P>
<P>Also, Game Courier used to read through every line of a GAME Code program, skipping certain lines depending upon the value of conditions in if-statements and loops. It now uses direct jumps to bypass code it won't be executing. This doesn't really affect what you can do with the language, but it makes it more efficient.</P>
I have been busy improving GAME Code this week. Here are some of the latest improvements. Instead of using explode to split a line of code into strings of non-whitespace, I have written some parsing functions. One parsing function checks whether a line of code is a move, returning each item in a separate argument. If it's not a move, a second parsing function is used. This function parses out quoted strings, arrays, and non-whitespace strings. Here's how it works. It goes through each character of a line. It normally skips over whitespace. When it finds a double quotation mark immediately after whitespace, it copies everything until the next one as a single string. When it find a left parenthesis, it copies everything until the next right parenthesis, then recursively calls the parsing function on this. This generates an array. Otherwise, it copies as a single argument whatever text falls between whitespace. Also, it does additional preprocessing only on unquoted nonarrays. So if you want to use 'origin', 'dest', or 'moved' as strings rather than as special variables, you can quote them to use the strings. This is required if you want to use setglobal to set the value of one of these variables. I've added target and check operators to the Polish notation calculator. These work sort of like switch and case. They are used for speeding up the search for pieces that might be checking the King. Details are in the documentation. The fn operator now accepts nameless functions as arrays, which allows the creation of nameless lambda functions.
Over the weekend, I added the ability to use parentheses for expressing arrays. For example, this will now set an array of all white pieces in Chess: set white (K Q R B N P); Arrays are parsed recursively, so that nested parentheses will yield multi-dimensional arrays. When lines are evaluated by the Polish notation calculator, the contents of arrays are not automatically evaluated. For example set a * (+ 4 5) (- 9 5) should not evaluate to 36. But arrays may be conditionally evaluated by the logical operators and, or, nor, nand, and cond, and also be eval and fn. For example, set a * eval (+4 5) eval (-9 5) would yield 36. When given arrays as arguments, the binary logical operators will evaluate the first array first, then evaluate the second only if its value is needed to determine the value of the expression. For example, set a or (== 4 4) (!= 4 7) will evaluate only (== 4 4) The cond operator is the equivalent of ?: in C or PHP. It will evaluate an expression, and if it is true, it will evaluate the array following the expression, but if it is false, it will evaluate the second array following the expression. For example, cond != 6 6 (== 7 9) (<= 9 7) will evaluate (<= 9 7) but not (== 7 9) Last night, there was still a problem with using parentheses with recursive functions. That problem is now fixed. It is now possible to write a recursive function like this one for finding a number's factorial: def fac cond equal #0 1 1 (* #0 fn fac dec #0); Note that #0 is now the first placeholder instead of #1. I changed all the placeholders in chess.txt to accomodate this. This particular function has been tested and shown to work. It first checks whether the value passed to it is equal to 1, with 'equal #0 1'. If it is 1, it returns 1. Otherwise, it evaluates the array (* #0 fn fac dec #0), which multiples the value passed to the function, #0, with a recursive function call of one less than the value passed, dec #0.
I've added switch, case, and endswitch commands. These work like switch and case in C, but not in PHP. The case statement can be used only with constant labels, because it works as a computed goto, not as a series of tests. I've modified the break command to be able to break out of a switch block. Details are in the section on control structures.
Control structure commands that introduce a body of code can now be ended with a colon instead of a semicolon. These include if, elseif, else, do, for, foreach, switch, case, and default. I did this, because I think it looks better. In other languages that end lines with semicolons, these commands normally do not end with semicolons. Semicolons are still allowed for backwards compatibility with old code. The program code is now broken up with a specialized parsing function instead of exploding on semicolons. The foreach command is now an alias for the for command. Both commands work much like foreach from Perl or PHP. By using an array instead of a string for naming the for variable, you can get both the key and the value of each array member. For example, the following code lists all the spaces of the board, assuming the 64-times limit of echo isn't exceeded: foreach (key val) spaces: echo #key #val; next;
I am currently developing code for checking whether a player is checkmated or stalemated. It is not all working right yet, but if anyone wants to take a look at it, you will find it here: /play/pbm/includes/checkmate.txt I am using it with a new version of the Chess preset: /play/pbm/play.php?game=Chess&settings=checkmate This preset is only for testing and should not be used for ongoing games. Also, so that single and double quotation marks can be entered in the form fields for GAME Code, I have switched to storing strings in settings files with the heredoc format. This will not affect current presets unless they are resaved.
One more thing. The new code is making use of two new commands called store and restore. The store command saves the current board configuration, including both piece locations and flags, and the restore command restores the board configuration to what it was the last time it was stored. These commands allow some subroutines to try various possible moves without permanently changing the board configuration.
I went through my code today, adding descriptions to this page of functions, commands, and operators I had previously missed or only recently created. Except for the commands for cards, which are already described in the User's Guide, this page should have a complete and up-to-date description of the commands, operators, and built-in functions you can use in GAME Code.
This comment, which I accidently posted on the wrong page a couple days ago, belongs on this page: I added the following new functions to the Polish notation calculator today: checkmaxsteps checknsteps checkpath These all handle movement that may go along a winding, unobstructed path, such as the movement of some pieces in Jetan. The checkmaxsteps function checks whether a piece may move from one space to another within a specified number of steps from one adjacent space to another. The checknsteps function checks whether a piece may move from one space to another in exactly a specified number of steps. Both of these functions allow movement through the origin space and repeated movement through the same space. They are both handled by a recursive function that goes through all possible paths until it finds one that works. The checkpath function checks whether a piece can move from one space to another by following a specific path, given as a set of paired directions. To illustrate how these work, here are two alternate ways to handle the Squire from Holywar: Barring possible mistakes, here is the long way that uses 16 checkpath functions for all possible paths: checkpath origin dest (1 0 1 1) or checkpath origin dest (1 1 1 0) or checkpath origin dest (1 0 1 -1) or checkpath origin dest (1 -1 1 0) or checkpath origin dest (-1 0 -1 1) or checkpath origin dest (-1 1 -1 0) or checkpath origin dest (-1 0 -1 -1) or checkpath origin dest (-1 -1 -1 0) or checkpath origin dest (0 1 1 1) or checkpath origin dest (1 1 0 -1) or checkpath origin dest (0 1 -1 1) or checkpath origin dest (-1 1 0 -1) or checkpath origin dest (0 -1 1 1) or checkpath origin dest (1 1 0 1) or checkpath origin dest (0 -1 1 -1) or checkpath origin dest (1 -1 0 1); Here is the short way that uses checknsteps in combination with checkleap: checkleap origin dest 1 2 and checknsteps origin dest 2; The checkleap function makes sure that the piece is going to a space a Squire could move to, then the checknsteps function makes sure it can get there in exactly two steps.
I have now modified the Alfaerie-JPG version of the Chess preset to use the code I've been working on for identifying check, checkmate, and stalemate. For each of these, it will put an appropriate message above the board, and for checkmate and stalemate, it will automatically update the status. I have also created the commands won, drawn, and lost for updating the status. The <B>won</B> command declares the current player to be the winner, <B>lost</B> declares the current player's opponent to be the winner, and <B>drawn</B> declares the game drawn. Don't confuse this with draw, which is a command for drawing cards. The lost command is an alias for resign, to be used when a player has already lost without resigning.
<P>I have added the <B>alias</B> command, which is quite a significant new command that will change how presets are developed. It significantly reduces the need to create new sets and to use the Custom Board rendering method. This command lets you create aliases for piece and coordinate labels, which players may use for entering moves in place of the internal representations used by Game Courier. Heretofore, internal and external representations have been identical. Now they may be separated. Here are some examples for how this can be used:</p>
<P>I have added the following line to the Shogi presets:</P>
<PRE>
alias +p t +n y +l m +s v +r d +b h +P T +N Y +L M +S V +R D +B H;
</PRE>
<P>This provides more intuitive labels for promoted pieces. Each promoted piece is now represented to the players as a plus sign before the type of piece it is the promoted form of. For backwards compatibility with pre-existing games, the internal representations still work. But the new ones may now be used, and they are what show up in tooltip text when you place your pointer over a piece.</P>
<P>I have added the following line to the Grotesque Chess preset:</P>
<PRE>
alias e a E A g m G M;
</PRE>
<P>This allows the use of e and E for the Equerry and the use of g and G for the Guard.</P>
<P>If I were to do an Omega Chess preset, I could use the usual rank and file system to define the board and then use the alias command to create aliases for the four corner squares. Previously, I would have had to settle for not using the official names for those squares or for figuring out how to enforce rules with the Custom Board method, which would be difficult. But now by distinguishing between internal and external coordinate systems, I can use an internal representation that is perfectly logical while allowing players to use the official coordinate system for a game. Likewise, I could now make a preset that enforces the rules for Glinski's Hexagonal Chess and that also lets players use its official coordinate system, which is unsuitable for simple mathematical descriptions of piece movement.</P>
Excellent addition that will make play and presentation more intuitive and appealing. Thanks!
Oh yes, this is a great addition for so many reasons... Thanks! I'm especially pleased that pieces can now be represented by the correct letters for the game, without requiring a proliferation of piece sets. The ability to use the plus-sign in the name for shogi pieces is a very nice touch, too. I would like to suggest something, though. Right now, when moving a piece you can either enter the piece type ('P e2-e4') or not ('e2-e4'). I always do the former, because it makes it easier for me to keep track of games. Some opponenets do, some do not. I would be nice if, when entering a simple single-move, like 'e2-e4', it would automatically add the 'P' or 'p'. Thanks for the consideration. You have done a lot of good work on improving the Game code recently! I need to get to work on presets using the new features for wildebeest chess, lions & unicorns chess, and others.
Game Courier can now render boards as GIF files. I have also programmed the GIF and PNG rendering methods to be able to resize images with little or no distortion to the image. Previously, a resized PNG file would be very ugly, but no more. Resized GIF files get the palette reduced back to 256 colors and are dithered. Resized PNG files make use of the PNG format's ability to handle true color images. This results in no distortion but also a larger file size than a resized GIF or JPG. Although the PNG method can handle true color images, it will normally start out as a small-palette image. So JPG is better if you are using a JPG background for your board.
Can one develop a javaboard type application for game courier, from which one may play just by mouse clicking. You already have similar type of system for computer play.
Not without a lot of work. The Java applets on this site were all written by other programmers, none of whom have worked on Game Courier, and I, the creator of Game Courier, have no experience programming in Java.
I have just added a recolor command and a color operator. These are for manipulating and reading the background colors of spaces. These work with color indexes, not with the actual colors seen by users. The actual colors are hardcoded into a preset and may be changed to suit a user's preferences. This gives users the freedom to choose the colors they want to use while still allowing games that change or use information on the colors of spaces. Naturally, recolor and color are of use only with boards based on a set of colors. They will not be useful with boards based on graphic images.
I am attempting to change the name of my recent submission from 'Chieftain Chess with Preset' to 'Chieftain Chess', now that a preset page is available. I am also trying to indicate it is multi-player, with 1-4 players per side, for a total of 2-8 players. I seem to be having 2 problems. First, when I try to do the name change, I get this error message: Error performing query: Duplicate entry 'MSchieftainchess' for key 1 Second, is there a way to indicate a range in the number of players per side? I will put in '1-4' and '2-8', but what comes up is '1' and '2'. Any information or assistance will be greatly appreciated.
I've changed the name. I will look into the problem you had changing the name. As to the number of players, there is currently no way to specify a range other than to make two separate index entries. I will look into improving this aspect of the indexing.
David, thank you very much. It's gratifying to know that it's not *always* me when it comes to computer-type problems. Now, if only my son would believe that... And thanks for looking into making the number of players more flexible. I also appreciate the efforts that have already been made to make indexing more useful for people like me. [Finally, I was thinking of making a mixed 2D-4D version of this game...]
I am interested in creating a game, but I am not sure it is possible. From what I see in the developer's guide, I do not see what I need. This is a chess-type game, also with a deck of cards. The deck of 52 cards would be shuffled, and four would be drawn and placed out for either player to use. When a card is played, it would be replaced by the next card drawn from the deck. When the last card is drawn, that is it, no more cards. Can anyone think of a way to do this with Game Courier?
Try this. It is probably best to do this through programmed automation, not with user-entered commands. On each move, each player draws all the cards from the discard pile, and if the discard pile has any fewer than four, he draws the rest from the deck. This may require a loop that draws one card at a time, checking each time whether the discard pile is empty. When a player ends his turn, he discards the rest of his hand. This allows his opponent to pick up what is left of his hand.
Maybe that won't work, because played cards also go to the discard pile. The place and displace commands might be helpful for what you want. But I might just have to modify the commands used for cards. By the way, all the card commands are described in the User's Guide, not here.
Oh, ok. Thanks, Fergus. I was wondering why I didn't see the card commands. I looked at presets for other games, but they didn't seem to do what I want. I'll look at the user's guide when I get a chance but it will probably be a few days before I get to it. No hurry anyway. Thanks for the help!
Under 'User Defined Functions,' I believe the argument placeholders really are numbered starting at #0 now, contrary to the present instructions.
25 comments displayed
Permalink to the exact comments currently displayed.