<commit_before>defmodule BattleSnake.GameState do
  alias __MODULE__
  alias BattleSnake.Snake
  alias BattleSnake.World

  @max_history 20

  @statuses [:cont, :replay, :halted, :suspend]

  @typedoc """
  Any function that takes a GameState, and returns a new GameState.
  """
  @type state_fun :: (t -> t)
  @type state_predicate :: (t -> boolean)
  @type uuid :: binary
  @type snake_id :: uuid

  @typedoc """
  A function that, when true, indicates that the game is over.
  """
  @type objective_fun :: state_predicate

  @type t :: %GameState{
    world: World.t,
    objective: objective_fun,
    delay: non_neg_integer,
    hist: [World.t],
    game_form: BattleSnake.GameForm.t,
    winners: [snake_id]
  }

  defstruct([
    :world,
    :objective,
    :game_form_id,
    :snakes,
    game_form: {:error, :init},
    delay: 0,
    hist: [],
    status: :suspend,
    winners: [],
  ])

  @spec cont!(t) :: t
  def cont!(state) do
    put_in(state.status, :cont)
  end

  @spec cont?(t) :: t
  def cont?(state) do
    state.status == :cont
  end

  @spec suspend!(t) :: t
  def suspend!(state) do
    put_in(state.status, :suspend)
  end<commit_msg>Move struct definition above types<commit_after>defmodule BattleSnake.GameState do
  alias __MODULE__
  alias BattleSnake.Snake
  alias BattleSnake.World

  @max_history 20

  @statuses [:cont, :replay, :halted, :suspend]

  defstruct([
    :world,
    :objective,
    :game_form_id,
    :snakes,
    game_form: {:error, :init},
    delay: 0,
    hist: [],
    status: :suspend,
    winners: [],
  ])

  ####################
  # Type Definitions #
  ####################

  @typedoc """
  Any function that takes a GameState, and returns a new GameState.
  """
  @type state_fun :: (t -> t)
  @type state_predicate :: (t -> boolean)
  @type uuid :: binary
  @type snake_id :: uuid

  @typedoc """
  A function that, when true, indicates that the game is over.
  """
  @type objective_fun :: state_predicate

  @type t :: %GameState{
    world: World.t,
    objective: objective_fun,
    delay: non_neg_integer,
    hist: [World.t],
    game_form: BattleSnake.GameForm.t,
    winners: [snake_id]
  }

  @spec cont!(t) :: t
  def cont!(state) do
    put_in(state.status, :cont)
  end

  @spec cont?(t) :: t
  def cont?(state) do
    state.status == :cont
  end

  @spec suspend!(t) :: t
  def suspend!(state) do
    put_in(state.status, :suspend)
  end
{'fraction_non_alphanumeric': 0.1477791614777916, 'fraction_numerical': 0.0024906600249066002, 'mean_word_length': 3.098639455782313, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '1053487', 'n_tokens_mistral': 877, 'n_tokens_neox': 867, 'n_words': 231}