andrasfelfoldi / FakeSudokuPuzzleGenerator

FakeSudokuPuzzleGenerator generates a unique solution sudoku puzzle by shuffling around and slightly altering already existing unique solution sudoku puzzles.
MIT License
2 stars 0 forks source link

Package not usable #1

Closed TKasekamp closed 5 years ago

TKasekamp commented 5 years ago

Hi @andrasfelfoldi ! This package looks very interesting and I tried it out for my own hobby project that uses Typescript.

The problem with this package is that the files are in ES6 and I think Typescript can't easily handle that. So can you add a webpack step to transpile it to ES5? Or do something to make the package more usable?

These are the errors I got

[Node] /Users/tonis.kasekamp/other/sudoku-service/node_modules/fake-sudoku-puzzle-generator/FakeSudokuPuzzleGenerator.js:1
[Node] (function (exports, require, module, __filename, __dirname) { import { getRandomVeryEasy, getRandomEasy, getRandomMedium, getRandomHard } from "./BasePuzzles";
[Node]                                                                      ^
[Node]
[Node] SyntaxError: Unexpected token {

Second point. You can improve typings with

declare module 'fake-sudoku-puzzle-generator' {
    export function getVeryEasySudoku(): number[][]
    export function getEasySudoku(): number[][]
    export function getMediumSudoku(): number[][]
    export function getHardSudoku(): number[][]
}
andrasfelfoldi commented 5 years ago

Hi @TKasekamp !

Thanks for the feedback! This is the first time I get a feedback on anything I made, so I appreciate it! πŸ˜„

I will look into this issue and try my best to fix it.

andrasfelfoldi commented 5 years ago

Hi @TKasekamp !

I'm currently working on it in my freetime, that's why it's taking so long. If nothing goes wrong, I should be able to fix it by the end of tomorrow.

andrasfelfoldi commented 5 years ago

Hi @TKasekamp !

Just published v1.2.0 of FakeSudokuPuzzleGenerator. It should work properly now. Can you please check if it works on your machine as well?

I also added another way of getting the puzzles. The getSudoku method accepts either "VeryEasy", "Easy", "Medium" or "Hard" as a parameter, and returns a puzzle with the corresponding difficulty. If no proper value is passed, it returns a VeryEasy puzzle by default.

TKasekamp commented 5 years ago

Thanks @andrasfelfoldi ! You definately changed a lot! I'll test it soon and report back.

TKasekamp commented 5 years ago

Tried it @andrasfelfoldi and now my Typescript project can use it. But I'm looking at the getSudoku results and there are still a lot of null in Easy, as much as with Hard. So it doesn't look that easy for me.

Secondly some more TS improvements πŸ˜„ Use it if you want


type Difficulty = "VeryEasy" | "Easy" | "Medium" | "Hard"
export declare const getSudoku: (difficulty: Difficulty) => (number | null)[][];
andrasfelfoldi commented 5 years ago

Thanks, I will add your improvements it as soon as I can. πŸ˜„

Regarding the difficulty of the puzzles: I used another website to check the difficulties of the generated puzzles. I think it was this site.

According to some stuff I read online (seems legit right? πŸ˜„ ) about sudoku, the main difficulty does not necessarily come from the lack of filled in numbers.

It is possible that a puzzle has only a very few filled cells, but they are laid out in a way that it's easy to determine the values of the blank cells. Similarly, a puzzle can have a lot of cells filled by default, but they may be laid out in a way that you will need to use advanced techniques to be able to fill the remaining blank cells.

To quote the website I have linked:

A sudoku puzzle can be very easy, extremely hard, or somewhere in between, depending on the techniques required to solve it.

So basically, when we check the difficulty of a sudoku puzzle, we should have a look at the techniques required to solve it and evaluate the puzzle based on how advanced these techniques are.

I admit, that there might be a correlation between sudoku puzzle difficulty and the number of blank cells, but this is likely due to the fact that a lack of filled cells may force the player to resort to more advanced techniques. If a puzzle has only a very few filled cells at the start, but I can solve it using only basic and easy methods, the puzzle is not hard, it just takes longer to complete.

TKasekamp commented 5 years ago

Okay, I haven't tried solving the puzzles, so the amount of blank spaces made me question πŸ˜„ Thanks for taking the time to answer πŸ‘

andrasfelfoldi commented 5 years ago

No problem, I'm glad that someone found a use of this repo. πŸ˜„

The blank spaces made me question it as well by the way. I just trust the evaluation of Thonky.com. They know more about sudoku than me for sure. πŸ˜„

But anyway, if it turns out, that the difficulties really do not align, feel free to notify me. πŸ”₯

andrasfelfoldi commented 5 years ago

By the way, I included your suggestion in v1.2.1 for the Difficulty type.