Small tip Log Out | Topics | Search
Moderators | Register | Edit Profile

Zillions of Games Discussion Forum » Designing Games for Zillions » Small tip « Previous Next »

Author Message
John Kewley (Jkew)
Posted on Thursday, January 16, 2003 - 6:27 pm:   

I have setup several macros that take a direction. At some later time I need to be able to call that macro with the current position.

The solution: a direction called 'h' for here,
defined to be (0 0)

Sorry if this is a well known trick, or
there is an even more trivial way round it!

Cheers

JK
David Eugene Whitcher (Dralius)
Posted on Friday, January 17, 2003 - 12:35 pm:   

Dear John

Any tip that works is a good tip. I have not seen any posts about using a 'Null' direction before. I am sure this concept will help many new scripters.

David (Dralius) Whitcher
Ingrid Lael (Ingridlael)
Posted on Thursday, January 12, 2006 - 12:35 am:   

Excellent tip! as a matter of fact I've found this one to be particularly useful when trying to "normalize" calls to macros, so that i needn't distinguish between my current position and everything else; the results are pretty orthogonal and produces FAR cleaner code.

Thanks for that one!
Karl Scherer (Karl)
Posted on Tuesday, January 17, 2006 - 6:57 am:   

The 'null' direction is also useful as a simple way to differentiate all grid positions from other
(auxilliary, for example) positions without the
need to declare the main board as one huge zone, which needs a lot of typing (every position has to be quoted, no matter how big the board is) and is not easy to adapt if various board sizes are needed.

Instead of checking for a zone you simply check for direction:
(if (on-board? null) ...

I have used this trick in many of my games.
Again it simplifies programming and maintenance.

The slight disadvantage is that the AI generates moves for all other positions as well, which are then eliminated in the if-statement, and hence slightly effects the response time (performance).

Now that computers are getting faster and faster, this disadvantages is less and less important, escpecially if you have not too many positions outside the main board.

In solitair-games there is basically no disadvantage at all.

Cheers, Karl

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: