| Author |
Message |
Eduardo Loureiro Jr. (Eloureiro)
| | Posted on Wednesday, January 22, 2003 - 4:28 pm: | |
Hi! When I use the following code for capturing an enemy piece by putting a piece between that enemy piece and a friend piece, it works all right: (define carimba (if (and (enemy? $1) (friend? (opposite $1)) (not-marked? (opposite $1))) (capture $1) ) ) (define carimba-all (carimba ne) (carimba nw) (carimba se) (carimba sw) ) But if I try to capture an enemy piece not one direction, but two directions far, with the following code, then I receive an error message: (define carimba (if (and (enemy? $1) (friend? (opposite $1)) (not-marked? (opposite $1))) (capture $1) ) ) (define carimba2 (if (and (enemy? $1 $2) (friend? (opposite $1 $2)) (not-marked? (opposite $1 $2))) (capture $1 $2) ) ) (define carimba-all (carimba ne) (carimba nw) (carimba se) (carimba sw) (carimba2 ne ne) (carimba2 nw nw) (carimba2 se se) (carimba2 sw sw) ) What's the problem here? Zillions doesn't accept this kind of double (or eventually multiple) "opposite"? Or am I meking another mistake? Sorry if it is a silly question. I'm just trying to learn the language by making my first game. Thanks in advance, Eduardo |
Jeff Mallett (Jeffm)
| | Posted on Thursday, January 23, 2003 - 12:03 am: | |
Correct, Zillions wouldn't understand (opposite ne ne), or (enemy? ne ne) for that matter. You'll have to actually take a step that direction. There's the concept of the current position. For instance, ne ; take one step ne (if (enemy? ne) ... would test whether there is an enemy two steps to the "ne". Remember to take a back up a step when you're done, i.e. (opposite ne), if necessary. Also, note that Zillions will exit the move block if you move off the board. For example, if you step "ne" and that is off the board, no move will be generated. That's probably what you want. But if you don't want that, use (on-board? ne) to check whether it's on the board before stepping that way. |
Dan Troyka (Dtroyka)
| | Posted on Thursday, January 23, 2003 - 6:33 am: | |
In this case you can also define directions that are two steps removed. I.e., in addition to (ne 1 -1) in the direction statement, include (NE 2 -2). If you do this for all four diagonal directions, each square will have a direct link to the the square two diagonal steps away. The link skips over and completely ignores the intervening diagonal square. The carimba macro can then take the form: (define carimba-all (carimba ne) (carimba nw) (carimba se) (carimba sw) (carimba2 NE) (carimba2 NW) (carimba2 SE) (carimba2 SW) ) This also avoids the problem of moving the current position off the board. |
Eduardo Loureiro Jr. (Eloureiro)
| | Posted on Friday, January 24, 2003 - 4:11 pm: | |
Thanks, Jeff and Dan! I've made it with "doubled" directions. If I ever finish this game, you guys will deserve a mention in its history. Cheers, Eduardo |
|