Check out Janggi (Korean Chess), our featured variant for December, 2024.

Enter Your Reply

The Comment You're Replying To
H. G. Muller wrote on Tue, Jul 28, 2020 05:17 AM UTC in reply to Fergus Duniho from Mon Jul 27 10:10 PM:

OK, great. That means all all issues encountered so far are solved now, and we are ready to continue. First a summary of where we are, because I was too optimistic in declaring phase 0 finished. The code shown befor turned out only to work for simple moves; Game Courier does not like it when you try to evaluate a composit move by putting "MOVE:" in front of it, and will complain the move is malformed in that case. So it is necessary to explode composit moves into an array mvs of simple moves, and have Game Courier perform these one by one in a loop. This exploding of moves had to be done anyway for parsing the move, but it is now done before we call ParseMove, and mvs is made a global variable, so that it will also be available inside ParseMove:

sub HandleMove player:
  set mvs explode chr 59 thismove; // split at semicolons
  gosub ParseMove #player;         // syntax check and interpretation
  set k 0;
  do while < var k count var mvs:  // for all legs
    eval join "MOVE: " trim elem var k var mvs; // apply the move
    inc k;
  loop;
endsub;

For phase 0 the call to Parsemove would not yet be there. The tested and debugged code for phase 1 is:

sub ParseMove player:
  my i j parts sqrs;
  set many suicide false freedrop false promo false;
  set parts explode ws trim elem 0 var mvs;            // split first move at space
  set i count var parts;
  if > var i 2:                                        // too many parts
    die "move must be piece ID plus board step";
  endif;
  set sqrs explode chr 45 trim elem dec var i var parts; // split last part at hyphen
  if != 2 count var sqrs:                                // must give 2 squares
    die "board step does not mention two squares";
  endif;
  set ori elem 0 var sqrs;                             // first is origin
  set desti elem 1 var sqrs;                           // second is dest
  if not onboard var ori or not onboard var desti:     // check if these are valid
    die "the board isn't that large";
  endif;
  set mover space var ori;                             // look what we move
  if != var mover elem 0 var parts and == 1 var i:     // input move mentioned another piece
    die "there is another piece there";
  endif;
  if not cond #player islower var mover isupper var mover: // it is not our piece
    die "no such piece there";
  endif;
  set j 1;                                             // prepare to do side effects
  do while < var j count var mvs:                      // for each of those
    set parts explode chr 45 trim elem var j var mvs;  // split them at hyphen
    if != 2 count var parts:                           // must give 2 parts
      die "malformed move " elem var j var mvs;
    elseif not onboard elem 1 var parts:               // second part must be valid square
      die "second leg goes off board";
    elseif onboard elem 0 var parts:                   // additional move for locust capture
      if != var desti elem 0 var parts:                // must start from destination of first move
        die "you can only continue with same piece";
      endif;
      if #suicide:                                     // for now only one side efect
        die "cannot have more than one locust victim";
      endif;
      set suicide var desti;                           // old dest was actually locust square
      set desti elem 1 var parts;
    elseif == var desti elem 1 var parts:              // drop on dest: promotion
      set promo elem 0 var parts;
    elseif == @ elem 0 var parts:                      // drop of empty: locust square
      if #suicide:
        die "cannot have more than one locust victim";
      endif;
      set suicide elem 1 var parts;
    else:                                              // drop of piece: unload
      if #freedrop:
        die "cannot kick more than one piece";
      endif;
      set dropped elem 0 var parts;
      set freedrop elem 1 var parts;
    endif;
    inc j;                                             // go on with next side effect
  loop;
endsub;

This extracts values for ori, desti, mover, promo, suicide, freedrop and dropped from the move. The first three from the (mandatory) first move. The others describe the optionally following moves of the turn, and are set to 0 by default. These values are not yet used in phase 1; the only observable effect is that the preset will now enforce turn order, as it no longer accepts moving of opponent pieces. It still accepts capture of own pieces, as XBetza can allow that. So this must be left for move generator to check out.

Next step is to take care of implied side effects: it should be possible (even mandatory) to enter castling and e.p. capture as a simple move. In phase 2 we will do this for castling. Phase 3 will then address e.p. capture, which is more complex, because it also has to address the creation of e.p. rights.

 


Edit Form
Conduct Guidelines
This is a Chess variants website, not a general forum.
Please limit your comments to Chess variants or the operation of this site.
Keep this website a safe space for Chess variant hobbyists of all stripes.
Because we want people to feel comfortable here no matter what their political or religious beliefs might be, we ask you to avoid discussing politics, religion, or other controversial subjects here. No matter how passionately you feel about any of these subjects, just take it someplace else.
Avoid Inflammatory Comments
If you are feeling anger, keep it to yourself until you calm down. Avoid insulting, blaming, or attacking someone you are angry with. Focus criticisms on ideas rather than people, and understand that criticisms of your ideas are not personal attacks and do not justify an inflammatory response.
Quick Markdown Guide

By default, new comments may be entered as Markdown, simple markup syntax designed to be readable and not look like markup. Comments stored as Markdown will be converted to HTML by Parsedown before displaying them. This follows the Github Flavored Markdown Spec with support for Markdown Extra. For a good overview of Markdown in general, check out the Markdown Guide. Here is a quick comparison of some commonly used Markdown with the rendered result:

Top level header: <H1>

Block quote

Second paragraph in block quote

First Paragraph of response. Italics, bold, and bold italics.

Second Paragraph after blank line. Here is some HTML code mixed in with the Markdown, and here is the same <U>HTML code</U> enclosed by backticks.

Secondary Header: <H2>

  • Unordered list item
  • Second unordered list item
  • New unordered list
    • Nested list item

Third Level header <H3>

  1. An ordered list item.
  2. A second ordered list item with the same number.
  3. A third ordered list item.
Here is some preformatted text.
  This line begins with some indentation.
    This begins with even more indentation.
And this line has no indentation.

Alt text for a graphic image

A definition list
A list of terms, each with one or more definitions following it.
An HTML construct using the tags <DL>, <DT> and <DD>.
A term
Its definition after a colon.
A second definition.
A third definition.
Another term following a blank line
The definition of that term.