Simple Question Log Out | Topics | Search
Moderators | Register | Edit Profile

Zillions of Games Discussion Forum » Designing Games for Zillions » Simple Question « Previous Next »

Author Message
JD (Jdbry)
Posted on Monday, January 05, 2004 - 1:02 pm:   

Greetings, I am new to ZOG, I have a very simple question that I'm sure I'm over looking something very simple. I have created a new move defintion for a piece as following.

(define Ranger-shift1 ($1 (verify not-friend?) add))
(define Ranger-shift2 ($1 $2 (verify not-friend?) add))
(define Ranger-shift3 ($1 $2 $3 (verify not-friend?) add))

In the piece info I have:

(moves
(Ranger-shift1 n)
(Ranger-shift1 e)
(Ranger-shift1 s)
(Ranger-shift1 w)
(Ranger-shift1 ne)
(Ranger-shift1 nw)
(Ranger-shift1 se)
(Ranger-shift1 sw)
(Ranger-shift2 n n)
(Ranger-shift2 e e)
(Ranger-shift2 s s)
(Ranger-shift2 w w)
(Ranger-shift2 ne ne)
(Ranger-shift2 nw nw)
(Ranger-shift2 se se)
(Ranger-shift2 sw sw)
(Ranger-shift3 n n n)
(Ranger-shift3 e e e)
(Ranger-shift3 s s s)
(Ranger-shift3 w w w)
(Ranger-shift3 ne ne ne)
(Ranger-shift3 nw nw nw)
(Ranger-shift3 se se se)
(Ranger-shift3 sw sw sw)

The piece moves exactly as it should " three in any direction" however it leaps over other pieces. Where and what is the syntaxt for adding the (verify empty) (if empty)or whatever it needs to disallow leaping? Thanks in advance for any and all help!
Keith Carter (Keithc)
Posted on Monday, January 05, 2004 - 5:48 pm:   

You need to check for the presence of an enemy piece at each step along the way. The three square move becomes:
(define Ranger-shift3 ($1 (verify not-friend?) $2 (verify not-friend?) $3 (verify not-friend?) add))

I may have mangled the parenthises but the concept is there.

This would still allow a piece to move through friendly pieces. You would need to use (verify empty? ) to have any piece block movement.
JD (Jdbry)
Posted on Monday, January 05, 2004 - 11:12 pm:   

Thanks ver much Keith!!! That does stop the leaping but now the piece will not capture any over pieces. Do I also need to define a capture somewhere?

(define Ranger-shift3 ($1 (verify not-friend?) (verify empty?) $2 (verify not-friend?) (verify empty?) $3 (verify not-friend?) (verify empty?) add))

Thanks for your help!!!
Sean Duggan (Dream)
Posted on Monday, January 05, 2004 - 11:18 pm:   

I guess the question which I'd have to ask is what exactly your planned movement is. Do you want it to jump friendly pieces? Do you want it to capture all interim enemy pieces? Please, explain what exactly this piece ought to do and we can help you better to achieve your goal.
JD (Jdbry)
Posted on Monday, January 05, 2004 - 11:44 pm:   

The piece should move one, two, or three squres in any direction and capture all enemy pieces, it should not jump pieces
Sean Duggan (Dream)
Posted on Monday, January 05, 2004 - 11:57 pm:   

The simplest way is to add captures at each point.

(define Ranger-shift3 ($1 (verify not-friend?) (verify empty?) capture $2 (verify not-friend?) (verify empty?) capture $3 (verify not-friend?) (verify empty?) add))

This adds some extra capture notation in the game log. That can be avoided using (if ... ) statements. "(if enemy? capture)" should work, I think.

Example code below for my Golem, which captures 3 people in a row assuming the last spot is occupied. Remove the "(verify not-empty?)" to have it capture three in a row whether or not the last space is occupied.

(define Golem-moveCapture
(
$1
(if not-empty? capture)
$1
(if not-empty? capture)
$1
(verify not-empty?)
add
)
)
Sean Duggan (Dream)
Posted on Monday, January 05, 2004 - 11:59 pm:   

Oh, and you'll probably have to change "not-empty?" to "enemy?" And make it non-unidirectional. ^_^ Simple enough, eh?
JD (Jdbry)
Posted on Tuesday, January 06, 2004 - 12:39 am:   

Thank you very much Sean but this doenst seem to work for me. Is there some place I can read about the proper Syntax for ZOG?
Keith Carter (Keithc)
Posted on Tuesday, January 06, 2004 - 1:45 am:   

Zillions has a language reference built in. Launch Zillions, go to the Help menu, choose the Rules File Language Reference.
Sean Duggan (Dream)
Posted on Tuesday, January 06, 2004 - 5:57 am:   

http://home.t-online.de/home/j_markmann/zrf.html is worth a look too.

Try the following:
; Allows the piece to move one to 3 moves in one direction, capturing all intermediate enemy pieces.
; Movement blocked by friendly pieces.
(define Rangermove
(
$1
(verify not-friend?)
add
(if not-empty? capture)

$1
(verify not-friend?)
add
(if not-empty? capture)

$1
(verify not-friend?)
add
)
)
JD (Jdbry)
Posted on Tuesday, January 06, 2004 - 9:53 am:   

Big thanks to both of you guys, I have somehow managed to get the piece to move and capture exactly as it should. Not really sure how I did that yet though because for some reason I was getting parse errors and cature not understood errors using your examples. I am quite sure all of the examples you guys give will work fine from scratch, but of course I have already fiddled with this code so I probably had something misdefined or some other syntax mess up. I went back and used what I had started with for the piece using Keiths sugestion for checking the presence of an enemy piece each step as follows:

($1 (verify not-friend?) $2 (verify not-friend?) $3 (verify not-friend?) add))

