I need a better way to swap pieces Log Out | Topics | Search
Moderators | Register | Edit Profile

Zillions of Games Discussion Forum » Designing Games for Zillions » I need a better way to swap pieces « Previous Next »

Author Message
Steve Warner (Ceratopsian)
New member
Username: Ceratopsian

Post Number: 5
Registered: 12-2007
Posted on Saturday, January 05, 2008 - 7:57 am:   

I have one piece which swaps with other friendly pieces. I am currently using a long list of commands to get this done. For example:

(n n n e cascade (verify friend?) back add)

(I have such a line for each possible square)

This works but it is taking too many lines of code. There must be a way to do this more compactly with something like a while command, but I can't get it to work. Any suggestions?
Greg Schmidt (Gschmidt2)
New member
Username: Gschmidt2

Post Number: 51
Registered: 1-2007
Posted on Saturday, January 05, 2008 - 8:36 am:   

As a suggestion, you could post your game to the following group and follow up with a message for assistance:

http://games.groups.yahoo.com/group/axiom-system/

It might help to get a few more eyes looking at it as well as to view the actual code.

-- Greg
Karl Scherer (Karl)
New member
Username: Karl

Post Number: 365
Registered: 9-2000
Posted on Saturday, March 22, 2008 - 10:38 pm:   

Hi Greg,

I suggest the following would do, with very little code:
Make two partial moves with the same pieces,
first moving to a friendly piece and then (in the second partial move) back to the original position.

The first part is easy:

(define Swapmove (
(verify (empty? dummypos))
(create Swap-part1 dummypos)

a0
(while (on-board? x) x
(if friend?)
(if (piece? rook) (create rook dummypos2) else
(if (piece? bishop) (create bishop dummypos2) else ...
)...)
(add-partial Swap-type2)
)
))

Second partial move is called "Swapmove2",
which is of move-type Swap-type2.


(define Swapmove2 (
(verify (piece? Swap-part1 dummypos))
(capture dummypos)

(go last-to) from
(go last-from) to

(if (piece? rook dummypos2) (add rook) else
(if (piece? bishop dummypos2) (add bishop) else ...
)...)
))

Cheers, Karl
Karl Scherer (Karl)
New member
Username: Karl

Post Number: 366
Registered: 9-2000
Posted on Saturday, March 22, 2008 - 10:41 pm:   

My message was meant for Steve, of course, not Greg. Sorry that I saw your query only yesterday.

If anything is not clear, fell free to ask more questions.

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: