Comments (5)
Your lead worked wonders nevertheless! And I did get that done just several hours ago. Since I only cared about the corners of the last layers, that is 4 * 3 stickers, I pulled those info and evaluated whether they got the "U color" value. And then it's just the matter of joining them and comparing them to some literals (the 7 * 4 OCLL patterns/angles) and that's it! Here's a pic:
Cheers!
from puzzle-gen.
Thanks for the feedback.
It is certainly possible and I'm considering what is the best way to expose that. I think I'd like to know the use case a little bit more before knowing how to handle it.
For some context, one of my goals with this library is to provide the puzzle rendering capability and be pretty agnostic to use case so the library can be utilized in different applications.
My first thought is that the application asking for an OLL render already knows the case in mind. So perhaps just providing a way to add a text label to the image itself would be sufficient?
Or perhaps the application is looking at a random scramble and trying to detect the case, I think this is more appropriate to include the logic outside of the puzzle-gen library, but expose the internal state of the puzzle so it can be used. I'm assuming this is more what you're after?
The good news is that the puzzle state is already exposed somewhat.
The modules are arranged kind of like this
- rendering
- PNG
- SVG
- Canvas
- visualizer
- simulator
- renderer
with PNG
SVG
Canvas
just convenience methods to build a visualizer and output the image to the HTML document. Which is the core purpose of the library. A visualizer
keeps the state of the puzzle in the simulator
and then uses w/e renderer to output depending on the mode selected (png, svg, canvas)
the SVG
and Canvas
methods return the visualizer object and the puzzle state can be inspected to do what you're looking for.
from puzzle-gen.
Hey, thank you! I would love to explain my use case by quoting your comments and perhaps explain how mine might be a bit too niche:
My first thought is that the application asking for an OLL render already knows the case in mind.
So what I have now is around 25k of algs that I'm sure what it does (it affects OLL) but not quite sure what OLL it gave. The algs are generated by combining 2 algs, and that is why the case is not known to the application. I tried bruteforcing the algs, but could only handle filtering images for like a couple hundred combinations before getting tired (lol). That brings me to my next small code, basically I used puzzlegen.min.js to do the work of displaying the algs!
<head>
<script type="text/javascript" src="puzzleGen.min.js"></script>
</head>
<body>
<div>
// some div ...
</div>
<script type="text/javascript">
function generatePuzzles(algorithmsId, containerId) {
let algorithms = document.getElementById(algorithmsId).value.split("\n");
let puzzleContainer = document.getElementById(containerId);
puzzleContainer.innerHTML = "";
for (let i = 0; i < algorithms.length; i++) {
let options = {
"width": 100,
"height": 100,
"strokeWidth": 0.03,
puzzle:
{
alg: algorithms[i]
}
};
let puzzleDiv = document.createElement("div");
puzzleDiv.id = "cube" + (i + 1);
puzzleContainer.appendChild(puzzleDiv);
puzzleGen.PNG("#" + puzzleDiv.id, puzzleGen.Type.CUBE, options);
// Add an indicator text to show the current index
let indicatorText = document.createElement("p");
indicatorText.innerHTML = "Generating puzzle " + (i + 1) + " of " + algorithms.length;
puzzleDiv.appendChild(indicatorText);
}
}
</script>
</body>
</html>
As you can see, a super simple one. If I could somehow pull the state of the cube (like what color UFR is, or basically every sticker) I could very easily make logic to differentiate the case. And as you said here:
the
SVG
andCanvas
methods return the visualizer object and the puzzle state can be inspected to do what you're looking for.
could you please guide me on how to pull those state from the objects? Thanks a bunch!
from puzzle-gen.
Hi Tyson,
Looks like I've found the way to expose the stickers that could workโby messing around on the console and from your lead (visualizer). This code shows the map and I am able to use the get() method to extract the stickers that matter, with LL_state
being an object that is returned by the Canvas
method.
LL_state.simulator.stickers;
Closing this issue. I might document what I did when my project is done, and for whoever reading this and find this pokes your interest, please expect some proof of concept codes on my page in the future. Thank you!
Best,
Adi
from puzzle-gen.
Yup exactly.
Sorry, I was planning to write out a full example / description on the weekend when I had some time. But you get the idea.
To be honest it might not be very straightforward but you should be able to accomplish what you need. The simulator stuff wasn't really built with that in mind, but if it works that's great!
from puzzle-gen.
Related Issues (5)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from puzzle-gen.