How to decrease the size of expanded ... Log Out | Topics | Search
Moderators | Register | Edit Profile

Zillions of Games Discussion Forum » Designing Games for Zillions » How to decrease the size of expanded game code « Previous Next »

Author Message
Karl Scherer (Karl)
Posted on Tuesday, December 26, 2000 - 3:01 pm:   

Zillions engine expands the code
(i.e. it replaces all macro calls with their
proper code content)
before it starts running.

Games with lots of expanded code
can still (even with the newset Zillions release)
easily prevent the game from running.

One way I found very useful to reduce the amount of expanded code is very simple: use only two- and three-letter names for your piecetypes.

NOTE that reducing the unexpanded code
(by creating macro calls) does NOT help, because
the macros will be expanded later.
This is VERY different from ordinary computer
programmming rules (for languages with proper subroutine calls), where the reduction of source code actually reduces the size of the finished program.

Still the use of macros for common code
is recommendable for other reasons (clarity,
ease of maintenance etc).
Karl Scherer (Karl)
Posted on Wednesday, January 03, 2001 - 5:54 pm:   

Another way to drastically reduce expanded code:

When you have many similar calls to macros like so (with n = 1 or larger):

(define Example-move
(Call1)(Call2)(Call3)...(Calln)
(Call1)(Call2)(Call3)...(Calln)
(Call1)(Call2)(Call3)...(Calln)
add
)

then each macro call is expanded and may crash Zillions (I have this problem a lot).

A way to drastically reduce the expanded code is by using the while command:

(define Example-move
(while .....;check a flag or a counter here
(Call1)(Call2)(Call3)...(Calln)
)
add
)

You may set the flag or counter inside the
called macros or inside the while-loop.
A practical example is my new game
"Spaghetti 2", to be published in a few days.
(Or get it right away from http://karl.kiwi.gen.nz)
Study the zrf file there!
I had to use this trick many times in this
rules file.

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: