Help! Boolean functions can only acce... Log Out | Topics | Search
Moderators | Register | Edit Profile

Zillions of Games Discussion Forum » Designing Games for Zillions » Help! Boolean functions can only accept conditions with single arguments? « Previous Next »

Author Message
No One (Singularity)
Posted on Thursday, March 16, 2006 - 7:54 am:   

Suppose I am trying to program a new chess piece which is only allowed to move if the square 1 space left OR 1 space right is empty:

(define TestMove (verify (or (empty? e) (empty? w))) n add n add)

However, is there some way I can program it to only be allowed to move if the square 2 spaces left OR 2 spaces right is empty? The following code generates an error, as "empty?" can apparently only handle a single direction afterwards.

(define TestMove (verify (or (empty? e e) (empty? w w))) n add n add)

The only solution I can currently think of is to define new directions, such as "doubleeast" and "doublewest". However, the piece I am trying to program would require 56 of these custom directions... Is there any other way I can handle this problem?

Thanks.

PS: I am trying to make a fairy chess piece known as a "Rose". I have made one before, but Zillions overestimates its value by a factor of 2, since any given square can be reached via a clockwise or counter-clockwise direction. I am trying to reprogram it using the OR function so that Zillions can calculate it more accurately.
Mats W (Kålroten)
Posted on Thursday, March 16, 2006 - 9:54 am:   

Possible solution:

e e
(if empty? back n add n add
else back w w
(if empty? back n add n add)
)
L. Lynn Smith (Interrupt27)
Posted on Thursday, March 16, 2006 - 5:32 pm:   

The only probably with moving the piece is that you may move it off the field and prematurely end the function.

So you will need to either break those two tests into seperate move declarations, or test for cells before moving the piece in a single declaration.

Here's a possible move declaration incorporating both:

(define test_move (
(set-flag valid_flag false)
mark
(if
(on-board? e)
e
(set-flag valid_flag (empty? e))
back
)
(if
(and
(not-flag? valid_flag)
(on-board? w)
)
w
(set-flag valid_flag (empty? w))
back
)
(verify (flag? valid_flag))
n add n add
))

Hopefully there are no syntax errors.

There are also some idiosyncrasies with Zillions when testing for cells off the field. I ran into these in a few codings. But I believe that it only verifies an empty cell if there is an actual empty cell.
Mats W (Kålroten)
Posted on Friday, March 17, 2006 - 12:00 am:   

Moreover, if a piece is overestimated by Zillions, then one can increase the value of the other pieces by adding moves to external positions, where one have added dummy pieces. One must check (verify not-empty?) so those moves aren't performed. The more calls to such "dummy moves" in a moves list, the higher evaluation gets the piece. I often have to tweak piece value in this way in the programs I make. One can also simply multiply calls to the piece's ordinary moves, but I suspect that this affects performance(?):

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: