8000 GitHub - T0nyX1ang/noqx-js: Pure Javascript implementation of noqx.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

T0nyX1ang/noqx-js

Repository files navigation

Noqx-JS

Pure Javascript implementation of Noqx.

Differences between Noqx

Code conversions

The converted codes are pre-generated by Copilot with manual modifications, and some variables are renamed to avoid conflict:

  • Color -> BaseColor

  • Direction -> BaseDir

  • Point -> BasePoint

  • Puzzle -> PenpaPuzzle (which extends BasePuzzle)

Data structure conversions

According to the difference between Python and Javascript, the BasePoint data structure adds a toString function to serialize the data:

class BasePoint {
  constructor(r, c, d = BaseDir.CENTER, pos = "normal") {
    this.r = r;
    this.c = c;
    this.d = d;
    this.pos = pos;
  }

  toString() {
    return `${this.r},${this.c},${this.d.description},${this.pos}`;
  }
}

Therefore, all the keys of surface, text, symbol, edge and line are changed to a String object in the Javascript version. Meanwhile, a new conversion utility function is created to convert the String object back to an Array object:

function extract_point(point) {
  /** Extract the point data from a string. */
  const point_data = point.split(",");
  return [parseInt(point_data[0], 10), parseInt(point_data[1], 10), point_data[2], point_data[3]];
}

Due to the same reason, all sources from the clues should be called from the following utility function:

function get_all_src(clues) {
  /** Get all the sources from the clues. */
  const all_src = new Set();
  const all_src_str = new Set();
  for (const point of clues.keys()) {
    const [r, c, _, __] = extract_point(point);
    if (!all_src_str.has(`${r},${c}`)) {
      all_src_str.add(`${r},${c}`);
      all_src.add([r, c]);
    }
  }
  return all_src;
}

License

  • This project is dual-licensed under Apache 2.0 and GPL 3.0 (or any later version). You can choose between one of them if you use this project.

About

Pure Javascript implementation of noqx.

Topics

Resources

License

Apache-2.0, GPL-3.0 licenses found

Licenses found

Apache-2.0
LICENSE.APACHE
GPL-3.0
LICENSE.GPL

Stars

Watchers

Forks

0