(lack of) arguments in macros Log Out | Topics | Search
Moderators | Register | Edit Profile

Zillions of Games Discussion Forum » Designing Games for Zillions » (lack of) arguments in macros « Previous Next »

Author Message
Andrew Dabrowski (Dabrowsa)
Posted on Tuesday, December 14, 2004 - 10:17 am:   

I'm interested in making variants of the game Gess. There is a Zillions version of Gess coded by L. Lynn Smith, so I thought I would start with that and modify it. The problem is I have done very little coding with Zillions, and am not a programmer by vocation, so I'm having trouble understanding Smith's code.


Currently I'm puzzled by the use of arguments in macros. There is one macro in the code that seems to use 8 arguments, but on the only 2 occasions when the macro is called no arguments at all are provided (see relevant sections of the code below).

Is there something simple I'm overlooking? Or does Zillions provide some sensible default behavior when too few arguments are provided to a macro call?


;Hacked and slashed by L. Lynn Smith
;send all comments to: llsmith@ev1.net


(define step-all-pieces
(if not-empty? cascade from $1 to (if (in-zone? kill-zone) capture) back
)
(if (not-empty? $2) cascade $2 from $1 to (if (in-zone? kill-zone) captu
re) back)
(if (empty? $2) $1 (capture $2) back)
(if (not-empty? $3) cascade $3 from $1 to (if (in-zone? kill-zone) captu
re) back)
(if (empty? $3) $1 (capture $3) back)
(if (not-empty? $4) cascade $4 from $1 to (if (in-zone? kill-zone) captu
re) back)
(if (empty? $4) $1 (capture $4) back)
(if (not-empty? $5) cascade $5 from $1 to (if (in-zone? kill-zone) captu
re) back)
(if (empty? $5) $1 (capture $5) back)
(if (not-empty? $6) cascade $6 from $1 to (if (in-zone? kill-zone) captu
re) back)
(if (not-empty? $7) cascade $7 from $1 to (if (in-zone? kill-zone) captu
re) back)
(if (not-empty? $8) cascade $8 from $1 to (if (in-zone? kill-zone) captu
re) back)


(define ortho-step
(
(check-3x3-stepper)
from
$1 to (if (in-zone? kill-zone) capture) back
(step-all-pieces)
add
)
)

(define diag-step
(
(check-3x3-stepper)
from
$1 to (if (in-zone? kill-zone) capture) back
(step-all-pieces)
add
)
)
L. Lynn Smith (Interrupt27)
Posted on Tuesday, December 14, 2004 - 10:50 am:   

Those arguments are sent by the initial calls in each piece's moves section. Since the call within the macro definition doesn't specify these values, the Zillions program falls back on those initial values.

Sorry for the shorthand.
L. Lynn Smith (Interrupt27)
Posted on Tuesday, December 14, 2004 - 3:31 pm:   

The reason for having two similar macros but named different was to aid in keeping the directions clear while coding. And it made it easier to duplicate with the subsequent multi-step calls. And it was essential that the mult-step calls be different because the orthogonal pattern needs only check three positions while the diagonal pattern needs to check five.

Because of the large number of pieces which are moved in this game, Zillions often ran into some of its limitations. Before the recent upgrade, it would reach a move generation limit with the Strength set above 4.

Still the implementation should obey all the rules and offer a fair but simple opponent. Please let me know if you work out any improvements.
Andrew Dabrowski (Dabrowsa)
Posted on Tuesday, December 14, 2004 - 10:56 pm:   

Thanks for your reply.

What confused me was the step-all-pieces macro, which isn't mentioned in the moves section. I gather now that step-all-pieces inherits the arguments from the encompassing diag-step and ortho-step macros in which it is called.

I may have overlooked it, but I don't this point of semantics is covered in the Zillions Language Reference.

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: