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.
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
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.
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?
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.
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.
For video tutorials on programming in Alice 2.2 check out my YouTube channel