Simon Game - Implement "standard" mode


I continue to make progress in my Simon game and I feel like I’m very close to having it finished. However, I am having issues implementing the non-strict version of my game. According to my understanding of the user story, in standard mode, if you miss a guess, it should replay the color sequence and allow you to continue guessing.

I implemented my code so that the color sequence replays and you can choose again. However, it appears that in certain instances, the code is no longer checking to make sure that the human input is correct. For example, in round three, I clicked the first two answer correctly, then clicked the third incorrectly, and instead of replaying the sequence, it advanced me to the next round.

If anyone can provide some guidance, I would really appreciate it!

I experienced some oddness when playing your game. A couple of times the game validated incorrect responses (e.g. red and blue blinked and I chose red and yellow). I also had some issues getting the start button to ‘click’ – it worked after refreshing my browser a couple of times. Also, at about 4 sequences when I missed a color the blinking went a little crazy.

Based I what I have seen from playing your game and based on the random issues I encountered when I made my game I have some suggestions. I don’t guarantee that they will fix the issues, but these are the things that I would do.

  1. rewrite the code to use one event listener on a parent element and then take action on the event based on the id that was clicked. I ended up using switch to control what actions took place when different things were clicked. If you peek at many of my projects, you will see the pattern to which I am referring. I don’t know if it is the best of practices, but it did work for me. This website talks about event listeners, but doesn’t quite show you an example of the pattern which I have in mind:

  2. Reconsider the way you are handing the timing for your lights. It took me forever (seemingly) to sort the timing out (HINT my solution involved callback functions and arrays). Again, I’m not sure if it is the most elegant solution, but it worked.

There are some other minor issues, but those can be discussed once the game is otherwise working properly.

I hope this helps.

1 Like

Thank you for your response. I stripped down the code to the bare basics and tried to implement (what I thought you meant by) suggestion #1.

If you have time, can you take a look and see if the weird issues that you experienced are fixed? I think I might have thought that my program was further along than it was, so I started adding in some additional functionality that it wasn’t ready for. I’m hoping this new version allows you to play a strict Simon game with no issues.


@jv88899 I’ve given your latest implementation a whirl, and the “strict” version seems to be working well. :+1:

However, a couple of comments:

  • When the user enters strict mode, it would be helpful to have some indication of this. I know I am playing in strict because I lose when I hit the wrong button, but I am not positive up until that point since there is no “indicator light” or something along those lines.
  • Also, once the game is lost, I can’t seem to restart without reloading the page.
  • I am still having a little trouble like what was described in above posts, for non-strict version of the game.

What are you using to check that the user’s sequence is the same as the computer’s? That seems to be where the problem lies, which is interesting because it seems to correctly identify when a user hits the wrong button in strict mode, but not in non-strict. Can you use the same function in both instances?


I didn’t experience the crazy blinking this time…well done.

There is still an issue with the wrong choice being counted as correct. It appears that the game will accept any choice for the last color in the sequence. For example, if they computer plays blue and green, it will let me play blue and yellow. Likewise, if it plays blue,green red, it will let me play blue, green, blue. It appears that if I get any other part of the sequence wrong I loose. You may want to look at playTheGame() and consider what is happening with the turnCount incrementer – I think that it may play a role in this issue.

This game is currently always playing in strict mode – there seems to be no way to turn it off. I agree about the indicator of being in strict mode. You could probably get away with just making an ‘strict-on’ class that changes the color of the box shadow around the button to indicate the strict mode is on.

Also, I had the same issues as @jv88899 in regards to not being able to start a new game. It appears that the resetGame resets variables, but there is not call to playTheGame().

Hope this helps!

1 Like


Thank you so much for the feedback. I apologize it took so long to get back to you, I have been offline for a few days recovering from a tooth issue :frowning:

I have gone through my code again based on your suggestions and I believe I have fixed a couple of issues. First, the color checking should now be accurate. It should not longer let you pick any color that you want for the final color. Second, after you lose, the game starts over after three seconds.

If you guys have time, I would really appreciate it if you could go through the game again and confirm that it works correctly for you. I’ll be working on the other issues as well.

Thank you again for all of your suggestions.

@jv88899 Yup! It’s working much better than before in strict mode (however, I still can’t see that I’m in strict mode and seems to be playing in strict whether I select it or not). But still, that part is def working well. I think if you can get the on/off switch working, get non-strict mode working, ad include some kind of indicator that denotes which mode a user is playing in, then you will be in great shape. Nice work so far!

@jv88899 from what I can tell the indicator for strict is working and the game play seems to be working correctly for both strict and nonstrict mode. Also, start and strict are only active when the power switch is on. Good job!

The only two things I would have to add 1) I can still press the colors when the power button is off. It doesn’t do anything but “light up”, but I suppose strictly speaking, it wouldn’t do that while off. 2) I would consider getting rid of the pop-up dialogs when people loose or hit the wrong button. I know that you are trying to indicate that the player missed a color in the sequence, but the popups, to me, are distracting.

Nice work. I’m glad to see that you were able to troubleshoot the issues and get this fixed.

Here’s how it looks for me in Firefox on Lubuntu with 1024 x 768 pixels resolution. Not sure what’s causing this visual issue.

My guess is that it has to do with the font being used by your browser. I get something similar if I increase the font to about 20px. The developer could explicitly set the font size and family, which may fix the issue.

1 Like