<commit_before><!DOCTYPE html>

<html>
  <head>
    <link rel="stylesheet" type="text/css" href="style.css">
    <script src="createjs-2015.11.26.min.js"></script>
    <script>
      //Colors and static variables
      var ENEMYC = "#bf1818";
      var PICKUPC = "#edd95c";
      var COREC = "#47d7f7";
      var FRAMERATE = 60;

      //Stage/shape drawer initialised, can be used in multiple functions
      var shape = new createjs.Shape();
      var stage = null;
      var text = null;

      //Game state
      var playerList = [];
      var enemyList = [];
      var powerupList = [];
      var core = null;

      //Initialisation and update functions

      //Initialise gameCanvas - initialise stage, add shape drawer
      function init() {
        stage = new createjs.Stage("gameCanvas");
        stage.addChild(shape);
        createjs.Ticker.framerate = FRAMERATE;
        createjs.Ticker.addEventListener("tick", handleTick);
      }

      //Tick handler, clears graphics, draws FPS, updates canvas
      function handleTick(event) {
        if (!event.paused) {
          shape.graphics.clear();
          drawFPS();
          updateCanvas();
        }
      }

      //Clear shape drawer, then draw game state to gameCanvas
      function updateCanvas() {
        drawList(playerList, null);
        drawList(enemyList, ENEMYC);
        drawList(powerupList, PICKUPC);
        if (core != null) {
          drawTriangle(core.pos, core.vel, core.radius, COREC);
        }
        stage.update();
      }

      //Pause game, update pause button
      function togglePause() {
        createjs.Ticker.paused = !createjs.Ticker.paused;
        var b = document.getElementById("pauseButton");
        b.innerHTML = (createjs.Ticker.paused) ? "Unpause" : "Pause";
      }

      //Drawing Functions

      //Function to draw the ticker's FPS to the screen
      function drawFPS() {
        var fps = createjs.Ticker.getMeasuredFPS();
        if (text == null) {
          text = new createjs.Text(fps, "20px Arial", "x000000");
          text.x = 10;
          text.y = 10;
          stage.addChild(text);
        } else {
          text.text = fps;
        }
      }

      //Draws a triangle facing the direction from vector vel
      function drawTriangle(pos, vel, radius, color) {
        var angle = Math.atan2(vel.y, vel.x) * 180 / Math.PI;
        shape.graphics.beginFill(color).drawPolyStar(pos.x, pos.y, radius, 3, 0,
                                                      angle);
      }

      /* Draw every object in a list - if color not provided then color is
       * obtained from the list objects */
      function drawList(list, color) {
        var isPlayer = false;
        if (color == null)
          isPlayer = true;

        for (i = 0; i < list.length; i++) {
          if (isPlayer)
            color = list[i].color;
          drawTriangle(list[i].pos, list[i].vel, list[i].radius, color);
        }
      }

      //Game state altering functions

      //Convert JSON string json to object, set game state accordingly
      function processJSON(json) {
        var obj = JSON.parse(json);
        playerList = obj.players;
        enemyList = obj.enemies;
        powerupList = obj.powerups;
        core = obj.core;
      }

      //Function to reset game state
      function resetState() {
        playerList = [];
        enemyList = [];
        powerupList = [];
        core = null;
      }

      //Test Functions
      //Set game state to test config
      function testCanvas() {
        playerList = [{"tag": 0, "healthMax": 100, "health": 100, "ammo": 10,
                      "name": "Bob", "color": "#5dfc5d",
                      "pos": { "x": 50, "y": 100 },
                      "vel": { "x": 1, "y": 0 }, "radius": 10 }];
        enemyList = [{ "tag": 0, "healthMax": 100, "health": 100,
                      "pos": { "x": 234, "y": 323 },
                      "vel": { "x": 0, "y": 1 }, "radius": 10 }];
        powerupList = [{ "tag": 0, "healthMax": 100, "health": 100,
                      "pos": { "x": 546, "y": 121 },
                      "vel": { "x": 0, "y": -1 }, "radius": 10 }];
        core = { "tag": 0, "healthMax": 100, "health": 100,
                      "pos": { "x": 900, "y": 400 },
                      "vel": { "x": -1, "y": 0 }, "radius": 10 };
      }

      /* Set game state to test config, convert to JSON, then clear game state
       * and set game state by JSON parsing */
      function testJSON() {
        testCanvas();
        var obj = {"players": playerList, "enemies": enemyList,
                    "powerups": powerupList, "core": core};
        var sjson = JSON.stringify(obj);
        resetState();
        processJSON(sjson);
      }

    </script>
  </head>

  <body onload="init()">
    <canvas id="gameCanvas" class="gameCanvas" width="960" height="600">
    </canvas>
    <div class="outer">
      <div class="controls">

      //Pause game
      function togglePause() {
        createjs.Ticker.paused = !createjs.Ticker.paused;
        var b = document.getElementById("pauseButton");
        b.innerHTML = (createjs.Ticker.paused) ? "Unpause" : "Pause";
      }
        <button onclick="testCanvas()">Test Canvas No JSON</button>
        <button onclick="testJSON()">Test Canvas JSON</button>
        <button onclick="resetState()">Clear Game State</button>
        <button id="pauseButton" onclick="togglePause()">Pause</button>
      </div>
    </div>
  </body>
</html>
<commit_msg>[DD] Relocated functions for clarity<commit_after><!DOCTYPE html>

<html>
  <head>
    <link rel="stylesheet" type="text/css" href="style.css">
    <script src="createjs-2015.11.26.min.js"></script>
    <script>
      //Colors and static variables
      var ENEMYC = "#bf1818";
      var PICKUPC = "#edd95c";
      var COREC = "#47d7f7";
      var FRAMERATE = 60;

      //Stage/shape drawer initialised, can be used in multiple functions
      var shape = new createjs.Shape();
      var stage = null;
      var text = null;

      //Game state
      var playerList = [];
      var enemyList = [];
      var powerupList = [];
      var core = null;

      //Initialisation and update functions

      //Initialise gameCanvas - initialise stage, add shape drawer
      function init() {
        stage = new createjs.Stage("gameCanvas");
        stage.addChild(shape);
        createjs.Ticker.framerate = FRAMERATE;
        createjs.Ticker.addEventListener("tick", handleTick);
      }

      //Tick handler, clears graphics, draws FPS, updates canvas
      function handleTick(event) {
        if (!event.paused) {
          shape.graphics.clear();
          drawFPS();
          updateCanvas();
        }
      }

      //Clear shape drawer, then draw game state to gameCanvas
      function updateCanvas() {
        drawList(playerList, null);
        drawList(enemyList, ENEMYC);
        drawList(powerupList, PICKUPC);
        if (core != null) {
          drawTriangle(core.pos, core.vel, core.radius, COREC);
        }
        stage.update();
      }

      //Pause game, update pause button
      function togglePause() {
        createjs.Ticker.paused = !createjs.Ticker.paused;
        var b = document.getElementById("pauseButton");
        b.innerHTML = (createjs.Ticker.paused) ? "Unpause" : "Pause";
      }

      //Drawing Functions

      //Function to draw the ticker's FPS to the screen
      function drawFPS() {
        var fps = createjs.Ticker.getMeasuredFPS();
        if (text == null) {
          text = new createjs.Text(fps, "20px Arial", "x000000");
          text.x = 10;
          text.y = 10;
          stage.addChild(text);
        } else {
          text.text = fps;
        }
      }

      //Draws a triangle facing the direction from vector vel
      function drawTriangle(pos, vel, radius, color) {
        var angle = Math.atan2(vel.y, vel.x) * 180 / Math.PI;
        shape.graphics.beginFill(color).drawPolyStar(pos.x, pos.y, radius, 3, 0,
                                                      angle);
      }

      /* Draw every object in a list - if color not provided then color is
       * obtained from the list objects */
      function drawList(list, color) {
        var isPlayer = false;
        if (color == null)
          isPlayer = true;

        for (i = 0; i < list.length; i++) {
          if (isPlayer)
            color = list[i].color;
          drawTriangle(list[i].pos, list[i].vel, list[i].radius, color);
        }
      }

      //Game state altering functions

      //Convert JSON string json to object, set game state accordingly
      function processJSON(json) {
        var obj = JSON.parse(json);
        playerList = obj.players;
        enemyList = obj.enemies;
        powerupList = obj.powerups;
        core = obj.core;
      }

      //Function to reset game state
      function resetState() {
        playerList = [];
        enemyList = [];
        powerupList = [];
        core = null;
      }

      //Test Functions
      //Set game state to test config
      function testCanvas() {
        playerList = [{"tag": 0, "healthMax": 100, "health": 100, "ammo": 10,
                      "name": "Bob", "color": "#5dfc5d",
                      "pos": { "x": 50, "y": 100 },
                      "vel": { "x": 1, "y": 0 }, "radius": 10 }];
        enemyList = [{ "tag": 0, "healthMax": 100, "health": 100,
                      "pos": { "x": 234, "y": 323 },
                      "vel": { "x": 0, "y": 1 }, "radius": 10 }];
        powerupList = [{ "tag": 0, "healthMax": 100, "health": 100,
                      "pos": { "x": 546, "y": 121 },
                      "vel": { "x": 0, "y": -1 }, "radius": 10 }];
        core = { "tag": 0, "healthMax": 100, "health": 100,
                      "pos": { "x": 900, "y": 400 },
                      "vel": { "x": -1, "y": 0 }, "radius": 10 };
      }

      /* Set game state to test config, convert to JSON, then clear game state
       * and set game state by JSON parsing */
      function testJSON() {
        testCanvas();
        var obj = {"players": playerList, "enemies": enemyList,
                    "powerups": powerupList, "core": core};
        var sjson = JSON.stringify(obj);
        resetState();
        processJSON(sjson);
      }

    </script>
  </head>

  <body onload="init()">
    <canvas id="gameCanvas" class="gameCanvas" width="960" height="600">
    </canvas>
    <div class="outer">
      <div class="controls">
        <button onclick="testCanvas()">Test Canvas No JSON</button>
        <button onclick="testJSON()">Test Canvas JSON</button>
        <button onclick="resetState()">Clear Game State</button>
        <button id="pauseButton" onclick="togglePause()">Pause</button>
      </div>
    </div>
  </body>
</html>

{'fraction_non_alphanumeric': 0.14215504451038577, 'fraction_numerical': 0.021513353115727003, 'mean_word_length': 1.871405750798722, 'pattern_counts': {'":': 94, '<': 57, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4365648', 'n_tokens_mistral': 3449, 'n_tokens_neox': 3156, 'n_words': 895}