Design and implement core Tetris game logic
Problem Description
Design and implement the core game logic for Tetris, suitable for execution within a terminal environment without a graphical user interface.
Requirements
- Board Dimensions: A standard grid of
width = 10andheight = 20. - Tetrominoes: Support all 7 standard pieces:
I, O, T, S, Z, J, L. - Piece Manipulation: Implement functionality for piece rotation, left/right movement, soft drop (accelerated descent), and hard drop (instant descent to the lowest possible position).
- Gravity: The active piece must automatically move down periodically. When it can no longer move down, it locks into place on the board.
- Line Clears: Detect and remove full rows, shifting all rows above down to fill the gap.
- Game Over Condition: The game ends when a new piece cannot be spawned due to insufficient space.
Deliverables
- A well-structured and clean implementation.
- A simple terminal-based game loop (text rendering is acceptable) or a robust API that a separate terminal loop can interact with.
- Primary emphasis on correctness and code organization, particularly for testability, rather than advanced UI features.
Candidate Decisions & Documentation
Candidates are expected to make and document decisions regarding the following aspects:
- Rotation System: For example, whether to implement simple wall kicks or no wall kicks.
- Scoring Rules: Simplified scoring rules are acceptable.
- Random Piece Generation: For example, using a 7-bag system versus uniform random generation.
AI interview prep
Core dilemma
Managing complex, real-time state transitions and collision detection on a grid, under various user inputs and timed events, while maintaining a clean, testable architecture.
3 tradeoffs and 2 stress tests locked
Interview prep
Unlock the interviewer X-Ray rubric, tradeoff matrix, stress tests, clarifying questions, and key concepts.
Design and implement core Tetris game logic
Problem Description
Design and implement the core game logic for Tetris, suitable for execution within a terminal environment without a graphical user interface.
Requirements
- Board Dimensions: A standard grid of
width = 10andheight = 20. - Tetrominoes: Support all 7 standard pieces:
I, O, T, S, Z, J, L. - Piece Manipulation: Implement functionality for piece rotation, left/right movement, soft drop (accelerated descent), and hard drop (instant descent to the lowest possible position).
- Gravity: The active piece must automatically move down periodically. When it can no longer move down, it locks into place on the board.
- Line Clears: Detect and remove full rows, shifting all rows above down to fill the gap.
- Game Over Condition: The game ends when a new piece cannot be spawned due to insufficient space.
Deliverables
- A well-structured and clean implementation.
- A simple terminal-based game loop (text rendering is acceptable) or a robust API that a separate terminal loop can interact with.
- Primary emphasis on correctness and code organization, particularly for testability, rather than advanced UI features.
Candidate Decisions & Documentation
Candidates are expected to make and document decisions regarding the following aspects:
- Rotation System: For example, whether to implement simple wall kicks or no wall kicks.
- Scoring Rules: Simplified scoring rules are acceptable.
- Random Piece Generation: For example, using a 7-bag system versus uniform random generation.