Help with moves Log Out | Topics | Search
Moderators | Register | Edit Profile

Zillions of Games Discussion Forum » Designing Games for Zillions » Help with moves « Previous Next »

Author Message
Michael Asher (Mike)
Posted on Sunday, March 07, 2004 - 2:14 pm:   

Hi - Please can anyone help me i'm new to Zillions and have the following problems (these may be easy to solve but their driving me mad,) I carn't work out the following moves.

1 - How can I have pieces which are able to capture more than one peice if the enemy peices are in a line, eg three peices on a1, a2 and a3 could all be captured in one move from a piece on a8.
2 - How can you capture a piece, from distance and not move, eg. An archer on a1 could capture an enemy peice on a4, but the Archer does not move.

Thanks for any advice
Sean Duggan (Dream)
Posted on Monday, March 08, 2004 - 7:02 am:   

I don't have my copy of ZoG in front of me, so I can't guarentee this, but these should work:

(define CaptureInLine
$1 (while not-friend? capture add $1)
)

Your piece can move along that direction until it runs into a friendly piece, captureing all spots in between. The "capture" will generate extra notation which can be somewhat avoided by replacing it with "(if enemy? capture)". Other conditions such as disallowing spaces will take more logic, but it shouldn't be so bad. For instance, if you want to only allow your piece to start attacking an adjacent piece and not be able to continue over spaces:

(define AnotherLineCapture
$1 (while enemy? capture add $1)
)

Or if he can move over spaces but cannot traverse space after he starts capturing:

(define YetAnotherLineCapture
$1 (while empty? $1)
(while enemy? capture add $1)
)

As for attacking from a distance, one way to do it is to move your piece to that spot, set a capture flag, set the "to" flag, then return to your original spot and set your "add".

(define CaptureFourAway
$1 $1 $1 $1 capture to (reverse $1) (reverse $1) (reverse $1) (reverse $1) add
)

Unfortunately, that's dealing more with commands I don't have memorized, including the "reverse" command, which may be an entirely different name. ^_^ But that should be enough to get you started. Tell me how well it works.
Jeff Mallett (Jeffm)
Posted on Tuesday, March 09, 2004 - 8:49 am:   

>that's dealing more with commands I don't have memorized,
>including the "reverse" command, which may be an entirely different name.

Yup, it's "opposite".

Alternate ways of returning to the original spot include "go from" and "back"/"mark".
Michael Asher (Mike)
Posted on Tuesday, March 09, 2004 - 1:58 pm:   

Thanks for the comments, but when I try these macro's in both cases the capturing piece is also removed from the board - any ideas?
Sean Duggan (Dream)
Posted on Tuesday, March 09, 2004 - 2:45 pm:   

*wry grin* Something I found out last night. The problem is that the capture flag is being set on the square on which the piece is landing. The "Archer" code doesn't work either. Back to the drawing board, I guess. I tried to post that it didn't work last night but it wasn't accepting my username/password.
Jeff Mallett (Jeffm)
Posted on Tuesday, March 09, 2004 - 3:58 pm:   

For #1, get to each position you want to capture and do "capture", except for the last one, where you do "add". This will move the piece to the position occupied by the last piece, if that's what you want. Don't use "add" until you've used "capture" on all the other squares. The list of captures is cleared once an "add" takes place. (For more info see "When Move Data Is Reset" in the "The Internals of Movement" in the Language Reference.)

For #2, there shouldn't be a "to" in the CaptureFourAway macro. The "to" says where you want the moving piece to end up, and you don't want it to move.
Michael Asher (Mike)
Posted on Saturday, March 13, 2004 - 1:58 pm:   

For 1 - how can you mark each square for capture?, however I use the capture command I still end up capturing the single peice. The best I have got is to use "capture opposite" which takes the add square and the previous square, but it won't capture any further squares.

For 2 - Even if I remove the "to" command the capturing peice is still removed from the board
Karl Scherer (Karl)
Posted on Saturday, March 13, 2004 - 7:16 pm:   

You only write a 'capture' command
when you are on a position whose piece you want to capture.
Karl Scherer (Karl)
Posted on Saturday, March 13, 2004 - 7:18 pm:   

You only write (capture x)
when x is the position or the direction of the
position that you want to capture.
Jeff Mallett (Jeffm)
Posted on Saturday, March 13, 2004 - 9:18 pm:   

>For 1 - how can you mark each square for capture?

By doing "capture" on that square.

>however I use the capture command I still end
>up capturing the single peice.

You're probably doing a bunch of captures on the same square? We'd have to see the code.

