cubing / alg.js Goto Github PK
View Code? Open in Web Editor NEWThe functionality of `alg.js` is now part of `cubing.js`. Please see: https://js.cubing.net/cubing/alg/
License: GNU General Public License v3.0
The functionality of `alg.js` is now part of `cubing.js`. Please see: https://js.cubing.net/cubing/alg/
License: GNU General Public License v3.0
Pros:
node
actually truncates nested values)Cons:
1 + [alg representing 2R]
could turn into 3
.The following prints false
:
var original = new Alg.Group(
new Alg.Sequence([
new Alg.BlockMove("R", 1)
]),
1
)
var parsed = parse(algToString(original));
console.log(structureEquals(original, parsed));
Ideally, I'd like there to be only a single representation of this alg.
One possibility is to have a nested kind of sequence that must have at least two units in it. The parser actually uses this requirement to avoid unnecessary nesting (which is why parsed
is different):
alg.js/src/jison_parser/index.jison
Line 147 in 716c91d
Ideas:
Algorithm
with nested algs to have its own lists, e.g. a commutator has {A: Unit[], B: Unit[]}
. This requires making sure to call the Sequence
processing code for each of the components in every relevant Algorithm
in every traversal, possibly leading to subtle bugs.Sequence
to contain a Unit
, and require a Sequence
layer.Sequence
the same way.See https://gist.github.com/lgarron/f33d88a571f4bc9536801a8a7b035a91 for more thoughts on this.
https://facebook.github.io/immutable-js/
But not without benchmarks.
And include dist
on the release branch for e.g. source downloads with the built file.
This is one way to solve #15.
As soon as I set module.exports.mode = "production"
, class names are mangled.
Some references:
https://webpack.js.org/plugins/uglifyjs-webpack-plugin/
https://github.com/webpack-contrib/uglifyjs-webpack-plugin
Absolutely nothing works to keep the class names, including this overkill config:
plugins: [
new UglifyJSPlugin({
sourceMap: true,
uglifyOptions: {
keep_classnames: true,
"mangle": {
keep_classnames: true
},
"compress": {
keep_classnames: true
}
}
})
],
Or this one:
optimization: {
minimizer: [
new UglifyJSPlugin({
sourceMap: true,
uglifyOptions: {
keep_classnames: true,
"mangle": {
keep_classnames: true
},
"compress": {
keep_classnames: true
}
}
})
]
},
I know that the config is being parsed properly, because I get errors if I place keep_classnames
directly in the UglifyJSPlugin
config object or change keep_classnames
into a typo anywhere.
People from different cultures use different kinds of apostrophe or accents to denote algorithms and solve reconstructions.
I would suggest replacing the line 22 of alg_jison.jison to accept at least these 4 most common ones:
['’`´] return "PRIME"
The following throws A sequence cannot be empty.
:
var s = alg.parse("L L'")
alg.coalesceBaseMoves(s)
I'm currently leaning towards a special, non-nestable EmptyAlgorithm extends Algorithm
class to represent the empty alg, if anything.
e.g.
parse("[F: [R, U]]').invert().expand().structureEquals(parse("F U R U' R' F'"))
Also see #7 (a special case for toString()
and #9 (providing convenience for when you just want to manipulate strings.
This is also only easy to provide for built-ins, although Javascript technically supports modifying class prototypes downstream from the original definition.
Filing a bug for posterity.
yarn publish
follows https://docs.npmjs.com/files/package.json#files and ignores the dist
folder if it's in our `.gitignore
The solution was to do something like https://github.com/bcherny/undux and include yet another dotfile (.npmignore
).
Example:
new Sequence([BareSiGNMove("R")])
It's probably confusing to beginners to know when to use new
. TypeScript and ES6 require new
for classes, and I don't want to create a helper for every class. So the main workaround I see here is to make SiGNMove
an abstract class, and SiGNMove
helpers into actual subclasses of SiGNMove
.
This is less performant, but super convenient:
> expand("(R U)2")
"R U R U"
Can easily be done by separating the Traversal[Down]Up.traverse()
entry point from a recursive entry point, and translating the input from/to a string if it was given as a string.
The main problem I see is that the performance issue might be masked, and users might perform a lot of conversions back and forth:
structureEquals(invert(expand("(R U)2")), expand(invert("(R U)2")))
It seems there is no common solution for this yet, so we're stuck with a whole bunch of d.ts
files in ./dist
for now.
2L L'
should not simplifyWe're not dealing with "source code", so I imagine direct indices are more useful.
Hopefully, this won't take extra processing. If possible, we should:
jison
to output string indices.A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.