🕸📝Fergus Duniho wrote on Sat, Nov 21, 2015 12:41 PM UTC:
I seem to have gotten it to work now. I changed
def P
remove #ep
checkleap #0 #1 1 1
and == var ep join filename #1 rankname #0
or and checkatwostep #0 #1 0 1 0 1 == rankname #0 #wpr
or checkleap #0 #1 0 1
and empty #1
or and islower space #1 checkleap #0 #1 1 1
and > rank #1 rank #0;
to this
def P
remove var ep
and checkleap #0 #1 1 1
and == var ep join filename #1 rankname #0
or and checkatwostep #0 #1 0 1 0 1 == rankname #0 #wpr
or checkleap #0 #1 0 1
and empty #1
or and islower space #1 checkleap #0 #1 1 1
and > rank #1 rank #0;
Remember that Game Courier reads all of this backwards, and this is just one of two Pawn functions. The first change I made was to the logic of the function. I put an and in front of the second to last operation, checkleap #0 #1 1 1, so that nothing would be left on the stack when it got to the last operation. Since it still didn't work, I changed #ep to var ep. That worked. Now, why would I need var ep but get away with using #wpr. The difference is that wpr is effectively a constant, keeping the same value throughout execution of the program. So, when I define the function, wpr already has the value I will need it to have whenever I use the function. But ep is a true variable whose value keeps changing. To make sure the function uses its current value, I need to use var ep instead of #ep.
The remove built-in function is a new one for removing a piece from a space. It exits automatically with the value of an assignment to '@'. Most built-in functions do not change anything, focusing instead on returning values. But I wanted to check possible Pawn moves with a function alone instead of using a subroutine.
I seem to have gotten it to work now. I changed
Remember that Game Courier reads all of this backwards, and this is just one of two Pawn functions. The first change I made was to the logic of the function. I put an and in front of the second to last operation,
checkleap #0 #1 1 1
, so that nothing would be left on the stack when it got to the last operation. Since it still didn't work, I changed#ep
tovar ep
. That worked. Now, why would I needvar ep
but get away with using#wpr
. The difference is that wpr is effectively a constant, keeping the same value throughout execution of the program. So, when I define the function,wpr
already has the value I will need it to have whenever I use the function. Butep
is a true variable whose value keeps changing. To make sure the function uses its current value, I need to usevar ep
instead of#ep
.The
remove
built-in function is a new one for removing a piece from a space. It exits automatically with the value of an assignment to '@'. Most built-in functions do not change anything, focusing instead on returning values. But I wanted to check possible Pawn moves with a function alone instead of using a subroutine.