>For 2 - Even if I remove the "to" command the
>capturing peice is still removed from the board

I've been investigating this today. It's a Zillions display bug that the original square isn't being redrawn! The capturing piece is not actually being removed from the board. You can see that by looking at the status bar when your mouse is over the piece. In fact, if you move another window over Zillions and then uncover Zillions again the piece will be redrawn where it should be.

Strange that I don't have a report of this bug before. I checked v.1.3.1 and it has the same bug, so it's been there forever. I guess not many people have moves that don't move the piece. I will fix this in the next version.

In the mean time, a kludge to work around it is:

(define CaptureFourAway (create $1 $1 $1 $1 capture add))

This will destroy the capturing piece, but also spawn a new piece where the capturing piece left from.
Sean Duggan (Dream)
Posted on Saturday, March 13, 2004 - 11:51 pm:   

I think the issue he's running into is he's trying to use code like mine where there's a capture followed by an add. If you only allow a piece to go the full distance of the board, it's easy to write the move as you set all the captures until the last square, where you put an add. But to allow your piece to stop at any position before then... you'd have to either write a seperate Macro for each movement, or find someone way of, at each position, drawing a line of captures back to the starting position, then moving back and doing an add. Unless someone can offer an easier way to do that?
Michael Asher (Mike)
Posted on Monday, March 15, 2004 - 2:24 am:   

The capturefouraway works fine thanks, but I still have a problem with tha captureinline. The last mailer had it right, I need to find a way to mark the start and end of a move and capture all the peices in between.
Jeff Mallett (Jeffm)
Posted on Monday, March 15, 2004 - 12:06 pm:   

It sounds like you're working with a chess board. So define capture inline macros up to capture-7-inline:

(define capture-2-inline (
$1 (if enemy? capture)
$1 (if empty? add)
))

(define capture-3-inline (
$1 (if enemy? capture)
$1 (if enemy? capture)
$1 (if empty? add)
))

etc.

Each one of these macros moves a certain distance in the direction that you pass. For example, a move from a1 to a8 would use the capture-7-inline macro passing n (north).

In the "moves" block for the piece, do:

(capture-2-inline n)
(capture-3-inline n)

etc.

This may need to be tweaked for your rules, e.g. I don't know if a jumping piece is also allowed to capture on the square it lands on, but I hope this gives you a pretty good idea of how to do it.
Jeff Mallett (Jeffm)
Posted on Tuesday, March 16, 2004 - 1:30 pm:   

P.S. Regarding #2 if you don't use the create, i.e. you have something like
(define CaptureFourAway (to $1 $1 $1 $1 capture add))
the display bug only occurs if you actually try to drag the archer piece to capture square. If you simply click on the capture square, which is a normal way of playing moves that don't move in Zillions, the move will be made on the board as expected.
Michael Asher (Mike)
Posted on Tuesday, March 16, 2004 - 4:17 pm:   

Thanks for the help, I have been able to use these to solve the problems in my game - Thanks
Keith Carter (Keithc)
Posted on Friday, September 01, 2006 - 10:31 pm:   

I am looking for some advice on getting a move definition to do what I want instead of just mostly what I want. In this game a player is allowed to drop a piece on the board if two conditions are met: 1) the space is empty; 2) There is at most one friendly or enemy piece adjacent (orthogonally) to the target space.

(define place1 ( (verify empty?
(or
(and (empty? $1) (empty? $2) (empty? $3) )
(and (empty? $1) (empty? $2) (empty? $4) )
(and (empty? $1) (empty? $3) (empty? $4) )
(and (empty? $2) (empty? $3) (empty? $4) )
))
add))

This works in the center of the board, does not work at all in the corners and does not work right with edge spaces. It seems that if empty tests in a direction that is off the board then the result is not empty even though there is no friendly or enemy piece there. How do I get around this?
Mats W (Kålroten)
Posted on Saturday, September 02, 2006 - 8:06 am:   

How about this?

