Win condition applies to ANY / ALL pi... Log Out | Topics | Search
Moderators | Register | Edit Profile

Zillions of Games Discussion Forum » Designing Games for Zillions » Win condition applies to ANY / ALL piece? « Previous Next »

Author Message
Bruce Dickey (Bruce_D)
Posted on Friday, May 05, 2006 - 7:18 pm:   

It appears the the win condition applies to ANY piece. Say for example I have an 8x8 grid with 10 pieces and say that 5 have to be in a row to win -- this condition is satisfied if 5 are in a row and 5 are scattered. However, is it possible to stipulate that ALL pieces must be involved in the win condition? I.e., in the above scenario, that there must be TWO 5-piece rows?

Thanks,
Bruce
Greg Schmidt (Gschmidt)
Posted on Sunday, May 07, 2006 - 12:02 pm:   

Here's an idea. For each piece, define a corresponding dummy/offboard piece and
call it the piece's "tracking piece". Each piece may have to have a unique name
in order to establish a correspondence with itself and it's tracking piece
(eg. piece-1, tracking-piece-1, piece-2, tracking-piece-2, ...).
The tracking piece can have a value of "not-in-a-row" or 'in-a-row".
Initially all tracking pieces are set to "not-in-a-row".

When a piece is moved, scan in all directions to determine if it is part of a 5 row, and if so,
then change the type of it's tracking piece to "in-a-row". The win-condition checks to see if all tracking-pieces are of type "in-a-row".

For each linear pair of directions, there are 5 ways for a piece to be part of a 5 row. For
example, in the north/south direction the 5 cases are:
1 2 3 4 5
. o o o o
o . o o o
o o . o o
o o o . o
o o o o .
(where '.' is the piece to be checked).

I'm envisioning a macro called 'in-a-row' which takes a direction as an argument and checks
for all 5 cases, using the direction and it's opposite direction to perform the scan. It
returns true if any of the 5 cases are satisfied.

I also envision a move macro for which takes the piece number as an argument and can thus
form both the piece name and tracking piece name from it.

This approach seems consistent with other complicated win checks I've seen. If you do decide to try it please let us know how it works out for you.

-- Greg
Greg Schmidt (Gschmidt)
Posted on Sunday, May 07, 2006 - 12:05 pm:   

Oops, I wrote:
I'm envisioning a macro called 'in-a-row'...

I meant to write:
I'm envisioning a macro called 'in-a-row?'...
Bruce Dickey (Bruce_D)
Posted on Sunday, May 14, 2006 - 2:22 pm:   

Turns out I'm stymied on this game -- the rules are not workable. If I come up with some rules that work I'll get back into it. But thank your very much for your suggestion. It could be applicable to other games.

Bruce
Karl Scherer (Karl)
Posted on Wednesday, May 17, 2006 - 4:54 pm:   

A method easier than using tracking pieces is to
create a macro which scans the board after each move to see whether each piece is part of a 5-in-a-row:

(set-flag fd? true)
a1
(while (on-board x) x

)

(if (flag? fd?) ;game won
(create game-won dummy-pos)
)

add))

Your win-condition simply checks the existence
of piece game-won on position dummy-pos :

(absolute-config (any-owner game-won)(dummy-pos))


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: