Changing an opponents piece type Log Out | Topics | Search
Moderators | Register | Edit Profile

Zillions of Games Discussion Forum » Designing Games for Zillions » Changing an opponents piece type « Previous Next »

Author Message
Robert Winkel (Bull)
Posted on Sunday, November 30, 2003 - 4:29 am:   

I've tried several methods but can't seem to make it work...
What I am trying to do is something like this: I have a game with two sides "Black" and "White", and they both have a piece type of "Checker". There is a third side "Neutral" which has the single piece of type "Ball". The game consists of the two sides trying to grab the ball with one of their Checkers and throwing it into a goal. When a Checker lands on the Ball it gets turned into a new piece which represents a Checker holding a ball (called "Checker-with-ball"). A "Checker-with-ball" cannot move, only throw the ball a number of squares in any direction. When this happens the "Checker-with-ball" turns back into a "Checker". So far so good?
Anyway, I can successfully throw the ball to an empty square and also to a square with a friend "Checker" in it, thereby turning it into type "Checker-with-ball". But I can't get the code right for, say, a White "Checker-with-ball" to throw the Ball to a Black "Checker", thereby transforming the White piece into a "Checker" and the Black piece into a "Checker-with-ball". Can anybody help me with this?

Cheers,
Bull.
Karl Scherer (Karl)
Posted on Sunday, November 30, 2003 - 5:53 am:   

Hi Robert,
have you tried to use the "flip" command?

That should do the job.
I have just published a similar game "Soccer",
a simulation of a real soccer game.
Maybe you should have a look at the code.
I don't use a special "player with ball" piece,
but I still have to chnage ownership of the ball
after every turn.
In my game any player next to the ball can kick the ball.

P.S. Updated version 1.1 of "Soccer" will be out next week; or download it from my web page:
http://karl.kiwi.gen.nz
Cheers, Karl
Robert Winkel (Bull)
Posted on Sunday, November 30, 2003 - 6:40 am:   

Karl,
I have seen your game actually. I like it. I have looked at most of the ball playing games in Zillions.
I also have tried "flip", but maybe I'm doing it wrong. I have tried flipping in various places, without success. Here's an example of what I am trying to do. "Ball-kick" is the only move that a "Checker-with-ball" can make.

(define ballmoves
(moves
(Ball-kick n)
(Ball-kick ne)
(Ball-kick e)
(Ball-kick se)
(Ball-kick s)
(Ball-kick sw)
(Ball-kick w)
(Ball-kick nw)
)
)

(define Ball-kick
( ; Only implementing 1 sqaure for now
(change-type Checker)
$1
(if empty? ; Works
(add-copy Ball)
)
(if enemy? ; DOESN'T WORK
flip
(add-copy Checker-with-ball)
)
(if friend? ; Works
(add-copy Checker-with-ball)
)
)
)

In the above example, the enemy piece is simply captured and nothing (visible) is placed in the position.
I think I am getting into trouble with "flip" because I have 3 players: Black, White and Neutral.
I have also tried checking what color made the move and then using a "(create Black Checker-with-ball)" for example. But that didn't seem to work either.

Cheers,
Bull.
Karl Scherer (Karl)
Posted on Wednesday, December 17, 2003 - 4:22 am:   

Hi Robert,

with 3 players you have to do 'flip'
for one player, and 'flip flip' if it is the other player's move in order to swap ownerships.
The flip command shifts ownership to the next player in sequence.
Whether it is White or Black who has to do the double flip depeneds in which sequence you listed the players.

Remember that using the 'zone' command helps
to find whose turn it is:

;..in your definition:
(zone (name playerzone)(players White)
(positions a1))

; in your move block:
(define Am-White?
(in-zone? playerzone a1)
)

...
(if Am-White? ...)

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: