Check out Balbo's Chess, our featured variant for October, 2024.


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

Single Comment

Interactive diagrams. (Updated!) Diagrams that interactively show piece moves.[All Comments] [Add Comment or Rating]
A. M. DeWitt wrote on Mon, Oct 21 06:14 PM UTC in reply to H. G. Muller from Sun Oct 20 03:14 PM:

Well, as you said, custom scripting is always an option. I am having trouble though when it comes to custom scripting compatibility for the AI though, probably because I set the kind variable in the Tinker() function itself. Here's the code for Raichu Shogi I use, when allowing hit-and-run captures of Lions to trigger the forced pass.

  function raichuTinker(m, d) {
    dest = board[m[3]][m[2]] & 511;
    midpoint = m[-2] > 2 ? (board[m[5]][m[4]] & 511) : 0;
    if(IsLion(dest) || IsLion(midpoint)) kind |= 64; // problem line, will be replaced with: return 5;
    return 0;
  }
  function IsLion(pieceType) { // Returns true if pieceType is a Lion
    return pieceType == 20 || pieceType == 31;
  }

Let's say that instead of setting it in the function, I want to return a value of 5 to indicate the forced pass, and set kind |= 64 elsewhere. Where should I set it?

When I tried in AlterMove(), and the Console gave the following error (this is in a local file),

Raichu Shogi.html:17 Uncaught RangeError: Maximum call stack size exceeded
    at AlterMove (Raichu Shogi.html:17:19)
    at StackMove (sourcecode.js:3068:10)
    at NextLeg (sourcecode.js:3325:22)
    at NextLeg (sourcecode.js:3328:9)
    at NewInner (sourcecode.js:3357:7)
    at NewGen (sourcecode.js:3368:3)
    at GenAll (sourcecode.js:3404:41)
    at AlphaBeta (sourcecode.js:3647:3)
    at AlphaBeta (sourcecode.js:3678:19)
    at AlphaBeta (sourcecode.js:3678:19)

, after I added an if statement telling AlterMove() to set kind |= 64 and return 0 for the normal move in the section with the Tinker() call.

  if(alter & 16) {
    var tinker = CustomScript(m, piece & 1024 ? m[3] : ranks - 1 - m[3]);
    if(tinker > 0) {
      if(tinker == 5) { if(!(kind & 64)) { kind |= 64; } return 0; }
      else return tinker;
    }
  }