<commit_before>'use strict';

const common = require('./../server/common');
const customLocations = require('./customLocations');


export class SurfaceBluePrints {
  constructor(worldSize, dungeonBluePrints) {
    this.worldSize = worldSize;
    this.dungeonBluePrints = dungeonBluePrints;

    this.blueprints = {};
    this.startLocationId = undefined;

    this.locationTypes = [customLocations.ForestLocation, customLocations.MeadowLocation];
  }

  setStartLocationId () {
    const c = Math.floor(this.worldSize / 2);
    this.startLocationId = `location_${c}_${c}`;
  }

  getStartLocationId () {
    return this.startLocationId;
  }

  getLocationType () {
    const location = this.locationTypes[common.getRandomInt(0, this.locationTypes.length - 1)];
    return location.name;
  }

  generate () {
    for (let y = 0; y < this.worldSize; y++) {
      for (let x = 0; x < this.worldSize; x++) {
        const locationId = `location_${y}_${x}`;

        this.blueprints[locationId] = {};
        this.blueprints[locationId].locationType = this.getLocationType();
<commit_msg>Add the toroidal topology<commit_after>'use strict';

const common = require('./../server/common');
const customLocations = require('./customLocations');


export class SurfaceBluePrints {
  constructor(worldSize, dungeonBluePrints) {
    this.worldSize = worldSize;
    this.dungeonBluePrints = dungeonBluePrints;

    this.blueprints = {};
    this.startLocationId = undefined;

    this.locationTypes = [customLocations.ForestLocation, customLocations.MeadowLocation];
  }

  setStartLocationId () {
    const c = Math.floor(this.worldSize / 2);
    this.startLocationId = `location_${c}_${c}`;
  }

  getStartLocationId () {
    return this.startLocationId;
  }

  getLocationType () {
    const location = this.locationTypes[common.getRandomInt(0, this.locationTypes.length - 1)];
    return location.name;
  }

  generate () {
    for (let y = 0; y < this.worldSize; y++) {
      for (let x = 0; x < this.worldSize; x++) {
        const locationId = `location_${y}_${x}`;

        this.blueprints[locationId] = {};
        this.blueprints[locationId].locationType = this.getLocationType();

        // for the toroidal topology
        if (y === 0) {
          this.blueprints[locationId].up = `location_${this.worldSize - 1}_${x}`;
        }

        if (y === this.worldSize - 1) {
          this.blueprints[locationId].down = `location_0_${x}`;
        }

        if (x === 0) {
          this.blueprints[locationId].left = `location_${y}_${this.worldSize - 1}`;
        }

        if (x === this.worldSize - 1) {
          this.blueprints[locationId].right = `location_${y}_0`;
        }

        // for the common neighbors
{'fraction_non_alphanumeric': 0.14275202354672553, 'fraction_numerical': 0.006622516556291391, 'mean_word_length': 3.070359281437126, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, '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': '956469', 'n_tokens_mistral': 878, 'n_tokens_neox': 841, 'n_words': 159}