PracHub
QuestionsCoachesLearningGuidesInterview Prep
|Home/Software Engineering Fundamentals/Asana

Design a Testable 2048 Game Engine

Last updated: Jul 18, 2026

Quick Overview

Design a testable 2048 game engine with correct movement, merging, restart, and game-over behavior. Explore clean object boundaries, injected tile generation, immutable board exposure, multiple stored games, concurrency, and deterministic tests.

  • medium
  • Asana
  • Software Engineering Fundamentals
  • Software Engineer

Design a Testable 2048 Game Engine

Company: Asana

Role: Software Engineer

Category: Software Engineering Fundamentals

Difficulty: medium

Interview Round: Technical Screen

# Design a Testable 2048 Game Engine Design the object model and core operations for a 2048 game. The engine must create a game, return the current board, apply a move in any of four directions, restart, and report whether the game is over. It should also be possible for an application service to store and retrieve multiple independent games. For one line in a move, nonzero tiles slide toward the chosen side. Equal adjacent values then merge once per move, from the movement side outward, and the resulting tiles slide again. A successful board-changing move asks a supplied tile generator for the next tile; an unchanged move does not. Focus on domain logic, not user-interface rendering. ### Constraints & Assumptions - Board size is configurable and at least two. - The tile generator is injected so tests can control placement and value. - A returned board must not let callers mutate the engine's state. - Define whether “game over” means no empty cell and no legal merge, independent of reaching a target tile. ### Clarifying Questions to Ask - Should the engine track score and move history? - Is undo required, and are games persisted across process restarts? - Can two clients submit moves to the same game concurrently? - What should happen if the tile generator cannot find an empty cell? ### What a Strong Answer Covers - Separation of board transformation, game lifecycle, randomness, and repository concerns - Correct one-merge-per-tile behavior for tricky lines - No-op move handling, defensive state exposure, and game-over detection - A concurrency or versioning strategy for multiple stored games - Deterministic unit tests for movement and restart ### Follow-up Questions - What should `[2, 2, 2, 2]` become after a move to the left? - How would you make replay deterministic? - Where should score calculation live? - How would the design support a different board size or spawning policy?

Quick Answer: Design a testable 2048 game engine with correct movement, merging, restart, and game-over behavior. Explore clean object boundaries, injected tile generation, immutable board exposure, multiple stored games, concurrency, and deterministic tests.

Related Interview Questions

  • Design an Extensible Animal-Chess Game Engine - Asana (medium)
  • Model and Solve a Rectangular Jigsaw Puzzle - Asana (medium)
  • Design and Solve a Rotatable Jigsaw Puzzle - Asana (medium)
  • Design a 2048 Game - Asana (medium)
|Home/Software Engineering Fundamentals/Asana

Design a Testable 2048 Game Engine

Asana logo
Asana
Jul 2, 2026, 12:00 AM
mediumSoftware EngineerTechnical ScreenSoftware Engineering Fundamentals
2
0

Design a Testable 2048 Game Engine

Design the object model and core operations for a 2048 game. The engine must create a game, return the current board, apply a move in any of four directions, restart, and report whether the game is over. It should also be possible for an application service to store and retrieve multiple independent games.

For one line in a move, nonzero tiles slide toward the chosen side. Equal adjacent values then merge once per move, from the movement side outward, and the resulting tiles slide again. A successful board-changing move asks a supplied tile generator for the next tile; an unchanged move does not. Focus on domain logic, not user-interface rendering.

Constraints & Assumptions

  • Board size is configurable and at least two.
  • The tile generator is injected so tests can control placement and value.
  • A returned board must not let callers mutate the engine's state.
  • Define whether “game over” means no empty cell and no legal merge, independent of reaching a target tile.

Clarifying Questions to Ask

  • Should the engine track score and move history?
  • Is undo required, and are games persisted across process restarts?
  • Can two clients submit moves to the same game concurrently?
  • What should happen if the tile generator cannot find an empty cell?

What a Strong Answer Covers

  • Separation of board transformation, game lifecycle, randomness, and repository concerns
  • Correct one-merge-per-tile behavior for tricky lines
  • No-op move handling, defensive state exposure, and game-over detection
  • A concurrency or versioning strategy for multiple stored games
  • Deterministic unit tests for movement and restart

Follow-up Questions

  • What should [2, 2, 2, 2] become after a move to the left?
  • How would you make replay deterministic?
  • Where should score calculation live?
  • How would the design support a different board size or spawning policy?
Loading comments...

Browse More Questions

More Software Engineering Fundamentals•More Asana•More Software Engineer•Asana Software Engineer•Asana Software Engineering Fundamentals•Software Engineer Software Engineering Fundamentals

Write your answer

Your first approved answer each day earns 20 XP.

Sign in to write your answer.
PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • AI Coding Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.