(define place1 ( (verify empty?)
(set-flag found1 false) (set-flag found2 false)
(if (not(or(empty? $1)(not-on-board? $1))
(set-flag found1 true)
)
(if (not(or(empty? $2)(not-on-board? $2))
(if (flag? found1) (set-flag found2 true)
else (set-flag found1 true))
)
(if (not(or(empty? $3)(not-on-board? $3))
(if (flag? found1) (set-flag found2 true)
else (set-flag found1 true))
)
(if (not(or(empty? $4)(not-on-board? $4))
(if (flag? found1) (set-flag found2 true)
else (set-flag found1 true))
)
(verify (not-flag? found2))
))

Mats
Greg Schmidt (Gschmidt)
Posted on Saturday, September 02, 2006 - 9:56 am:   

>This works in the center of the board, does not work at all in the corners and does not work right with edge spaces. It seems that if empty tests in a direction that is off the board then the result is not empty even though there is no friendly or enemy piece there. How do I get around this?

I haven't tried it, but would something like the following work?

(define place1 ( (verify empty?
(or
(and (not (piece? $1)) (not (piece? $2)) (not (piece? $3)) )
(and (not (piece? $1)) (not (piece? $2)) (not (piece? $4)) )
(and (not (piece? $1)) (not (piece? $3)) (not (piece? $4)) )
(and (not (piece? $2)) (not (piece? $3)) (not (piece? $4)) )
))
add))
Keith Carter (Keithc)
Posted on Saturday, September 02, 2006 - 12:31 pm:   

Thanks folks I will give the answers a try after work today.

Mats: does an add go in before the last two parentheses?
Keith Carter (Keithc)
Posted on Saturday, September 02, 2006 - 9:54 pm:   

I have tried both suggestions.

Greg: I liked the simplicity of your suggestion. Much easier for me to understand as I have never written a macro that used flags. It seemed as if I had simply chosen the wrong keyword. Alas, Zillions looks for a piece type following piece? I might be able to modify things so the search is for enemy? or friendly?.

Mats: Your idea worked with some minor editing thank you. Here is the final macro:

(define place1 ( (verify empty?)
(set-flag found1 false) (set-flag found2 false)
(if (not(or(empty? $1)(not-on-board? $1)))
(set-flag found1 true)
)
(if (not(or(empty? $2)(not-on-board? $2)))
(if (flag? found1) (set-flag found2 true)
else (set-flag found1 true))
)
(if (not(or(empty? $3)(not-on-board? $3)))
(if (flag? found1) (set-flag found2 true)
else (set-flag found1 true))
)
(if (not(or(empty? $4)(not-on-board? $4)))
(if (flag? found1) (set-flag found2 true)
else (set-flag found1 true))
)
(verify (not-flag? found2))
add))
Keith Carter (Keithc)
Posted on Sunday, September 03, 2006 - 10:47 pm:   

I have been making good progress on my zrf script, however, I have run into another stumbling block. The following macro works:

(define place1_25 (
(verify empty?) mark $1 (verify (piece? 2_pip)) back $2 (verify (piece? 5_pip)) back

((verify (not-on-board? $3)) $3 (verify (piece? 5_pip)) (verify (piece? 6_pip)) back)
add))

The problem I have run into is that I need the second verify sequence to be an OR statement. I looked at the help file and working examples in other zrf files. It does not look like it should be difficult to set up an OR statment and yet hours and hours of trying to imbed it in one only produces a parser error at the OR. For example:

(define place1_25 (
(verify empty?) mark $1 (verify (piece? 2_pip)) back $2 (verify (piece? 5_pip)) back
(OR
((verify (not-on-board? $3)) $3 (verify (piece? 5_pip)) (verify (piece? 6_pip)) back)
); end OR
add))

And this:
(define place1_25 (
(verify empty?) mark $1 (verify (piece? 2_pip)) back $2 (verify (piece? 5_pip)) back
(OR(
((verify (not-on-board? $3)) $3 (verify (piece? 5_pip)) (verify (piece? 6_pip)) back)
)); end OR
add))

And this:
(define place1_25 (
(verify empty?) mark $1 (verify (piece? 2_pip)) back $2 (verify (piece? 5_pip)) back
(OR(
((verify (not-on-board? $3)) ($3 (verify (piece? 5_pip))) ((verify (piece? 6_pip)) back))
)); end OR
add))
All produce the same parser error at (OR. There must me something basic I am not understanding about the syntax for an OR or an AND conditional sequence.

Help.
Mats W (Kålroten)
Posted on Monday, September 04, 2006 - 12:23 am:   

But or-statements are written in lowercase: 'or'.

Moreover, you have made a programming error(?) there. You first verify that the position is *not* on-board and then you go to that position. This should not be possible.
(verify (not-on-board? $3)) $3

By the way, maybe I don't understand your code. What do you want to do? An or-statement only produces a true or false. So after the 'back' you will get 'true' or 'false'. That does nothing and is not legitimate code, is it? An or-statement could be *inside* a verify-statement, but not standalone like this. I am uncertain what you want to check. Do you want the second verify statements to be or-ed with first part? Or do you want the second part's statements to be or-ed internally? Then you can write something like this:

$3 (verify on-board?) (verify (or (piece? 5_pip) (piece? 6_pip))) back

Mats Winther
Keith Carter (Keithc)
Posted on Monday, September 04, 2006 - 12:45 pm:   

The game that I am trying to do uses numeric value of adjacent spaces to determine what pieces may be played where and what pieces are captured. The game is Cephalopod and the rules can be found here: http://www.marksteeregames.com/Cephalopod_rules.pdf , I have permission from Mark for a Zillions version.

1. OR vs or - I put ‘or’ in upper case in the post to make it stand out. It is in lower case in my zrf file. Is Zillions case sensative?

2. A true or false that does nothing may be my problem. What I was trying to do was to determine that the spaces adjacent to the one to be played on have a two and a five and then determine that the other adjacent spaces have either a five, a six, or are off board. The eventual macro will be more complex than I presented so far. I was having so much trouble with syntax when trying to put together the whole thing that I was trying to get a simpler version working and then build up to what I really needed. Eventually I expect to end up with something like this:
(define place1_25 (
(verify empty?) mark $1 (verify (piece? 2_pip)) back $2 (verify (piece? 5_pip)) back
(and
(or
((verify (not-on-board? $3)) $3 (verify (piece? 5_pip)) (verify (piece? 6_pip)) back)
); end or
(or
((verify (not-on-board? $4)) $4 (verify (piece? 5_pip)) (verify (piece? 6_pip)) back)
add))
); end or
); end and
add))

3. It is true that the space examined can not be both on and off board. It also can hold a five and a six. I need to have only one of the three conditions be true for two different directions.

Thank you for the help Mats. I am sure you or Karl could have whipped this one out in an afternoon.

Keith
Keith Carter (Keithc)
Posted on Monday, September 04, 2006 - 10:24 pm:   

Whoops. #3 should be:

3. It is true that the space examined can not be both on and off board. It also can not hold a five and a six. Off the three parts of the or test only one at most will be true for the two directions that do not have a two and a five.
Keith Carter (Keithc)
Posted on Wednesday, September 06, 2006 - 10:01 pm:   

My syntax problem was having a bare or statement. I kept trying to fix it by changing things after the or when I needed a conditional before it.

The working syntax follows though there is a logi error in it.

(define place7_25 (
(verify empty?) mark $1 (verify (piece? 2_pip)) back $2 (verify (piece? 5_pip)) back $3
(if
(or
(piece? 5_pip) (piece? 6_pip) (not-on-board? $3)
) back $4
(if
(or
(piece? 5_pip) (piece? 6_pip) (not-on-board? $3)
)
back )add)))

I want to test the same space for a 5_pip, 6_pip, or being off board. However, not-on-board requires a direction which moves me off the space I tested for a 5-pip or a 6_pip. I have tried to incorporate a back or an additional move with the not-on-board but always get a syntax error.

How would I write an or statement to test the same space all three ways?
Mats W (Kålroten)
Posted on Thursday, September 07, 2006 - 12:36 am:   

I'm not sure I understand you correctly, but you shouldn't need to move to the actual space and go back again(?). This is very wasteful. Maybe something like this instead.

(define place7_25 (
(verify empty?)
(verify (and(piece? 2_pip $1) (piece? 5_pip $2)))
(if
(or
(or (piece? 5_pip $3 ) (piece? 6_pip $3) (not-on-board? $3) )
(or (piece? 5_pip $4) (piece? 6_pip $4) (not-on-board? $4) ))

add

)
))

Mats
Keith Carter (Keithc)
Posted on Friday, December 15, 2006 - 6:17 pm:   

BTW, Thank you for all the previous help. The last thing I got help on is used in the game Cephalopod.

I need help again.
The following macro moves a slides a piece across empty squares but does not allow the piece to enter position e5.

(define Slide ($1 (while (and empty? (not-position? e5) ) add $1 ) ))

I want to be able to modify this so that e5 can be skipped over if it is empty and the slide move continued on the other side.
Mats W (Kålroten)
Posted on Saturday, December 16, 2006 - 2:13 am:   

Maybe this will work:
(define Slide ($1 (while empty? (if (not-position? e5) add) $1 ) ) )
/Mats
Keith Carter (Keithc)
Posted on Saturday, December 16, 2006 - 7:26 am:   

Thats it. Thank you Mats. It also increases my understanding of how While works.

Keith

Add Your Message Here
Post:
Username: Posting Information:
This is a private posting area. Only registered users and moderators may post messages here.
Password:
Options: Enable HTML code in message
Automatically activate URLs in message
Action: