Shop OBEX P1 Docs P2 Docs Learn Events
Help with Program - Simon Says — Parallax Forums

Help with Program - Simon Says

ktdid07ktdid07 Posts: 8
edited 2008-04-03 14:23 in BASIC Stamp
Hi, everyone.

I am trying to build a simple Simon Says game with 10VDC lights...you know, like the one you used to have where the game would flash a series of lights at you, and you would repeat the pattern. Correct repetition would earn you points or access to a new level and incorrect repetition would lead to something unpleasant, like a loud buzzer or imminent death. [noparse]:)[/noparse]

Anyway, I was wondering if anybody had some suggestions on programming using PBASIC. I am trying to figure out a "random" pattern generator, and also how to allow the program to interpret the data coming back in.

Can anybody help?? I really appreciate it.

Thanks.

Comments

  • JonathanJonathan Posts: 1,023
    edited 2008-04-02 14:10
    How about:

    Make a tight loop with a counter that monitors a switch. This will be the start switch. When the user presses the button, use the counter number as a seed for the RANDOM command. Random isn't really random, if you use the same seed, you will get the same patterns. Using the counter as a seed will make it much more "random".

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
  • ercoerco Posts: 20,260
    edited 2008-04-02 14:34
    Nice answer, Jonathan. Base "random" on user input, such as how long they held a button down, or how long it took them to find the right button. I prefer to get new random input every loop instead of using the built-in random generator. Simple timing loops. You'll do the right thing.

    BTW, I give out this same problem (program Simon into a BS1) in a course I teach on toy design. It's a great problem, and an opportunity to use 4 pins as both inputs and outputs. That is, light the LED and then monitor its switch with one pin.

    Hey, wait, ktdid07, you had better not be a student in my class, soliciting help from all these Basic Stamp gurus in this forum! JK

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·"If you build it, they will come."
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-04-03 14:23
    For truly random effects you need to keep randomizing the seed until the user presses a button…This should happen before each new reseed to keep it true.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
Sign In or Register to comment.