#import "@local/handout:0.1.0": *
#import "@preview/cetz:0.4.2"

#show: handout.with(
  title: [Warm-Up: Big-Tac-Toe],
  by: "Mark",
)

#let extra_boards = false;

#let ttt(s, p) = {
  // s: scale,
  // p: position
  let x = p.at(0) * s
  let y = p.at(1) * s

  cetz.draw.line((-1 * s + x, 3 * s + y), (-1 * s + x, -3 * s + y))
  cetz.draw.line((1 * s + x, 3 * s + y), (1 * s + x, -3 * s + y))
  cetz.draw.line((3 * s + x, -1 * s + y), (-3 * s + x, -1 * s + y))
  cetz.draw.line((3 * s + x, 1 * s + y), (-3 * s + x, 1 * s + y))
}

#let btt(s) = cetz.canvas({
  import cetz.draw: *

  set-style(stroke: (thickness: 0.5mm * s))

  ttt(s, (-7, -7))
  ttt(s, (-7, 0))
  ttt(s, (-7, 7))
  ttt(s, (0, -7))
  ttt(s, (0, 0))
  ttt(s, (0, 7))
  ttt(s, (7, -7))
  ttt(s, (7, 0))
  ttt(s, (7, 7))

  set-style(stroke: (thickness: 2mm * s))
  ttt(s * 3.5, (0, 0))
})


#problem()
Consider a large tic-tac-toe grid, each cell of which contains another.
On each turn, one player puts their glyph into a cell of a small grid. When the next player goes,
they must make their move in the small grid in the same position as the previous player's move.
- The first player to move may pick any small grid to start in.
- If a player is directed to a grid that is _full_, that player may go anywhere. \
  A sub-grid that is "won" but not full may still be played in.

#v(2mm)

The first player to complete a line of three "won" subgrids wins the game.

#v(2mm)

#problem()
Play a few rounds of this game with someone nearby. \
Can either player force a win?

#table(
  stroke: none,
  align: center,
  columns: (1fr, 1fr),
  btt(0.35), btt(0.35),
);

#problem()
Modify the rules of this game to disallow play in won subgrids. \
How does your strategy change? \
#if extra_boards { note([Additional boards are available on the next page.]) }

#v(1fr)

#if extra_boards {
  pagebreak()

  align(center, grid(
    stroke: none,
    align: center,
    columns: (1fr, 1fr),
    rows: (1fr, 1fr, 1fr),
    btt(0.35), btt(0.35),
    btt(0.35), btt(0.35),
    btt(0.35), btt(0.35),
  ))
}
