<commit_before>defmodule BattleSnakeServer.PlayView do
  use BattleSnakeServer.Web, :view

  def render("square.html", %{state: state, y: y, x: x}) do
    square = state.map[x][y]

    square_state = square["state"]

    fill = case square_state do
      "head" -> "red"

      "body" -> "blue"

      "food" -> "green"

      _ -> "black"
    end

    style = "fill: #{fill};"

    content_tag(:rect, "", x: x, y: y, width: 1, height: 1, style: style)
  end
end<commit_msg>avoid drawing empty cells<commit_after>defmodule BattleSnakeServer.PlayView do
  use BattleSnakeServer.Web, :view

  def render("square.html", %{state: state, y: y, x: x}) do
    square = state.map[x][y]

    square_state = square["state"]

    rect(square_state, x, y)
  end

  def rect(nil, _, _) do
    ""
  end

  def rect(square_state, x, y) do
    fill = case square_state do
      "head" -> "red"

      "body" -> "blue"

      "food" -> "green"
    end

    style = "fill: #{fill};"

    content_tag(:rect, "", x: x, y: y, width: 1, height: 1, style: style)
  end
end
{'fraction_non_alphanumeric': 0.1601525262154433, 'fraction_numerical': 0.0038131553860819827, 'mean_word_length': 2.763440860215054, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6307796', 'n_tokens_mistral': 399, 'n_tokens_neox': 374, 'n_words': 108}