Help with Hook Mover Log Out | Topics | Search
Moderators | Register | Edit Profile

Zillions of Games Discussion Forum » Designing Games for Zillions » Help with Hook Mover « Previous Next »

Author Message
dhalgren (Dhalgren)
Posted on Wednesday, October 04, 2006 - 8:17 pm:   

Can someone help me with code for a piece? The piece moves like a hook mover but can't capture on the first leg. In other words, there's two steps to the move, any number of empty squares in an orthogonal direction without capturing, and then like a Rook.

Thanks for the help!
Sean Duggan (Dream)
Posted on Wednesday, October 04, 2006 - 8:20 pm:   

Honestly, that kind of movement requires hardcoding. You'll have to define macros for 1-square-then-rook, 2-square-then-rook, 3-square-then-rook, etc. Alternately, it might be possible using flags, but I think that would be that much harder to implement.
Sean Duggan (Dream)
Posted on Wednesday, October 04, 2006 - 8:28 pm:   

Hmmm... And I'm about to gainsay myself. It could be quite possible. You'd have to run nested while loops using mark. I don't have a syntax file onhand, but probably something like:
$1 (while empty? mark $2 (while empty? add $2) (verify not-friend?) add recall $1)
dhalgren (Dhalgren)
Posted on Wednesday, October 04, 2006 - 9:15 pm:   

Thanks sean! It works!
Sean Duggan (Dream)
Posted on Wednesday, October 04, 2006 - 9:17 pm:   

The problem I was thinking of, which required the separate moves, was one where the number of squares for each leg had to match each other. I did that for Duggan's Fantasy Chess and it was problematic.
dhalgren (Dhalgren)
Posted on Wednesday, October 04, 2006 - 9:35 pm:   

I spoke too soon, but something's not quite right. IF there's no piece to capture, it stops the loop.
Edward Holzman (Edholzman)
Posted on Wednesday, October 04, 2006 - 10:08 pm:   

Check the code that I used for the Cavalier and the Duke in Rennaisance Chess.

;================================================================================
;The STEP-SLIDE function combines the STEP and SLIDE into
;a single maneuver. A piece may move one space in direction $1 (provided that
;the space is unoccupied) and then begin sliding an unlimited number of
;unoccupied spaces in a straight line in direction $2 (and capture any enemy that
;may be present in the last space of the sliding maneuver).

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


;================================================================================
;My inability to come up with an elegant method to combine a SLIDE and STEP move
;causes the need for the SLIDEx-STEP functions. These allow a piece to slide x
;unoccupied space(s) in a straight line in direction $1 and then step one space
;in direction $2 (and capture any enemy that may be present in that space).

(define slide1-step ($1 (verify empty?) $2 (verify not-friend?) add))

(define slide2-step ($1 (verify empty?) $1 (verify empty?)
$2 (verify not-friend?) add))

(define slide3-step ($1 (verify empty?) $1 (verify empty?) $1 (verify empty?)
$2 (verify not-friend?) add))

(define slide4-step ($1 (verify empty?) $1 (verify empty?) $1 (verify empty?)
$1 (verify empty?) $2 (verify not-friend?) add))

(define slide5-step ($1 (verify empty?) $1 (verify empty?) $1 (verify empty?)
$1 (verify empty?) $1 (verify empty?)
$2 (verify not-friend?) add))

(define slide6-step ($1 (verify empty?) $1 (verify empty?) $1 (verify empty?)
$1 (verify empty?) $1 (verify empty?) $1 (verify empty?)
$2 (verify not-friend?) add))

(define slide7-step ($1 (verify empty?) $1 (verify empty?) $1 (verify empty?)
$1 (verify empty?) $1 (verify empty?) $1 (verify empty?)
$1 (verify empty?) $2 (verify not-friend?) add))

(define slide8-step ($1 (verify empty?) $1 (verify empty?) $1 (verify empty?)
$1 (verify empty?) $1 (verify empty?) $1 (verify empty?)
$1 (verify empty?) $1 (verify empty?)
$2 (verify not-friend?) add))

(define slide9-step ($1 (verify empty?) $1 (verify empty?) $1 (verify empty?)
$1 (verify empty?) $1 (verify empty?) $1 (verify empty?)
$1 (verify empty?) $1 (verify empty?) $1 (verify empty?)
$2 (verify not-friend?) add))

(define slide10-step ($1 (verify empty?) $1 (verify empty?) $1 (verify empty?)
$1 (verify empty?) $1 (verify empty?) $1 (verify empty?)
$1 (verify empty?) $1 (verify empty?) $1 (verify empty?)
$1 (verify empty?) $2 (verify not-friend?) add))

(define slide11-step ($1 (verify empty?) $1 (verify empty?) $1 (verify empty?)
$1 (verify empty?) $1 (verify empty?) $1 (verify empty?)
$1 (verify empty?) $1 (verify empty?) $1 (verify empty?)
$1 (verify empty?) $1 (verify empty?)
$2 (verify not-friend?) add))

(define slide12-step ($1 (verify empty?) $1 (verify empty?) $1 (verify empty?)
$1 (verify empty?) $1 (verify empty?) $1 (verify empty?)
$1 (verify empty?) $1 (verify empty?) $1 (verify empty?)
$1 (verify empty?) $1 (verify empty?) $1 (verify empty?)
$2 (verify not-friend?) add))

I know it's not exactly what you're looking for but it should help.
Mats W (Kålroten)
Posted on Thursday, October 05, 2006 - 3:37 am:   

Edward's code probably works, but it can be done with an algorithm on lines of Sean's suggestion. It strikes me as an overwhelmingly powerful piece so maybe you should introduce criteria for when it's allowed to enter the second leg, or the first leg, like I have done in my bifurcation pieces:
http://hem.passagen.se/melki9/bifurcation.htm

Anyway, this code should probably work:

(define twoleg-slide (
(while true
$1 (verify empty?) mark add ;add the rook slide move

(set-flag continue true)

(while (and empty? (flag? continue))
(if (and (on-board? $2) (not-friend? $2)) $2 add else (set-flag continue false))
)
back
)
))

The piece definition should contain:

(twoleg-slide n w)
(twoleg-slide n e )
(twoleg-slide s w) etc...

Mats
dhalgren (Dhalgren)
Posted on Thursday, October 05, 2006 - 10:56 am:   

Thanks Mats! That seems to do the trick. My piece doesn't capture on its first leg, so I just removed the first add. Zillions values it at about twice a Queen.
Mats W (Kålroten)
Posted on Friday, October 06, 2006 - 12:10 am:   

But this code does not capture on the first leg. If you remove the first add then you remove 'movement' on the first leg.

Mats
dhalgren (Dhalgren)
Posted on Friday, October 06, 2006 - 12:19 am:   

Yes, that's what I meant, it can't land on the first leg. I'm thinking of calling it an Anti-Rook.

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: