What am I doing wrong here?

Hapy00Hapy00 Member Posts: 16
edited August 2012 in Working with GS (Mac)
Hey guys. I posted a while back asking about doing a simple memory matching game using GS. The game is similar to the old electronic game Simon. The game spits out a random color in a sequence and you need to hit the colors back in the same sequence.

So, using Tables I have been attempting this. This is what I have so far for my sequencer:

I have a Table set up called "TB Sequencer", that has 54 Rows and 2 Columns (both set as Integers). Column 1 is my sequence order value, and column 2 is my color value (I am using Change Table Value to set this from the sequencer). I have an Attribute called "Order Count" that is defaulted to 0.

There is a Rule in place for this thing to run 3 times, then stop (if Order Count is less than or equal to Sequence Count (defaulted to 3), then run this script).

The sequencing script itself looks like this:

Change Attribue "self.Random" to Random (1,4). ---> This picks a random color (1 = Red, 2 = Blue, etc...).

RULE - If self.Random = 1, then Change Table Value (TB Sequencer) to Row: game.Order Count+1, Column 2, Value: 1.

So if 1 gets picked, it should set Row 1, Column 2 of TB Sequencer to 1 (remember, Order Count is defaulted to 0, so 0+1 = 1).

After this, it Displays Text: Red!

Then it does a Change Attribute of game.Order Count to game.Order Count+1. <--- Increase the Order count by 1, setting it to 1 (defaulted at 0).

All of this runs flawlessly. Each color (4 colors) has the exact same setup.

The problem occurs when the next number is picked. (I have debug Displays showing me the Order Count and each Row of TB Sequencer, Column 2).

When it picks the next random number, it should change only Row 2, Column 2 of TB Sequencer, but it changes Rows 2 AND 3 (setting them both to whichever random number was just picked). And to make matters worse, on the third random number it does not set Row 3, Column 2.

What am I doing wrong? This sounds like it should work, but it doesn't. =(

Comments

  • Hapy00Hapy00 Member Posts: 16
    I have tried extending the sequence out past 3 (to 9), and it works past 2 and 3 just fine.
    For some reason the second number always gets set to Order Count 2 AND 3, the third number gets ignored (or something), and then everything runs fine from there.

    Am I just a noob and just missing something simple?
  • Hapy00Hapy00 Member Posts: 16
    I also have tried just ignoring Rows 1, 2, and 3, and that seems to work just fine also. It appears to be a problem with Rows 2 & 3. If I try to start the sequence at 1, it does the exact same thing as I stated earlier (doubles the first number in Rows 2 & 3 and ignores the third number), then continues fine. If I start it at 2, then it drops the first number (this should go into Row 3), then continues along just fine.

    I guess I can just start it at 3 and adjust my other math to suit this as a work around. I am just reluctant to do so because I am afraid that:
    A. - Someone will respond to this and point out the flaw.
    B. - That the problem will re-occur later down the chain.

    ANY help would be useful at this point!!!
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited August 2012

    @Hapy00

    Hi, not sure why it's doing what it's doing, but: try amending your Rules like the following, to see if the problem clears:

    (By the way, I'm not sure what loop mechanism you're using to get this looping so I've put my own version in, by making a boolean attribute called LoopA):

    Rule: When LoopA is false and OrderCount <= SequenceCount

    Change Attribute LoopA to true
    Change Attribute game.Order Count to game.Order Count+1
    Change Attribute self.Random to Random (1,4)
    Change Table Value (TB Sequencer) to Row: game.Order Count, Column 2, Value: self.Random

    When self.Random = 1
    Displays Text: Red
    When self.Random = 2
    Displays Text: Yellow, etc,.

    Change Attribute LoopA to false

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • Hapy00Hapy00 Member Posts: 16
    Nevermind, I figured it out. I had bad math elsewhere.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598

    A "but thanks all the same" wouldn't have gone amiss.

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • rhinokeyrhinokey Member Posts: 158
    i appreciate the time you spent trying to help gryo!
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited August 2012

    @rhinokey Hey, thanks! I know that the vast majority of Forum members appreciate answers given from all of us who try to help out; there are still a small amount of people who either totally ignore your comment (which has sometimes, in my case, taken twenty minutes or more to get the answer together, and I'm certain it's been the same for others once in a while) i.e dont make any acknowledgement of you as if you're invisible and your help doesn't count; or verbally dismiss you like you're a servant or something; personally, I make a mental note of their names and know I won't be trying to help them again in the future.

    It's like this small minority of members think a "cheers" or "thanks" or even "thanks for trying but not what I'm after" will bring them out in a rash.... ;-)

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • Hapy00Hapy00 Member Posts: 16
    Sorry for the hurt feelings, Gyro.
    When I posted my "never mind" post, I still didn't see any replies to this thread.

    Thanks for the effort, though!
Sign In or Register to comment.