Revitalizing the second puzzle.

Following it's failure in the usability test, the second puzzle was reworked from the ground up.

For a start, the cubes that were to be moved around were made into a prefab, so they could be recreated in the game world easier. I also made the current texture of the cube change based on what variable the number of the box was set to, rather than assigning the textures manually. The textures it could choose from were themselves stored in a list, and modified in the Unity editor. This means in theory I could replace the numbers with just about anything (such as shapes) and could have a similar puzzle with a very different context.

I decided the optimum way of making the puzzle was to have a simple check against a value in a list, and to see whether or not it matched the current box number of the cube.
To make the puzzle easier to edit and rearrange, the list that the current layout of cubes was to check against was sorted at the beginning of the game with Quicksort, a divide and conquer algorithm.

Quicksort works by selecting a number as a pivot, and placing all numbers lower or equal to that number behind the pivot, and the rest greater than the pivot. This is done recursively. I chose the initial pivot point to be the middlemost number in the sequence, but this could also be done randomly.
Quicksort usually has a complexity of O(n log n), but at worst case its O(n²), depending on whether the number chosen is at the end of the sorted sequence. Still, since I am working with a small list, the impact on the program will be minimal. For this puzzle, the algorithm is only run once, rather than repeatedly like the original version of the puzzle.
Once the current numbers were sorted, this sorted list was stored in an invisible object and used to check against each individual cube as they were moved about. (Green means the cube is in the correct position, red means it isn't.)

Each cube has three states, the initial setup (-1),  wherein the cube finds out which position it is currently in, 0, in which case it is ready to connect to a lock point prefab, and 1, wherein the cube is connected and no further code should be run. If the cube is removed from the lock point, the state is set to 0


The new approach for this puzzle, a cube will only light up green if it is in the correct position, which should make the puzzle easier to figure out.

Comments

Popular posts from this blog

102CR Portfolio

Puzzle 2 - First Attempt

Early Game Puzzle - Finding the Terrorist