Thanks Irv... I really appreciate your help...
I wasn't really thinking of the list of all the possible solutions in the beginning... What I did was to see if any combinations of block make certain figures(such as three in a row or four in a column)... I think I got a great deal to go on with this game, but I think I can manage it somehow, of course with your help... :) Thanks again, and have a nice day!!! Jason -----Original Message----- From: Irv Kalb <[EMAIL PROTECTED]> Date: Tue, 29 Jan 2002 09:14:43 -0800 To: [EMAIL PROTECTED], [EMAIL PROTECTED] Subject: Re: <lingo-l> Logic question... > Jason, > > The answer to your question depends a great deal on how you are > representing your 5 by 5 matrix (i.e. are you using a single 25 > element list, or a list of 5 lists where each sublist contains 5 > elements). But if you can do the proper translation, here's an > approach. > > Pe-calculate all possible winning combinations and make a list of > lists out of them. That is, make one list, where each element in the > list is a list of a single winning combination. To make this most > simple, let's just assume that you are using a single list with > elements 1 to 25 to represent your game: > > lCombinations = [\ > [1, 2, 3, 4, 5],\ > [6, 7, 8, 9, 10],\ > ... > [21, 22, 23, 24, 25],\ > [1, 6, 11, 16, 21],\ > ... > [5, 10, 15, 20, 25]] > > Then given this list of lists, you write a handler to step through > these combinations to see if all elements are the same color. > Completely untested: > > -- I'm assuming that you have some global list, let's call it gBoard > that contains the game elements > on CheckForMatch > nCombinations = count(lCombinations) > repeat with i = 1 to nCombinations > lThisCombination = lCombinations[i] > indexOfFirstItemInThisCombination = lThisCombination[1] > valueToMatch = gBoard[indexofFirstItemInThisCombination] > > nItemsInThisCombination = count(lThisCombination) > fMatched = TRUE -- assume a match until proven otherwise > repeat with j = 2 to nItemsInThisCombination > indexOfNextItemInThisCombination = lThisCombination[j] > thisValue = gBoard[indexofNextItemInThisCombination] > if thisValue <> valueToMatch then > fMatched = FALSE -- sorry Charlie > exit repeat > end if > end repeat > if fMatched then > -- This items in the list lThisCombination are all the > same value, do whatever you want here > end if > > end repeat > end > > Hope this gives you some inspiration. > > Irv > > > > At 11:46 PM -0500 1/28/02, Jason Je wrote: > >Hi... I am building a simple game and I need some help here... > > > >Let's just say that I am making a tetris-like game... The basic > >thing I have to check is if the blocks are same color or not... I'm > >using 5X5 matrix here... > >The basic things that I have to check in this game is to see if any > >three(four and five) consecutive blocks in any direction within the > >matrix have the same value or not... And I also check if any > >five(seven and nine) blocks are making any cross shape with same > >value and so on... > >Currently I am just using simple if statement to check all of > >occurence... but I think there should be some simple method that I > >could use rather than using if statements on all occasions... > >Can someone help me out here??? > > > >TIA > >Jason > > -- > > Lingo / Director / Shockwave development for all occasions. > > (Home-made Lingo cooked up fresh every day just for you.) > [To remove yourself from this list, or to change to digest mode, go to >http://www.penworks.com/lingo-l.cgi To post messages to the list, email >[EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for >learning and helping with programming Lingo. Thanks!] > > -- _______________________________________________ Win a ski trip! http://www.nowcode.com/register.asp?affiliate=1net2phone3a [To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/lingo-l.cgi To post messages to the list, email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for learning and helping with programming Lingo. Thanks!]
