Puzzle 2 - First Attempt
Puzzle 2 Algorithm A number sorting puzzle was created by myself that could be implemented into the final game. This uses Marco’s Gravity Gun code in order to move cubes around. This puzzle went through 2 iterations, and was changed based off user feedback and the fact the first version didn’t really work at all.
Puzzle Type 1:
The puzzle is to make all the numbers on the cubes be in ascending order. The puzzle is built in the game world, and instantiates additional objects on startup which act as lock on points, so that the cubes will snap in place. In a actual game, these would probably be invisible and the puzzle built into a wall.
The first algorithm used was Binary Search, the idea being that it would return true if the number in sequence was found. Here is the function for the binary search.
The first algorithm used was Binary Search, the idea being that it would return true if the number in sequence was found. Here is the function for the binary search.
Binary searches only work on sorted arrays, so the theory was that it would check against the array and see if it sorted. There is an invisible object which stored the current ordering of the numbers and this object’s list variable is updated based on how the the player moves the boxes around by sending the box’s variable. If a box was in order, further code was applied to make the box green. (If the Binary Search function returned true, the box would become green, otherwise the box would become red).
For this initial version, each box had its texture and number applied manually, and the original ordering of the boxes was also applied to the invisible object by hand. In retrospect, this is a very poor way of handling it, as it means to edit the puzzle at a later date would require changing a lot of variables. To make every cube detect at once whether they were in order, I used a event that triggered whenever a cube’s collision state changed.
The event would then run the binary search and the cubes would try to detect whether or not they were in the sequence.
While initial testing seemed to show this to work, a later usability test showcased that putting in the cubes backwards would cause the wrong cube to light up.
For this initial version, each box had its texture and number applied manually, and the original ordering of the boxes was also applied to the invisible object by hand. In retrospect, this is a very poor way of handling it, as it means to edit the puzzle at a later date would require changing a lot of variables. To make every cube detect at once whether they were in order, I used a event that triggered whenever a cube’s collision state changed.
The event would then run the binary search and the cubes would try to detect whether or not they were in the sequence.
While initial testing seemed to show this to work, a later usability test showcased that putting in the cubes backwards would cause the wrong cube to light up.
Comments
Post a Comment