<commit_before><?php

require_once(__DIR__ . '/../tournament.php');

function generateScenario() {
  $num_players = mt_rand(6, 11);
  $players = [];
  for ($i = 0; $i < $num_players; $i++) {
    $players[] = ['playerId' => chr(65 + $i), 'opponents' => [], 'points' => 0];
  }
  $afterRound1 = playRound($players);
  $afterRound2 = playRound($afterRound1);
  $afterRound3 = playRound($afterRound2, /* lastRound = */   true);
}

function playRound($players, $lastRound = false) {
  echo "=== ROUND ===\n";
  $pairings = (new Pairings($players))->pair();
  $nextRoundPlayers = [];
  foreach ($pairings as $pairing) {
    $pairing[0]['opponents'][] = $pairing[1]['playerId'];
    $pairing[1]['opponents'][] = $pairing[0]['playerId'];

    echo $pairing[0]['playerId'] . " (" . $pairing[0]['points'] . ") is playing " . $pairing[1]['playerId'] . " (" . $pairing[1]['points'] . ")\n";

    // Random result of match
    $result = mt_rand(0, 5);
    if ($result === 0 && $pairing[0]['playerId'] !== 0 && $pairing[1]['playerId'] !== 0) {
      $pairing[0]['points'] += 1;
      $pairing[1]['points'] += 1;
      echo $pairing[0]['playerId'] . " and " . $pairing[1]['playerId'] . " Draw\n";
    } elseif ($result <= 3 || $pairing[0]['playerId'] !== 0) {
      $pairing[0]['points'] += 3;
      echo $pairing[0]['playerId'] . " wins\n";
    } else {
      $pairing[1]['points'] += 3;
      echo $pairing[1]['playerId'] . " wins\n";
    }
    if ($lastRound) {
      // you can't drop after the last round.
      continue;
    }
    // Simulate drops
    if (mt_rand(0, 5) !== 0 && $pairing[0]['playerId'] !== 0) {
      $nextRoundPlayers[] = $pairing[0];
    } else if ($pairing[0]['playerId'] !== 0) {
      echo $pairing[0]['playerId'] . " drops\n";
    }
    if (mt_rand(0, 5) !== 0 && $pairing[1]['playerId'] !== 0) {
      $nextRoundPlayers[] = $pairing[1];
    } else if ($pairing[1]['playerId'] !== 0) {
      echo $pairing[1]['playerId'] . " drops\n";
    }
  }
  return $nextRoundPlayers;<commit_msg>Standardize on elseif not else if.<commit_after><?php

require_once(__DIR__ . '/../tournament.php');

function generateScenario() {
  $num_players = mt_rand(6, 11);
  $players = [];
  for ($i = 0; $i < $num_players; $i++) {
    $players[] = ['playerId' => chr(65 + $i), 'opponents' => [], 'points' => 0];
  }
  $afterRound1 = playRound($players);
  $afterRound2 = playRound($afterRound1);
  $afterRound3 = playRound($afterRound2, /* lastRound = */   true);
}

function playRound($players, $lastRound = false) {
  echo "=== ROUND ===\n";
  $pairings = (new Pairings($players))->pair();
  $nextRoundPlayers = [];
  foreach ($pairings as $pairing) {
    $pairing[0]['opponents'][] = $pairing[1]['playerId'];
    $pairing[1]['opponents'][] = $pairing[0]['playerId'];

    echo $pairing[0]['playerId'] . " (" . $pairing[0]['points'] . ") is playing " . $pairing[1]['playerId'] . " (" . $pairing[1]['points'] . ")\n";

    // Random result of match
    $result = mt_rand(0, 5);
    if ($result === 0 && $pairing[0]['playerId'] !== 0 && $pairing[1]['playerId'] !== 0) {
      $pairing[0]['points'] += 1;
      $pairing[1]['points'] += 1;
      echo $pairing[0]['playerId'] . " and " . $pairing[1]['playerId'] . " Draw\n";
    } elseif ($result <= 3 || $pairing[0]['playerId'] !== 0) {
      $pairing[0]['points'] += 3;
      echo $pairing[0]['playerId'] . " wins\n";
    } else {
      $pairing[1]['points'] += 3;
      echo $pairing[1]['playerId'] . " wins\n";
    }
    if ($lastRound) {
      // you can't drop after the last round.
      continue;
    }
    // Simulate drops
    if (mt_rand(0, 5) !== 0 && $pairing[0]['playerId'] !== 0) {
      $nextRoundPlayers[] = $pairing[0];
    } elseif ($pairing[0]['playerId'] !== 0) {
      echo $pairing[0]['playerId'] . " drops\n";
    }
    if (mt_rand(0, 5) !== 0 && $pairing[1]['playerId'] !== 0) {
      $nextRoundPlayers[] = $pairing[1];
    } elseif ($pairing[1]['playerId'] !== 0) {
      echo $pairing[1]['playerId'] . " drops\n";
    }
  }
  return $nextRoundPlayers;
{'fraction_non_alphanumeric': 0.24670151854617875, 'fraction_numerical': 0.029873039581777446, 'mean_word_length': 3.3065380493033225, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, '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': '2050040', 'n_tokens_mistral': 1539, 'n_tokens_neox': 1480, 'n_words': 282}