   @moduledoc """
   """
 
-  defstruct [:squares]
+  defstruct [:grid]
 
   alias LexibombServer.Board
   alias LexibombServer.Board.Square


  def new(size \\ @default_size) do
    border = 2
    squares =
      empty_board(size + border)
      |> deactivate_border

    Agent.start_link(fn -> %Board{squares: squares} end)
  end

  def empty_board(size) do
    for row <- 0 .. (size - 1),
        col <- 0 .. (size - 1),
        into: %{},
        do: {{row, col}, %Square{}}
  end

  def deactivate_border(squares) do
    coords = Map.keys(squares)
    size = size(squares)
    border_coords = Enum.filter(coords, &border_square?(&1, size))

    Enum.reduce(border_coords, squares, &deactivate/2)
  end

  def size(squares) when is_map(squares) do
    squares
    |> map_size
    |> :math.sqrt
    |> round
  end

  def size(board) do
    board.squares |> size
  end

  def border_square?(coord, size) do

    end
  end

  def deactivate(coord, grid) do
    grid |> Map.update!(coord, &Square.deactivate/1)
  end

  def get(pid) do
