"swap places" bug? workaround? Log Out | Topics | Search
Moderators | Register | Edit Profile

Zillions of Games Discussion Forum » Designing Games for Zillions » "swap places" bug? workaround? « Previous Next »

Author Message
David J Bush (Twixter)
Posted on Friday, January 14, 2005 - 3:28 pm:   

I am designing a game where pieces on adjacent positions are sometimes able to swap places. You can swap a pair of your own pieces, or swap with an opposing piece, with some restrictions. Capturing is not allowed under any circumstances. If I play both sides, I can make such swap moves with no problem. If I tell Zillions to play one side, it will make only legal moves, but it plays poorly because when it looks beyond one ply, it will not be looking at swapping with opposing pieces, but capturing them instead. If I tell Zillions to play both sides, the first move it makes will be legal, but all subsequent moves which should be swaps will be captures. I have saved a game which when loaded will demonstrate this illegal move behavior from Zillions. If I save a game with illegal moves and try to load it in again, Zillions will complain at the first capturing move it finds, as it should.

In all the games written for Zillions, there must be other games where a piece swaps positions with an opposing piece. Has anyone encountered this weird behavior before? Is there a workaround? I'd rather not wait for the bug to be fixed.

There are three piece types in my game: Large, medium, and small. A typical call from a Large move block would be:

((swapcheck e w medium))

Here is my macro "swapcheck"

 
(define swapcheck
(if (and (on-board? $1) (piece? $3 $1)) ; A large piece may swap with
$1 ; a medium, medium with a
(if friend? ; small, small with a large.
cascade ;
from ; If you are swapping two of
$2 ; your own pieces, no further
to ; check is necessary.
$1
add
else
(set-position-flag friendpiecehere true)
(set-position-flag noenemyhere true)
$2
(set-position-flag enemypiecehere true)
(set-position-flag nofriendhere true)
$1
(fivecheck friend true) ; have you formed a connected group of 5?
(if (flag? toomuch) ; illegal to form a group of more than 5
(set-position-flag friendpiecehere false)
(set-position-flag noenemyhere false) ; reset position
$2 ; flags
(set-position-flag enemypiecehere false)
(set-position-flag nofriendhere false)
else
(if (not-flag? gameover)
cascade
from
$2
(fivecheck enemy true) ; have you formed an enemy group of 5?
(if (not-flag? toomuch) add)
(set-position-flag enemypiecehere false) ; reset the position
(set-position-flag nofriendhere false) ; flags
$1
(set-position-flag friendpiecehere false)
(set-position-flag noenemyhere false)
$2
else
add
$2
)
)
)
)
)
Sean Duggan (Dream)
Posted on Friday, January 14, 2005 - 3:38 pm:   

Right now my eyes are watering too much from the dilation drops to properly follow your code, but I suggest looking at http://home.t-online.de/home/j_markmann/zrf.html for a good example of a swap. I will look further at your code when my eyes start cooperating again.
David J Bush (Twixter)
Posted on Friday, January 14, 2005 - 3:58 pm:   

Uh, I found some more bugs in my code, and now Zillions seems to be working just fine! Funny how talking about a problem to someone else helped me realize what I was doing wrong. Zillions might still have a bug, but it doesn't seem to affect my program any more. Sorry to have taken up your time and Inbox.

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: