Design tic-tac-toe
easy 70 minModel a game everybody knows: marks on a grid, turns, a full line wins.
Watch lesson4:32
Explain your choices
Answer first. Then compare your reasoning.
13 questions 0 got it 0 to review13 not marked
Defend
Choice, reason, cost, trigger
| Choice | Reason | Cost | I would change it when |
|---|---|---|---|
| Counters | Any size in O(1) | Must follow undo | A win is not a full line |
| Moves as history | Small, replayable | Opposites | Pictures are needed at once |
Mark in play | Wrong callers are seen | One argument | Only one local caller, ever |
| Enum for status | One event | None | Pause, offer, resign |
| Cells as values | No behaviour | None | Squares with bonuses |
| No lock | One game, one thread | None | A server: one for each game |
Which way to undo?
WorksKeep a copy of the board for each move
- How
- Nine pictures.
- Limit
- n squared for each move. For n = 1,000 a million squares a move.
- Choose when
- Small boards, user interfaces with immutable values.
StrongOpposites of the last move
- How
- Clear, uncount, give back the turn.
- Limit
- Each change needs an owner with an opposite.
- Choose when
- The base design.
BreaksSwitch the turn and clear the last square
- How
- Two lines in the screen.
- Limit
- The counts stay. After a win the turn is wrong.
- Choose when
- Never.