<commit_before>// A pseudo random number generator based on <NAME> and
// <NAME>'s paper "A New Class of Invertible Mappings".
var PRNG = (function () {
'use strict';

var rng = {}
  , max = Math.pow(2, 32)
  , state = undefined

// Call seed with "null" to start in a random state.
rng.seed = function (value) {
  if (value !== undefined) {
    state = parseInt(value, 10)
  }
  if (isNaN(state)) {
    state = Math.floor(Math.random() * max)
  }
  return state
}

rng.random = function () {
  state += (state * state) | 5
  return (state >>> 32) / max
}

rng.shuffle = function (array) {
  var i = 0
    , j = 0
    , temp = null

  for (i = array.length - 1; i > 0; i -= 1) {
    j = Math.floor(this.random() * (i + 1))
    temp = array[i]
    array[i] = array[j]
    array[j] = temp
  }
}

return rng
}())

function makeSocketHTML () {
  var html = ''

  html += '<div class="trace">'
  html += '<div class="pads">'
  html += '<span class="pad"></span>'
  html += '<span class="pad"></span>'
  html += '<span class="pad"></span>'
  html += '<span class="pad"></span>'
  html += '</div>'
  html += '<span class="cutout"></span>'
  html += '<div class="pads">'
  html += '<span class="pad"></span>'
  html += '<span class="pad"></span>'
  html += '<span class="pad"></span>'
  html += '<span class="pad"></span>'
  html += '</div>'
  html += '</div>'

  return html
}

function makeChipHTML (chip) {
  var html = ''

  html += '<div class="dip">'
  html += '<div class="pins">'
  html += '<span class="pin"></span>'
  html += '<span class="pin"></span>'
  html += '<span class="pin"></span>'
  html += '<span class="pin"></span>'
  html += '</div>'
  html += '<div class="chip">'
  html += '<span class="led '+chip.suit1+'"></span>'
  html += chip.percent
  html += '<span class="led '+chip.suit2+'"></span>'
  html += '</div>'
  html += '<div class="pins">'
  html += '<span class="pin"></span>'
  html += '<span class="pin"></span>'
  html += '<span class="pin"></span>'
  html += '<span class="pin"></span>'
  html += '</div>'
  html += '</div>'

  return html
}

var Sockets = (function () {
'use strict';

var sockets = {}
  , chipped = {}
  , powered = {}
  , dirty = 0
  , picked = null

sockets.reset = function () {
  chipped = {}
  dirty |= 1

  picked = null
  dirty |= 2

  powered = {}
  dirty |= 4
}

sockets.render = function () {
  var $ = window.jQuery
    , x = 0
    , y = 0
    , html = ''

  if (dirty & 1) {
    Object.keys(chipped).forEach(function (id) {
      $('#'+id).html(makeChipHTML(chipped[id])).add('chipped')
    })
  }

  if (dirty & 2) {
    for (x = 0; x < 4; x += 1) {
      for (y = 0; y < 4; y += 1) {
        if ('socket'+x+''+y !== picked) {
          $('#socket'+x+''+y).remove('picked')
        } else {
          $('#socket'+x+''+y).add('picked')
        }
      }
    }
  }

  if (dirty & 4) {
    Object.keys(powered).forEach(function (id) {
      $('#'+id).add('powered')
    })
  }

  dirty = 0
}

sockets.pick = function (id) {
  if (picked !== id && !(id in powered)) {
    picked = id
    dirty |= 2
  }
}

sockets.canInsert = function () {
  var chipped_count = Object.keys(chipped).length
    , powered_count = Object.keys(powered).length
    , needs_more_power = false
    , i = 0

  for (i = 1; !needs_more_power && i <= 4; i += 1) {
    if (powered_count < i && chipped_count >= i * 4) {
      needs_more_power = true
    }
  }

  return picked && !(picked in chipped) && !needs_more_power
}

sockets.canPower = function () {
  return picked && (picked in chipped) && !(picked in powered)
}

sockets.insert = function (chip, glitch) {
  if (glitch.value >= chip.value &&
      chip.value > 1 && chip.value < 10 &&
      glitch.value > 1 && glitch.value < 10)
  {
    glitch.percent = chip.percent
    chip = glitch<commit_msg>Allow sockets to be unselected.<commit_after>// A pseudo random number generator based on <NAME> and
// <NAME>'s paper "A New Class of Invertible Mappings".
var PRNG = (function () {
'use strict';

var rng = {}
  , max = Math.pow(2, 32)
  , state = undefined

// Call seed with "null" to start in a random state.
rng.seed = function (value) {
  if (value !== undefined) {
    state = parseInt(value, 10)
  }
  if (isNaN(state)) {
    state = Math.floor(Math.random() * max)
  }
  return state
}

rng.random = function () {
  state += (state * state) | 5
  return (state >>> 32) / max
}

rng.shuffle = function (array) {
  var i = 0
    , j = 0
    , temp = null

  for (i = array.length - 1; i > 0; i -= 1) {
    j = Math.floor(this.random() * (i + 1))
    temp = array[i]
    array[i] = array[j]
    array[j] = temp
  }
}

return rng
}())

function makeSocketHTML () {
  var html = ''

  html += '<div class="trace">'
  html += '<div class="pads">'
  html += '<span class="pad"></span>'
  html += '<span class="pad"></span>'
  html += '<span class="pad"></span>'
  html += '<span class="pad"></span>'
  html += '</div>'
  html += '<span class="cutout"></span>'
  html += '<div class="pads">'
  html += '<span class="pad"></span>'
  html += '<span class="pad"></span>'
  html += '<span class="pad"></span>'
  html += '<span class="pad"></span>'
  html += '</div>'
  html += '</div>'

  return html
}

function makeChipHTML (chip) {
  var html = ''

  html += '<div class="dip">'
  html += '<div class="pins">'
  html += '<span class="pin"></span>'
  html += '<span class="pin"></span>'
  html += '<span class="pin"></span>'
  html += '<span class="pin"></span>'
  html += '</div>'
  html += '<div class="chip">'
  html += '<span class="led '+chip.suit1+'"></span>'
  html += chip.percent
  html += '<span class="led '+chip.suit2+'"></span>'
  html += '</div>'
  html += '<div class="pins">'
  html += '<span class="pin"></span>'
  html += '<span class="pin"></span>'
  html += '<span class="pin"></span>'
  html += '<span class="pin"></span>'
  html += '</div>'
  html += '</div>'

  return html
}

var Sockets = (function () {
'use strict';

var sockets = {}
  , chipped = {}
  , powered = {}
  , dirty = 0
  , picked = null

sockets.reset = function () {
  chipped = {}
  dirty |= 1

  picked = null
  dirty |= 2

  powered = {}
  dirty |= 4
}

sockets.render = function () {
  var $ = window.jQuery
    , x = 0
    , y = 0
    , html = ''

  if (dirty & 1) {
    Object.keys(chipped).forEach(function (id) {
      $('#'+id).html(makeChipHTML(chipped[id])).add('chipped')
    })
  }

  if (dirty & 2) {
    for (x = 0; x < 4; x += 1) {
      for (y = 0; y < 4; y += 1) {
        if ('socket'+x+''+y !== picked) {
          $('#socket'+x+''+y).remove('picked')
        } else {
          $('#socket'+x+''+y).add('picked')
        }
      }
    }
  }

  if (dirty & 4) {
    Object.keys(powered).forEach(function (id) {
      $('#'+id).add('powered')
    })
  }

  dirty = 0
}

sockets.pick = function (id) {
  if (!(id in powered)) {
    picked = (picked !== id) ? id : null
    dirty |= 2
  }
}

sockets.canInsert = function () {
  var chipped_count = Object.keys(chipped).length
    , powered_count = Object.keys(powered).length
    , needs_more_power = false
    , i = 0

  for (i = 1; !needs_more_power && i <= 4; i += 1) {
    if (powered_count < i && chipped_count >= i * 4) {
      needs_more_power = true
    }
  }

  return picked && !(picked in chipped) && !needs_more_power
}

sockets.canPower = function () {
  return picked && (picked in chipped) && !(picked in powered)
}

sockets.insert = function (chip, glitch) {
  if (glitch.value >= chip.value &&
      chip.value > 1 && chip.value < 10 &&
      glitch.value > 1 && glitch.value < 10)
  {
    glitch.percent = chip.percent
    chip = glitch
{'fraction_non_alphanumeric': 0.21661838293389518, 'fraction_numerical': 0.011588095865156703, 'mean_word_length': 2.7157534246575343, 'pattern_counts': {'":': 0, '<': 123, '<?xml version=': 0, '>': 127, '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': '5149582', 'n_tokens_mistral': 2824, 'n_tokens_neox': 2717, 'n_words': 706}