InterviewDB Question

Turn-based Game - Simulate Game State and Determine Valid Moves

Question Details

Problem Implement a turn-based game engine for a simplified strategy game on an n x n grid. Two players alternate turns. Each turn, a player moves one of their pieces to an adjacent cell (up/down/left/right). A piece captures an opponent piece by moving onto its cell. The game ends when one player has no pieces left. Implement: move(player, from_pos, to_pos) - execute a move or raise if invalid. valid_moves(player) -> List[Tuple] - all legal moves for the player. is_game_over() -> bool winner()…

Full Details

🔒

Unlock all Two Sigma questions

Full insider details, leaked discussions, and candidate experiences.

Get full access — $100 a year, unlimited access

About This Question

This is a reported interview question from a two sigma interview during the phone round.

It covers the following topics: Coding, Phone, Onsite, Matrix .