# Comments/Ratings for a Single Item

GAME Code uses prefix notation, not infix notation. This means the operator comes first. Where it looks like infix notation, the operator is actually working with only one operand. In particular, the logical operators can work with either one or two operands. This allows you to string them together as though you were using infix notation, but it doesn't work the same way as infix notation would.

Hei Fergus,

About the anglican bishop, I remember noticing somthing as I had played a few games a few months back. Quite a nice game, by the way.

I almost understand the code you posted although I still have trouble with the order of operations as the instructions:

operator p q , p operator q are both valid, and that is a bit troubelling to me.

I know where to read material on this though. If I still have trouble I'll then come back to you :)!

The Bishop in Caissa Britannia had used this code:

def B checkleap #0 #1 1 0 and nor capture nor empty #0 empty #1 or checkride #0 #1 1 1;

Based on what I wrote earlier, this code is incorrect. In a test I ran, this code allowed the Bishop to make a non-capturing orthogonal move, but it did not display it among the available legal moves. So, it seems to be working for actual moves, but it is not working for potential moves. With that in mind, I have changed it to this:

def B checkleap #0 #1 1 0 and cond empty #0 not capture empty #1 or checkride #0 #1 1 1;

Running the same test, this code worked correctly for both potential and actual moves.

Because the function is going to be used for both actual and potential moves, it has to be able to handle both. For a potential move, #0 will still be occupied, and #1 must be empty, but for an actual move, #0 will be empty, and the move must not be a capture. So, depending on the value of #0, you want to confirm either that #1 is empty or that the move is not a capture. The portion of your code devoted to this looks like this:

and nor capture nor empty #0 empty #1

First, "nor empty #0 empty #1" returns true if #0 and #1 are both false. This value is used as the second value for the next nor. So, "nor capture nor empty #0 empty #1" returns true if #0 and #1 are not both false and it is not a capture. This does not seem to be what you want, since it will always require a false value for capture. But this matters only when #0 is empty, and it could throw off the evaluation of a potential move.

It would be better to use this:

and cond empty #0 not capture empty #1

This returns "not capture" if #0 is empty or "empty #1" if #0 is not empty. The and requires this value to be true for it to continue. Note that this test has to be done only once. So your code can look like this:

checkleap #0 #1 3 0 or checkleap #0 #1 2 2 and cond empty #0 not capture empty #1 or checkleap #0 #1 2 1;

@Fergus

I'm not confident enough to be sure about this, so I'm asking:

Is the following code fine for verifying if a piece that can perform moves only as and alfil and ThreeLeaper (or Trebuchet as is also called) but can both move and capture as a regular knight ?

checkleap #0 #1 3 0 and nor capture nor empty #0 empty #1 or checkleap #0 #1 2 2 and nor capture nor empty #0 empty #1 or checkleap #0 #1 2 1;

As a sorce of inspiration I had used your anglican bishop code in Caissa Britania :)!

Thanks!...

sign and - are two seperate operations. The - operator does subtraction. The sign operator indicates whether the result of the subtraction is positive, negative, or zero by returning 1, -1, or 0. In this context, this value is being used as a value for the where operator, which takes three arguments and returns a coordinate. It is the same coordinate each time. The space in question is the diagonal space it must pass through before turning to move in an orthogonal direction. By using sign twice, it has divided the board into four quadrants, and it has identified the only diagonally adjacent space it could have passed through to reach the space legal movement to is being checked for. If this space is empty, it then checks whether orthogonal movement from that space could reach the destination space.

Hi Fergus,

I don't seem to understand squat out of the griffin code :(!

First I don't understand what "sign -" does. I'm thinking that it means that both the rank and file must vary by 1 in absolute value. But I don't see the intricacies :)!

The aanca code seems roughly the same albeit for an abs function :(!

I get the same feeling :)!

So when the time please fill me in to some details, please!

8 comments displayed

**Permalink** to the exact comments currently displayed.

Thanks for the explanation Fergus, now it is clear to me :)!