How can I get pieces to reproduce? Log Out | Topics | Search
Moderators | Register | Edit Profile

Zillions of Games Discussion Forum » Designing Games for Zillions » How can I get pieces to reproduce? « Previous Next »

Author Message
Chris Huntoon (Chrish)
Posted on Thursday, August 10, 2000 - 4:46 am:   

I've been trying to implement one of my games for some time now, but so far have had no success.

In the game, players alternate dropping a piece on an empty space. On subsequent rounds, players continue to drop pieces on empty spaces, but in addition the piece dropped on the previous round will "reproduce". By this I mean if there are any empty spaces in any of the orthogonal directions immediately next to the piece, then a duplicate of the piece will be added to those spaces. On the following rounds, those new pieces will also reproduce themselves, and so on, and the board will become progressively more crowded.

Any help would be appreciated.
Roger J Cooper (Rogercooper)
Posted on Saturday, August 12, 2000 - 5:42 pm:   

This could be done by defining a reproducing piece. Define a cascade-move to allow multiple pieces to be dropped. Then end the cascade by having them promote to regular pieces. I think that Zillions would play this game poorly.
Marek Ctrnact (Marek14)
Posted on Sunday, August 13, 2000 - 1:38 am:   

Can I ask how you can define multiple drops with cascade? I never figured this one out...
Patrick S. Duff (Pduff)
Posted on Sunday, August 13, 2000 - 1:46 am:   

That isn't quite what he asked for. He asked that "the piece dropped on the previous round" and "new pieces" which were born from reproduction during the previous round reproduce into their orthogonal spaces in the current round.

This could be done by making a piece which has a completely transparent bitmap (or no image at all), making it invisible. Use cascade to drop these invisible pieces during the previous round, then in the current round, use (change type) to change any invisible pieces to visible ones.

An alternative is to create a neutral player, and have that player handle reproductions after each regular player's turn. That isn't quite the same as having it happen during the current round, but might turn out to be what he wants (not what he asked for).

Which way is better depends upon what the rules say about the order and interaction of drops and reproductions. If reproductions happen first, Zillions should show them before letting the player pick an empty location to drop their piece onto. Or you may want the drop(s) to happen first, then the reproductions. Perhaps the current player is allowed to drop on reproductions, or current reproductions are allowed to reproduce onto the location where the player just dropped. Whatever.
Patrick S. Duff (Pduff)
Posted on Sunday, August 13, 2000 - 2:04 am:   

How do cascades work? See the keyword "cascade" in the langref.hlp file, and look at the main topic named "The Internals of Movement" for instructions and examples.

Captures do not have to be cascaded, just drops and moves.

The only other thing I found tricky about cascades is making sure that the "to" location for the overall move is the location where the user should click with the mouse to initiate the drop (or move). A common mistake I made while learning cascades was to make an intermediate or the last drop in the cascade the location where the user must click to make the drop happen, instead of the location of the first drop. If you make this mistake, you won't see the black hand appear when you put the mouse pointer over the location where you want the user to click to "make" the drop happen. Instead it will appear when you put the mouse pointer over one of the other drop locations in the cascade.

Check what shows up in the "Moves List" window carefully to make sure that Zillions is executing your cascades correctly.
Chris Huntoon (Chrish)
Posted on Sunday, August 13, 2000 - 7:14 am:   

The game would function basically like this: a piece would be dropped on any empty space initiating a cascade that would search the board row by row. Each piece would have an attribute of "fertile" so that new pieces do not immediately reproduce. When the search found a new piece it would set the "fertile" attribute to true for the next round. If the search found a piece with a true "fertile" attribute it would then check the spaces next to it in the four orthogonal directions and drop pieces if any of them are empty. Then it would continue on with its search until it had completed the whole board.

Problem is, that when I try this, nothing happens. A piece drops on the empty space clicked on, but that's it, no reproduction at all.
Patrick S. Duff (Pduff)
Posted on Sunday, August 13, 2000 - 1:06 pm:   

From the langref.hlp file under keyword 'set-position-flag': "The flags for each position are initialized to false at the start of a move generation block for a piece. They only retain their values during move generation while the move code inside that block is executed." So when move generation begins for the current round, you are losing all of the position attribute information you set during the previous round.

That's why I suggested using invisible pieces to save the information for the next round. Another method would be to have an infertile piece and a fertile piece, possibly giving both the same bitmap so they look the same to the human player. Then your search would work, checking the piece-type instead of the position-attribute.
Marek Ctrnact (Marek14)
Posted on Sunday, August 13, 2000 - 2:58 pm:   

