<commit_before>defmodule Elixoids.World.Testcard do
  @moduledoc "Starts a game where the entities form a test card layout"

  alias Elixoids.Asteroid.Rock
  alias Elixoids.Asteroid.Server, as: Asteroid
  alias Elixoids.Ship.Server, as: Ship
  alias Elixoids.World.Point
  alias Elixoids.World.Velocity
  import Elixoids.Game.Supervisor, only: [start_game: 1]
  import Elixoids.Space

  def start_testcard do
    [asteroids: 0]
    |> start_game()
    |> corners()
    |> this_way_up
    |> middle()
    |> compass
    |> large_ship
    |> asteroid_sizes()
  end

  defp middle(game = {_, _, game_id}) do
    [w, h] = dimensions()
    ship(game_id, %Point{x: w / 2, y: h / 2}, "MID", 0.0)
    game
  end

  defp compass(game = {_, _, game_id}) do
    [w, h] = dimensions()
    r = h / 4
    origin = %Point{x: w / 2, y: h / 2}

    Enum.each(compass_points(), fn {tag, theta} ->
      p = Velocity.apply_velocity(origin, %{theta: theta, speed: r}, 1000)
      ship(game_id, p, tag, theta)
    end)

    game
  end

  defp large_ship(game = {_, _, game_id}) do
    [w, h] = dimensions()
    p = %Point{x: w * 0.8, y: h / 2}
    north = :math.pi() / 2
    ship(game_id, p, "BFG", north, h / 8)
    ship(game_id, p, "COG", north, 2.0)
    game
  end

  defp this_way_up(game = {_, _, game_id}) do
    [w, h] = dimensions()
    p = %Point{x: w * 0.5, y: h * 0.95}
    north = :math.pi() / 2
    ship(game_id, Point.translate(p, -60, 0), "THI", north)
    ship(game_id, Point.translate(p, 0, 0), "SWA", north)
    ship(game_id, Point.translate(p, 60, 0), "YUP", north)
    game
  end

  defp corners(game = {_, _, game_id}) do
    dimensions()
    |> corner_points()
    |> Enum.each(fn p -> stationary_asteroid(game_id, p) end)

    game
  end

  defp asteroid_sizes(game = {_, _, game_id}) do
    [w, h] = dimensions()
    box = %Point{x: w * 0.1, y: h * 0.8}
    asteroid_boxes(game_id, box, 240.0, 120.0)

    game
  end

  defp corner_points([w, h]) do
    for x <- [0, w], y <- [0, h], do: %Point{x: x, y: y}
  end

  defp stationary_asteroid(game_id, p, r \\ 120.0) do
    asteroid(game_id, p, r, %Velocity{})
  end

  defp asteroid_drifting_west(game_id, p, r) do
    asteroid(game_id, p, r, %Velocity{theta: :math.pi, speed: 4.0})
  end

  defp asteroid(game_id, p, r, v) do
    rock = %Rock{pos: p, velocity: v, radius: r}
    Asteroid.start_link(%{id: game_id}, rock)
  end

  defp asteroid_boxes(game_id, box, box_width, radius) do
    asteroid_box(game_id, box, box_width, radius)<commit_msg>Change mid point to a dot<commit_after>defmodule Elixoids.World.Testcard do
  @moduledoc "Starts a game where the entities form a test card layout"

  alias Elixoids.Asteroid.Rock
  alias Elixoids.Asteroid.Server, as: Asteroid
  alias Elixoids.Ship.Server, as: Ship
  alias Elixoids.World.Point
  alias Elixoids.World.Velocity
  import Elixoids.Game.Supervisor, only: [start_game: 1]
  import Elixoids.Space

  def start_testcard do
    [asteroids: 0]
    |> start_game()
    |> corners()
    |> this_way_up
    |> middle()
    |> compass
    |> large_ship
    |> asteroid_sizes()
  end

  defp middle(game = {_, _, game_id}) do
    [w, h] = dimensions()
    stationary_asteroid(game_id, %Point{x: w / 2, y: h / 2}, 5.0)
    game
  end

  defp compass(game = {_, _, game_id}) do
    [w, h] = dimensions()
    r = h / 4
    origin = %Point{x: w / 2, y: h / 2}

    Enum.each(compass_points(), fn {tag, theta} ->
      p = Velocity.apply_velocity(origin, %{theta: theta, speed: r}, 1000)
      ship(game_id, p, tag, theta)
    end)

    game
  end

  defp large_ship(game = {_, _, game_id}) do
    [w, h] = dimensions()
    p = %Point{x: w * 0.8, y: h / 2}
    north = :math.pi() / 2
    ship(game_id, p, "BFG", north, h / 8)
    ship(game_id, p, "COG", north, 2.0)
    game
  end

  defp this_way_up(game = {_, _, game_id}) do
    [w, h] = dimensions()
    p = %Point{x: w * 0.5, y: h * 0.95}
    north = :math.pi() / 2
    ship(game_id, Point.translate(p, -60, 0), "THI", north)
    ship(game_id, Point.translate(p, 0, 0), "SWA", north)
    ship(game_id, Point.translate(p, 60, 0), "YUP", north)
    game
  end

  defp corners(game = {_, _, game_id}) do
    dimensions()
    |> corner_points()
    |> Enum.each(fn p -> stationary_asteroid(game_id, p) end)

    game
  end

  defp asteroid_sizes(game = {_, _, game_id}) do
    [w, h] = dimensions()
    box = %Point{x: w * 0.1, y: h * 0.8}
    asteroid_boxes(game_id, box, 240.0, 120.0)

    game
  end

  defp corner_points([w, h]) do
    for x <- [0, w], y <- [0, h], do: %Point{x: x, y: y}
  end

  defp stationary_asteroid(game_id, p, r \\ 120.0) do
    asteroid(game_id, p, r, %Velocity{})
  end

  defp asteroid_drifting_west(game_id, p, r) do
    asteroid(game_id, p, r, %Velocity{theta: :math.pi, speed: 1.0})
  end

  defp asteroid(game_id, p, r, v) do
    rock = %Rock{pos: p, velocity: v, radius: r}
    Asteroid.start_link(%{id: game_id}, rock)
  end

  defp asteroid_boxes(game_id, box, box_width, radius) do
    asteroid_box(game_id, box, box_width, radius)
{'fraction_non_alphanumeric': 0.15597609561752987, 'fraction_numerical': 0.02151394422310757, 'mean_word_length': 2.8593389700230594, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 25, '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': '2737633', 'n_tokens_mistral': 2168, 'n_tokens_neox': 2002, 'n_words': 543}