Alice Community  

Go Back   Alice Community > Alice 2 > How do I...?

Thread Tools Display Modes
Re: Simon
todd0312's Avatar
Status: Offline
Posts: 35
Join Date: Sep 2011
Default Re: Simon - 12-08-2011, 06:23 AM

Hey Blunted_what:

This is what I did to compare the lists, though I don't know if it's the best way. I'm a beginner muddling my way through.

Create a global function that contains 2 empty lists as the parameters. Create an if-else statement comparing the size of the 2 parameter lists, and have it return 1 if they are not equal. Then add a loop to the function containing another if-else statement comparing the list parameters for inequality, looping the size of one of the lists and using the same conditions you did in the first if-else statement except using "item" instead of "size", and returning 1 if they are not equal. After the loop block, return 2 if they are equal (the inequality conditions in the upper blocks are not true.

Next, create a method that calls the function you created to compare the lists. You will also need a boolean variable that you will use as a condition in the case that the player has selected the wrong sequence of squares - set to false in global properties.

In this method, create an if-else statement, and drag the function you created after if, using the logic statement "= 1" (the 2 lists are unequal and have returned "1", as stated in your function). If this is the case, set your variable for wrong selection = true, and call the method you created for what happens if the player made the wrong selection.

If the condition is not true, have the program go back to the beginning method so Simon can continue with the game.

Does that make sense?

Hope it helps. If you have any questions, post again - I'll be checking your post.

Take care,


Last edited by todd0312; 12-08-2011 at 06:30 AM.
Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Copyright ©2023, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.