Making A Puzzle App With Unity
Yesterday I was asked about things that require computer programming in a virtual reality simulation made with the Unity game engine. I invented a Box Packing Simulator to help explain a few concepts.
Imagine a simple VR puzzle app that's about filling a large box with smaller boxes of varying size, leaving the least possible unfilled space. An open box rests on the floor with smaller, closed boxes scattered around. The control interface affords picking up small boxes and placing them inside of the large box with Oculus Touch controllers or the like. A player's score factors total attempts, elapsed time, and unfilled space remaining at the end of a round.
The app generates quasi-random box sizes and shapes using rules instead of a lookup table. Box generator code spawns subsidiary code chunks defining individual box dimensions. This box-making parent object generates child box objects with characteristics of game world objects, all in code. The Unity game engine employs dimensions stored in child box object code to generate a visible box. This is object-oriented programming. To avoid weirdly shaped boxes, their dimensions are limited by rules or heuristics. It's an algorithm employed by the box-making parent object to test boxes for game world eligibility.
The box generator could adapt dynamically to the player's strategy, making the puzzle more or less difficult. Box dimensions could derive from the probability or tendency a player has to choose a particular box size or shape. The app could independently direct players to improve their performance in a prescribed fashion based on past performance while referencing an ideal performance model. The more use it gets, the more effective the puzzle's box generator becomes, evolving its performance model over time. This is artificial intelligence. With any luck, it seems like a sentient box maker learns from and responds competitively to a player's technique.
The app also needs code enabling Oculus Touch controllers to pick up, rotate, position, and release boxes. Also needed are scoring and GUI management functions. Writing code for the app could take five hundred hours or more. Reusing code chunks in other products can help defray costs. The box packing AI could become a Unity prefab or plugin, as could the input controller functions for manipulating boxes. Unity's Asset Store is a marketplace for selling such plugins and prefabs.
T.M.Wilcox, March, 2017