Alice Community  

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

Reply
 
Thread Tools Display Modes
Going through a list
Old
CloudMagic
Junior Member
 
Status: Offline
Posts: 2
Join Date: Nov 2012
Location: Massachussettes
Default Going through a list - 12-09-2012, 02:29 PM

Hello Alice Community,

I'm working on a game where I need to incremently go through a list. I need to check the object at the current spot in a list, and if it evaluates to the same object in the current list spot, I want to move along, etc. etc.

pseudocode

var/increment = 1
if(generatedlist[increment] is the same object as the one you clicked on)
increment the value and continue this procedure

Please help
   
Reply With Quote
traverse a list
Old
djslater107
Administrator
 
Status: Offline
Posts: 155
Join Date: Jan 2007
Default traverse a list - 12-10-2012, 09:37 AM

Alice 2.3 has an array structure that can be used instead of a list...

When setting up the collection, specify that you want an array by choosing array from the drop down menu you get when you click on list (see the attached screen shot)...

Then set up a while loop structure to traverse the array, the ending condition being "not the object clicked on"...

<start pseudocode>

arrayIndex = 0;
while (arrayIndex < (size of the array) AND (NOT the object clicked on))
arrayIndex = arrayIndex + 1;

<end pseudocode>

Hope this helps.
Attached Images
File Type: jpg arrayChoice.jpg (7.9 KB, 23 views)


Don Slater
Alice Team
Carnegie Mellon University
   
Reply With Quote
Old
CloudMagic
Junior Member
 
Status: Offline
Posts: 2
Join Date: Nov 2012
Location: Massachussettes
Default 12-10-2012, 03:56 PM

Quote:
Originally Posted by djslater107 View Post
Alice 2.3 has an array structure that can be used instead of a list...

When setting up the collection, specify that you want an array by choosing array from the drop down menu you get when you click on list (see the attached screen shot)...

Then set up a while loop structure to traverse the array, the ending condition being "not the object clicked on"...

<start pseudocode>

arrayIndex = 0;
while (arrayIndex < (size of the array) AND (NOT the object clicked on))
arrayIndex = arrayIndex + 1;

<end pseudocode>

Hope this helps.
What do you mean by NOT the object clicked on? What do I compare the object clicked on with, I'm assuming the object at the specified array index ... How do I program this comparison?

   
Reply With Quote
Reply

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