Alice Community  

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

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Comparing individual list elements
Old
todd0312
Member
 
todd0312's Avatar
 
Status: Offline
Posts: 35
Join Date: Sep 2011
Unhappy Comparing individual list elements - 12-12-2011, 01:22 PM

Hey everyone:

Noob here.

I have this Simon game, and the way it is set up now, the "fail" method (if an incorrect circle was pressed) is not initiated until all the circles have been pressed. I want it to initiate as soon as a wrong circle is clicked. (I'm comparing the size - not the individual elements, but my brain is now addled, and I can't figure out a better way to compare).

I created a function called "check_mates" with 2 empty list parameters (list 1, list 2) that returns 1 if the lists are unequal:

If ((size of list)!=(size of list 2))
Return 1
Else: do nothing
Loop (size of list_1) from 0 up to (but not including) size of list 1 incrementing by 1.
If ((item index from list 1)!=(item index from list_2)
Return 1
Else: do nothing

Return 2

Next, I have a method to compare the lists called "world.check_Lists" to compare the variable that stores the moves the program has chosen: "world.program_turn" with the circles clicked by the player ("player_turn") for inequality:
It goes like this:

Do in Order:
If ((world.check_mates list 2 = world.player_turn/list 1=world.program_turn)==1)
world.missed set value to true
world.fail (method to display fail text initiated)
ELSE:
world.main

Can anyone tell from this code where I went wrong? I am a green noob; this is the first game I've ever made, and my head is swimming in variables.

Any advice as to what the problem might be would be greatly appreciated. I'm pretty sure it has something to do with looping the size of list 1 in my function - but this has turned out to be way more complex than I had planned, and my mind is so muddled at this point - that I'm probably missing something obvious.

Thanks in advance. If this wasn't clear, I'd be happy to explain it more fully.

Take care and good cheer,

Todd
   
Reply With Quote
 


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 ©2024, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.