I still quite don't grasp the cascade command. I always used it to define multiple moving. The help file is not as specific as I would need ;-)
Is it possible to write something like this?
(n cascade n add) and make the piece land on both squares together? This way, the multiple drops could be defined, but I am not sure if it is correct.
Jens Markmann (Jensm)
Posted on Monday, August 14, 2000 - 4:47 am:   

I think it's not necessary to have any attributes or flags for this problem, as the the piece currently dropping is not yet considered to be on the board, and will thus not reproduce.
The following might work for you, but only if all of your pieces are of the same type, as all cascaded pieces will be of the dropping type.
(define spawn-all
a1
(while (not-position? end)
(if friend? (spawn-here) )
next
)
)
(define spawn-here
mark
(spawn n)(spawn s)(spawn w)(spawn e)
)
(define spawn
(if (empty? $1) $1 cascade to)
back
)

(piece ...
(drops
(
(verify empty?)
to
(spawn-all)
add
)
)
)
Marek Ctrnact (Marek14)
Posted on Monday, August 14, 2000 - 2:55 pm:   

The spawn macro should be a bit different:
(define spawn
(if (or (not-on-board? $1) (empty? $1)) $1
cascade to)
back
)

BTW, could this method be used in IceAge Chess?
Patrick S. Duff (Pduff)
Posted on Monday, August 14, 2000 - 7:24 pm:   

(not-on-board? x) means the position x is not a defined location. For example, (while (on-board? n) n) will move to the north edge of the board and stop. Note also that going to an illegal location terminates the generation of the current move.
Jens Markmann (Jensm)
Posted on Tuesday, August 15, 2000 - 2:10 am:   

It's not necessary to have an additional on-board check here, as one is already included in (empty?): A position can only be empty if it is also on-board.

I guess this can be used for Ice Age Chess, so that the neutral player only needs one move instead of 64.
Patrick S. Duff (Pduff)
Posted on Tuesday, August 15, 2000 - 2:53 am:   

I haven't tried it, but the langref.hlp file says that dummy positions are off-board. So a position can be empty but not on-board if it is a dummy position.

But I agree, the on-board check isn't needed here.

What is the name of the game we're discussing?
Jens Markmann (Jensm)
Posted on Tuesday, August 15, 2000 - 4:36 am:   

I just made a test, and it seems dummy positions verify as on-board, too.
Chris Huntoon (Chrish)
Posted on Tuesday, August 15, 2000 - 8:04 pm:   

When I tried the suggested Spawn macro and ran the game, I immediately got an error message: "An endless loop was encountered in the move logic for a piece."
Patrick S. Duff (Pduff)
Posted on Tuesday, August 15, 2000 - 9:03 pm:   

I bet you forgot to define a position named 'end' reachable by following the 'next' direction links starting from the position named 'a1'.

Am I right? Pay up!
Patrick S. Duff (Pduff)
Posted on Tuesday, August 15, 2000 - 9:18 pm:   

Here's the board definition from "ultima.zrf", showing how to use the 'next' direction to set up a search of the whole board:

(define Board-Definitions
(image "images\Chess\Chess8x8.bmp")
(grid
(start-rectangle 5 5 53 53)

(dimensions
("a/b/c/d/e/f/g/h" (49 0)) ; files
("8/7/6/5/4/3/2/1" (0 49)) ; ranks
)

(directions
(n 0 -1) (e 1 0) (s 0 1) (w -1 0)
(ne 1 -1) (nw -1 -1) (se 1 1) (sw -1 1)
(next 1 0)
) )

(links next
(h1 a2) (h2 a3) (h3 a4) (h4 a5)
(h5 a6) (h6 a7) (h7 a8)
)

(symmetry Black
(n s)(s n)
(nw sw)(sw nw) (ne se)(se ne)
) )

Now you can search the board for the friendly king by:

a1
(while (or (not-piece? King) not-friend?) next)
mark

Since move-generation terminates when an illegal position is reached, there is no reason to do an on-board? check. For that matter, if the king is captured, the game is over, so it must be on the board somewhere!
Chris Huntoon (Chrish)
Posted on Wednesday, August 16, 2000 - 9:02 pm:   

Well I finally got it to work.

Unfortunately something important has just come up at work and I'll have to fly out of town for a few days. So I won't be able to complete the rest of the game file until I get back. Hopefully by the end of next week I should have it wrapped up and submitted. BTW, the game's name is Jackrabbits.

Thanks to everyone who helped out!

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: