Simon Says app issues

Hello
So I'm trying to make the game 'Simon Says' for a school assignment and Im experiencing some issues.
When Im running the app, I get an error saying 'trying to remove item 1 from an empty list'.
I was hoping if someone could help me out.
Thanks in advance




image

In your showOldItems procedure, you check to see if the list is empty and then proceed to call pickNewItem, which tries to get items from the empty list. Either don't call pickNewItem or repopulate your list with items before the call.

Hey, thanks for the quick reply.
Do you think this is a good fix?
image

I'm not sure that would really solve your problem. What happens when you play the game with that change?

The moment I press Start the first square gets indicated.
Then after a short time I get an error
image
My guess is that I have to make a function that inserts an answer before it continues.

I think that might be due to a logic bug in your compare method. Think/talk through the code you wrote in the if block.

Hmm Ive been looking at it and I dont see the logic bug in there. Could you enlighten me please?

as it seems to be in your procedure clearList you are trying to clear 2 lists?
if yes, just set the lists to create empty list

also for lists let me recommend you to use a prefix for the variable names, i.e. rather than the variable name playerChosen use listPlayerChosen...

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

Hey Taifun, Thanks for the answer. It did fix the error but unfortunately it doesnt end there :frowning:
image
This error remains. For now.

Your list only has 1 item in it.

use Do it to debug your blocks, see also tip 4 here https://puravidaapps.com/learn.php
see also Live Development, Testing, and Debugging Tools
Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

Simon can be made simpler if you use 3 lists:

  • the list of Computer choices, growing by 1 item each successful round
  • a temporary copy of the Computer choices list for the timed display sequence, flashing and depleting item 1 each timer cycle until empty
  • a temporary copy of the Computer choices for the player to nibble away until empty, guessing item 1 (if not empty list) then either removing item1 if success, else replenishing the timed display list and the to-guess list if wrong. If correct guess and the guess list is now empty, add a new random item to the Computer choice list.

This approach eliminates the need for counter variables and index variables, since you always work with just item 1 (if not empty).