Thanks for the info on your page too Sean, it really helps a lot as this is the simplest piece in this varient of 9 pieces, so I will need it :-)
Thanks again for all your help, hopefully soon I will be able to share this game with all.

Any quick sugestions for limiting leaping pieces from jumping pieces that have not moved from their starting point? I know, Google is my friend; I off to read, Thanks!!!!!
Sean Duggan (Dream)
Posted on Tuesday, January 06, 2004 - 11:18 am:   

You'd probably have to set a flag on the piece to denote whether it's moved. Look at "Chess.zrf" and what they do with the king and the rook for castling ("O-O" and "O-O-O")

As for your resulting solution, that will create a piece that can jump up to two enemy pieces before capturing a third if one is present at the ending spot but is blocked by any friendly pieces. If this was your intent, then your move definition will work. ^_^

Anyhow, if you have further questions, I'd be glad to help. I went through a similar process trying to automate Fantasy Chess (http://www.chessvariants.com/diffmove.dir/fantasy.html), which was largely original pieces. Look for example code in other games that you can lift, as it will save you a lot of work. If a piece doesn't seem to be working right, or won't compile right, try putting it in its own ZRF file apart from the other pieces and see if it works. When testing a piece, check for every condition you can think of involving friendly pieces, enemy pieces, empty spaces, and board edges. And lastly, if you don't have 2.0, I highly reccomend it, as it has some very nice developments for programming and debugging.
JD (Jdbry)
Posted on Tuesday, January 06, 2004 - 2:20 pm:   

Wow, very interesting game Sean, thanks for the suggestion of putting new pieces in their own ZRF file for testing. The reason mine works with the code above is because the last one posted is only one of the moves it can make. Probably should have defined everything in one move, and I will as I learn :). The example of the O-O" and "O-O-O flags works great too, but I want mine to be able to jump friendly pieces but not enemy ones. Also need to know if it is posible to make a piece uncapturable in a special zone, by any piece other than one with the same description.
I do have 2.0, thanks for all your help!!!
JD (Jdbry)
Posted on Tuesday, January 06, 2004 - 2:35 pm:   

Would it be posible to add something like " If not friend (verify never-moved?)else add))
I'm still a little lost on the syntax.
Sean Duggan (Dream)
Posted on Wednesday, January 07, 2004 - 12:20 am:   

Well, a straightforward writing for your condition is:
(if not-friend? (verify never-moved?) else add)

However, this won't work if it hits an empty square. Plus, the only time you get results is an add for squares that don't hold friendly pieces. I'm guessing you want it to jump pieces that are friendly and have not moved, also moving over empty space. The check you'd use is below:
(verify not-enemy?) (if friend? (verify not-moved?) else add)

Then, do this after every move. For instance, for allowing up to three steps, jumping friendly pieces that have moved (note, this move cannot capture as it currently is):
(
$1 (verify not-enemy?) (if friend? (verify not-moved?) else add)
$1 (verify not-enemy?) (if friend? (verify not-moved?) else add)
$1 (verify not-enemy?) (if friend? (verify not-moved?) else add)
)

If you're not restricted to a finite number of steps, you might consider a loop.

Incidentally, on the not-being-able to capture bit, you cannot program that into the piece that is to not-be-captured. Rather, you must program it into the other pieces. For instance, in Fantasy Chess, Golems can only be killed by Adepts (and later Mercs). For every piece other than the Adept (and Merc), an add which might be a capture instead calls a macro that checks if the piece is a Golem before adding. Example:

(define CaptureAdd

; This allows the rook to only be captured by the Adept, so long as I employ it properly.
(if (not-piece? Golem) add)
)

(define slide ($1 (while empty? add $1) (verify not-friend?) (CaptureAdd)))

(piece
(name Bishop)
(help "Bishop: slides diagonally any number of squares")
(description "Bishop\A Bishop moves any number of squares on a diagonal. It may
not leap over other pieces.")
(image White "images\Chess\wbishop.bmp" Black "images\Chess\bbishop.bmp")
(moves
(slide ne)
(slide nw)
(slide se)
(slide sw)
)
)

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: