Searching for an empty square. Log Out | Topics | Search
Moderators | Register | Edit Profile

Zillions of Games Discussion Forum » Designing Games for Zillions » Searching for an empty square. « Previous Next »

Author Message
Shane Freeman (Thegreathabudabi)
New member
Username: Thegreathabudabi

Post Number: 2
Registered: 7-2008
Posted on Wednesday, July 02, 2008 - 7:44 pm:   

I created an off board zone for each player in my 4 player chess variant where pieces they capture are displayed. The problem is, the way I accomplished it allows for players to move their own pieces off the board to the 'Dungeon' instead of capturing the pieces within their capture zones.

This is how it happens. Every piece Move definition calls a subroutine that checks what piece is being caotured. Once it has determined the who (player) and what (piece) it calls another subroutine to examine the vacancy in the 'Dungeon'. The following is the code I use to find an empty square.

(define S_EMPTY
b0 (if empty? add else c0 (if empty? add else
d0 (if empty? add else e0 (if empty? add else
f0 (if empty? add else g0 (if empty? add else
h0 (if empty? add else i0 (if empty? add else
j0 (if empty? add else k0 (if empty? add else
l0 (if empty? add else m0 (if empty? add else
n0 (if empty? add else o0 (if empty? add else
p0 (if empty? add else q0 (if empty? add else
r0 (if empty? add else s0 (if empty? add else

b1 (if empty? add else c1 (if empty? add else
d1 (if empty? add else e1 (if empty? add else
f1 (if empty? add else g1 (if empty? add else
h1 (if empty? add else i1 (if empty? add else
j1 (if empty? add else k1 (if empty? add else
l1 (if empty? add else m1 (if empty? add else
n1 (if empty? add else o1 (if empty? add else
p1 (if empty? add else q1 (if empty? add else
r1 (if empty? add else s1 (if empty? add else

q2 (if empty? add else r2 (if empty? add else
q3 (if empty? add else
b0 )))))))))) )))))))))) )))))))))) )))))))))
)

When it returns from this subroutine the proper piece is added to the square it stopped on. My problem is that by using the add command in this subroutine I allow the piece being used to capture with to move itself into the dungeon instead of making the capture.

What I need is a routine that will poll through my 'Dungeon' looking for an empty square then stop on the first empty square it finds and terminate the routine, all without actually moving anything to the destination before the termination.
M Winther (Kalroten)
New member
Username: Kalroten

Post Number: 78
Registered: 1-2007
Posted on Thursday, July 03, 2008 - 12:03 am:   

It s not good if you add an actual piece to an external square because then captures become much more valuable. You should add dummy pieces with the same image.

In order to add an external dummy piece then you should use e.g. (create dBishop m1) or m1 (create dBishop). Then you must make the add so that the piece on the board is captured.

Mats
Shane Freeman (Thegreathabudabi)
New member
Username: Thegreathabudabi

Post Number: 3
Registered: 7-2008
Posted on Thursday, July 03, 2008 - 2:57 pm:   

I don't use an actual piece in the 'Dungeon'. It is a dummy piece as you suggested. The problem is my check dungeon call is generic, not piece specific. In the above code I tried using another create dummy piece instead of the add, but the compiler crashes when i do it.
Shane Freeman (Thegreathabudabi)
New member
Username: Thegreathabudabi

Post Number: 5
Registered: 7-2008
Posted on Thursday, July 03, 2008 - 7:29 pm:   

This problem has been resolved. The following code is an example of the routine taken by each piece movement that results in captured pieces being 'moved' to the dungeon without allowing the capturing piece to move itself to the dungeon instead.

( define S_KNIGHT_MOVE
($1 $2 (verify not-friend?) (S_CAPTURING) add)
)

(define S_CAPTURING

(if (piece? N_KING) mark (S_EMPTY_K) (create GREY_KING) back else
(if (piece? E_KING) mark (S_EMPTY_K) (create BLUE_KING) back else
(if (piece? W_KING) mark (S_EMPTY_K) (create RED_KING) back else

(if (piece? N_QUEEN) mark (S_EMPTY) (create GREY_QUEEN) back else
(if (piece? E_QUEEN) mark (S_EMPTY) (create BLUE_QUEEN) back else
(if (piece? W_QUEEN) mark (S_EMPTY) (create RED_QUEEN) back else

(if (piece? N_BISHOP) mark (S_EMPTY) (create GREY_BISHOP) back else
(if (piece? E_BISHOP) mark (S_EMPTY) (create BLUE_BISHOP) back else
(if (piece? W_BISHOP) mark (S_EMPTY) (create RED_BISHOP) back else

(if (piece? N_KNIGHT) mark (S_EMPTY) (create GREY_KNIGHT) back else
(if (piece? E_KNIGHT) mark (S_EMPTY) (create BLUE_KNIGHT) back else
(if (piece? W_KNIGHT) mark (S_EMPTY) (create RED_KNIGHT) back else

(if (piece? N_ROOK) mark (S_EMPTY) (create GREY_ROOK) back else
(if (piece? E_ROOK) mark (S_EMPTY) (create BLUE_ROOK) back else
(if (piece? W_ROOK) mark (S_EMPTY) (create RED_ROOK) back else

(if (piece? N_PROOK) mark (S_EMPTY) (create GREY_PROOK) back else
(if (piece? E_PROOK) mark (S_EMPTY) (create BLUE_PROOK) back else
(if (piece? W_PROOK) mark (S_EMPTY) (create RED_PROOK) back else

(if (piece? N_PBISHOP) mark (S_EMPTY) (create GREY_PBISHOP) back else
(if (piece? E_PBISHOP) mark (S_EMPTY) (create BLUE_PBISHOP) back else
(if (piece? W_PBISHOP) mark (S_EMPTY) (create RED_PBISHOP) back else

(if (or (piece? N_PAWN) (piece? GREY_NW_4T_PAWN) (piece? GREY_NE_4T_PAWN)
(piece? GREY_NW_3T_PAWN) (piece? GREY_NE_3T_PAWN)
(piece? GREY_NW_2T_PAWN) (piece? GREY_NE_2T_PAWN) ) mark
(S_EMPTY) (create GREY_PAWN) back else
(if (or (piece? E_PAWN) (piece? BLUE_NE_4T_PAWN) (piece? BLUE_SE_4T_PAWN)
(piece? BLUE_NE_3T_PAWN) (piece? BLUE_SE_3T_PAWN)
(piece? RED_SW_2T_PAWN) (piece? RED_NW_2T_PAWN) ) mark
(S_EMPTY) (create BLUE_PAWN) back else
(if (or (piece? W_PAWN) (piece? RED_SW_4T_PAWN) (piece? RED_NW_4T_PAWN)
(piece? RED_SW_3T_PAWN) (piece? RED_NW_3T_PAWN)
(piece? BLUE_NE_2T_PAWN) (piece? BLUE_SE_2T_PAWN) ) mark
(S_EMPTY) (create RED_PAWN) back )))))) )))))) )))))) ))))))
)

(define S_EMPTY
b0 (if empty? add-copy else c0 (if empty? add-copy else
d0 (if empty? add-copy else e0 (if empty? add-copy else
f0 (if empty? add-copy else g0 (if empty? add-copy else
h0 (if empty? add-copy else i0 (if empty? add-copy else
j0 (if empty? add-copy else k0 (if empty? add-copy else
l0 (if empty? add-copy else m0 (if empty? add-copy else
n0 (if empty? add-copy else o0 (if empty? add-copy else
p0 (if empty? add-copy else q0 (if empty? add-copy else
r0 (if empty? add-copy else s0 (if empty? add-copy else

b1 (if empty? add-copy else c1 (if empty? add-copy else
d1 (if empty? add-copy else e1 (if empty? add-copy else
f1 (if empty? add-copy else g1 (if empty? add-copy else
h1 (if empty? add-copy else i1 (if empty? add-copy else
j1 (if empty? add-copy else k1 (if empty? add-copy else
l1 (if empty? add-copy else m1 (if empty? add-copy else
n1 (if empty? add-copy else o1 (if empty? add-copy else
p1 (if empty? add-copy else q1 (if empty? add-copy else
r1 (if empty? add-copy else s1 (if empty? add-copy else

q2 (if empty? add-copy else r2 (if empty? add-copy else
q3 (if empty? add-copy else
b0 )))))))))) )))))))))) )))))))))) )))))))))
)

(define S_EMPTY_K
d3 (if empty? add-copy else d2 (if empty? add-copy else
c2 ))
)

One problem down. Now only hacking turn sequence during gameplay left to go.

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: