<commit_before>import * as cursor from './utils/cursor.js'
import cursorStrings from './config-cursors.js'

// --- Config ------------------------------------------------------------------

const conf = {}

conf.canvas = {
  width: 1200, // px
  height: 600, // px
  cellColor: '#000'
}

conf.timer = {
  intervals: [0, 10, 25, 50, 100, 250, 500, 1000, 2000], // ms
  initialIndex: 6 // TODO: maybe put here directly the value instead of index??
}

conf.world = {
  dimensions: [ // number of cells horizontally × vertically
    [conf.canvas.width / 40, conf.canvas.height / 40], // 40px cell size
    [conf.canvas.width / 20, conf.canvas.height / 20],
    [conf.canvas.width / 10, conf.canvas.height / 10],
    [conf.canvas.width / 5, conf.canvas.height / 5],
    [conf.canvas.width / 2, conf.canvas.height / 2],
    [conf.canvas.width / 1, conf.canvas.height / 1]
  ],
  initialIndex: 1 // TODO: maybe put here directly the value instead of index??
}

conf.cursor = {
  initialCursor: { // TODO: maybe put here directly the value instead of index??
    group: 'Spaceships',
    name: 'Glider'
  },
  types: cursor.convertObjectOfCursors(cursorStrings)
}

// --- Initial state -----------------------------------------------------------

// TODO: refactor
const offsetX = 27
const offsetY = 12
const initialWorld = [
  [1, 2], [2, 1], [2, 2], [2, 3], [3, 3]
].map(([x, y]) => [x + offsetX, y + offsetY])

const initialAppState = {
  world: initialWorld,
  worldDimensions: conf.world.dimensions[conf.world.initialIndex], // TODO: maybe put whole set of values from config in here?
  cursor: {
    menuVisible: false,
    type: conf.cursor.types[conf.cursor.initialCursor.group][conf.cursor.initialCursor.name]
  },
  timer: {<commit_msg>initial world is randomly choosen cursor<commit_after>import * as cursor from './utils/cursor.js'
import cursorStrings from './config-cursors.js'

// --- Config ------------------------------------------------------------------

const conf = {}

conf.canvas = {
  width: 1200, // px
  height: 600, // px
  cellColor: '#000'
}

conf.timer = {
  intervals: [0, 10, 25, 50, 100, 250, 500, 1000, 2000], // ms
  initialIndex: 6 // TODO: maybe put here directly the value instead of index??
}

conf.world = {
  dimensions: [ // number of cells horizontally × vertically
    [conf.canvas.width / 40, conf.canvas.height / 40], // 40px cell size
    [conf.canvas.width / 20, conf.canvas.height / 20],
    [conf.canvas.width / 10, conf.canvas.height / 10],
    [conf.canvas.width / 5, conf.canvas.height / 5],
    [conf.canvas.width / 2, conf.canvas.height / 2],
    [conf.canvas.width / 1, conf.canvas.height / 1]
  ],
  initialIndex: 1 // TODO: maybe put here directly the value instead of index??
}

conf.cursor = {
  initialCursor: { // TODO: maybe put here directly the value instead of index??
    group: 'Spaceships',
    name: 'Glider'
  },
  types: cursor.convertObjectOfCursors(cursorStrings)
}

// --- Initial state -----------------------------------------------------------

// randomly choose cursor
const getRandomInt = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min
const allCursors = Object.keys(conf.cursor.types)
  .map(key => conf.cursor.types[key])
  .map(group => Object.keys(group).map(key => group[key]))
  .reduce((a, b) => a.concat(b))
const randomCursor = allCursors[getRandomInt(0, allCursors.length - 1)]

const cursorWidth = randomCursor.reduce((width, [x, _]) => x > width ? x : width, 0) + 1
const cursorHeight = randomCursor.reduce((height, [_, y]) => y > height ? y : height, 0) + 1

const [worldWidth, worldHeight] = conf.world.dimensions[conf.world.initialIndex]
const offsetX = Math.round((worldWidth / 2) - (cursorWidth / 2))
const offsetY = Math.round((worldHeight / 2) - (cursorHeight / 2))

const randomCursorCentered = randomCursor
  .map(([x, y]) => [x + offsetX, y + offsetY])

const initialWorld = randomCursorCentered

const initialAppState = {
  world: initialWorld,
  worldDimensions: conf.world.dimensions[conf.world.initialIndex], // TODO: maybe put whole set of values from config in here?
  cursor: {
    menuVisible: false,
    type: conf.cursor.types[conf.cursor.initialCursor.group][conf.cursor.initialCursor.name]
  },
  timer: {
{'fraction_non_alphanumeric': 0.2033096926713948, 'fraction_numerical': 0.03238770685579196, 'mean_word_length': 2.622431506849315, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '880094', 'n_tokens_mistral': 1436, 'n_tokens_neox': 1306, 'n_words': 377}