Alice Community A question about arrays and boolean

 A question about arrays and boolean
 cubeNoob Junior Member   Status: Offline Posts: 4 Join Date: Nov 2011 Location: North Carolina A question about arrays and boolean - 12-03-2011, 03:08 PM is it possible to put all items in an array into a boolean function? example: if all objects (a, b, c) are within 1 meter of object d then true thanks any help will be most appreciated
 Mr Kidnapper Senior Member   Status: Offline Posts: 442 Join Date: Feb 2011 12-03-2011, 05:42 PM It's the other way around. Use a Do All Together block and insert an if/else statement in there. It will check the if/else statement on all items in an array at the same time.
 well....
cubeNoob
Junior Member

Status: Offline
Posts: 4
Join Date: Nov 2011
Location: North Carolina
well.... - 12-03-2011, 06:20 PM

so i tried that, unfortunately when i try to loop it or use a recursive method on it it throws an error. im trying to create a win situation for a rubiks cube program. program works fine but the win situation doesnt i feel like i have tried everything ill post my program so you can see what im talking about, look in the events for my win conditions and look at the back square and front square objects for the methods used to create my win situation. any advice is much appreciated
Attached Files
 cube project methods.a2w (5.51 MB, 8 views)

 Mr Kidnapper Senior Member   Status: Offline Posts: 442 Join Date: Feb 2011 12-03-2011, 06:43 PM I have no idea what this is win situation is trying to do. I also do not understand how the criteria for winning is chosen. Now, the way I would do it is by detecting a number of matching pieces. For each side there is an array of 6 numbers, each representing a color. This number goes from 1-9, and when one of the numbers in the array equal 9, the side is considered complete. You can do this by making a For All In Order to check for a 9, which will mark a true/false variable named colorComplete or something true, and this will be done for all 6 sides until all 6 equal true. After all of them equal true at the same time, winner sequence.
 hmm
 cubeNoob Junior Member   Status: Offline Posts: 4 Join Date: Nov 2011 Location: North Carolina hmm - 12-03-2011, 07:12 PM i only see one problem with that solution, when solving a rubiks cube there are often times when there sides that are solved and then you have to unsolve the side to solve another, will it detect when you unsolve a side and re-solve it?
 Mr Kidnapper Senior Member   Status: Offline Posts: 442 Join Date: Feb 2011 12-03-2011, 07:20 PM I imagine you would be able to figure out that it would mark the sides as solved or unsolved by yourself, since it's supposed to check the sides every time a turn is made.
 =(
 cubeNoob Junior Member   Status: Offline Posts: 4 Join Date: Nov 2011 Location: North Carolina =( - 12-03-2011, 08:21 PM well i appreciate your advice, unfortunately i cant figure out how to put it into alice lol i feel like such a noob
davidghemer
Member

Status: Offline
Posts: 38
Join Date: Nov 2011
12-05-2011, 05:07 PM

The attached world contains a function, faceSameColour, which tests whether an array with nine elements contains the same values (it is with the World object functions). You could use this by representing each face of the cube with an array of 9 elements. Each element of the array is a number, different numbers represent different colours.

The cube will be solved if each face of the cube satisfies the faceSameColour function.

Importantly you need some abstract representation of the cube before you can do any tests.
Attached Files
 cube_test.a2w (168.9 KB, 3 views)

For video tutorials on programming in Alice 2.2 check out my YouTube channel

Also check out my Programming in Alice blog at

http://programminginalice.com

 Thread Tools Display Modes Linear Mode

 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 Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Announcements     Community News and Announcements Alice 3     How Do I?     Works In Progress     Share Your World     Share Custom Classes     Bugs and Trouble Shooting     Suggestion Box Alice 2     How do I...?     Works-In-Progress     Share Worlds     Share Objects     Bugs and Troubleshooting     Suggestion Box Educators     Teaching with Alice     Teaching Using Alice 3     Teaching Using Alice 2     CS Principles and Alice     AP CSA and Intro to Java and Alice     Workshops General Discussion     Questions and Comments     The Lounge