All puzzles › Game Development
Game Development Practice Problems
30 puzzles (9 easy, 18 medium, 3 hard), in Python, JavaScript and C++.
The algorithms inside a game engine. A fixed-timestep loop, A* pathfinding, behavior trees, spatial hashing, object pools, autotiling and a tech tree, thirty puzzles covering every pattern from sliding windows to knapsack.
The puzzles, easiest first
- Back to Front (Easy): Games draw far things first so near things paint over them, which is called the painter's algorithm.
- Cut the Silence (Easy): A recorded sound effect has silence at both ends, which delays it when it plays.
- Find the Stutter (Easy): A stutter is a run of slow frames, and players feel it even when the average frame rate looks fine.
- How Many Bag Slots? (Easy): A player picks up items[i] in amounts counts[i].
- Level Up (Easy): Everyone starts at level 1, and thresholds[i] is the total XP needed to reach level i + 2, in increasing order.
- Off One Edge, On the Other (Easy): Screen wrap turns the world into a loop: fly off the right edge and you come back on the left, as in Asteroids.
- Pause on Top of Play (Easy): Game menus are a stack: the pause menu sits on top of the game, and closing it returns you to exactly the game underneath.
- The Steady Clock (Easy): Every game loop draws frames as fast as the screen allows, but physics has to advance in a fixed timestep or it behaves differently on fast and slow machines.
- Who Is Allowed to Touch? (Easy): Each object has a layer, one bit saying what it is, and a mask, a bitmask of every layer it reacts to.
- Are All the Rooms Connected? (Medium): A dungeon generator has made n rooms and dug some corridors, each joining two rooms.
- Ctrl+Z in the Level Editor (Medium): A level editor gets commands: "place NAME" puts down a tile, "undo" takes back the last placement, and "redo" puts back the last thing undone.
- Don't Eat Yourself (Medium): A snake starts at row 0, column 0 on a board of the given width and height.
- Fewest Jumps to the Flag (Medium): Platforms sit in a row and reach[i] is how many platforms ahead you can jump from platform i.
- Fewest Towers on the Lane (Medium): Enemies spawn at the given spots along a straight lane, in no particular order.
- Keep the Combo Alive (Medium): A fighting game rewards a combo: hits landed close together.
- Last One Standing (Medium): n players numbered 0 to n - 1 sit in a circle.
- Lock On (Medium): Auto-aim locks on to the closest enemies.
- Only Check the Neighbors (Medium): Checking every pair of objects for collisions is O(n squared).
- Pack the Loadout (Medium): Each piece of gear has a weight and a power.
- Recycle the Bullets (Medium): Creating a fresh bullet every shot would make the garbage collector stutter, so games keep an object pool of reusable slots.
- Research Order (Medium): A strategy game's tech tree has n technologies, and each pair [tech, pre] means tech can't be researched until pre is done.
- Spend the Mana (Medium): Each spell has a mana cost and a damage, and each can be cast once.
- Standing on Solid Ground (Medium): A tilemap stores a level as a grid, which turns collision into arithmetic.
- Take the Least Damage (Medium): A hero crosses a trapped room from the top-left tile to the bottom-right, moving only right or down.
- Tiles That Know Their Neighbors (Medium): Autotiling picks each wall's picture from its neighbors, so walls join up into smooth shapes on their own.
- Where Is the Sword, Really? (Medium): In a scene graph every object is placed relative to its parent: a sword relative to a hand, the hand relative to an arm, the arm relative to the knight.
- Which Diamond Did I Click? (Medium): In an isometric game, square map tiles are drawn as diamonds, so finding the tile under the mouse takes a little algebra.
- Chase the Player (Hard): Given a grid where 0 is a wall and any other number is what it costs to step onto that tile (grass 1, swamp 5), return the cheapest cost from the top-left corner to the bottom-right, moving up, down, left or right, or -1 if there's no way through.
- Load It Before They Get There (Hard): An open world streams assets in as you move.
- What Does the Guard Do? (Hard): A guard's AI is a behavior tree.
Practice another pattern
Or browse by subject
Browse all 676 puzzles