Comments (9)
You'll find that most c/c++ code on GitHub assumes a Linux build environment so things won't build out of the box under Windows. You could try using cygwin or mingw or even better install Ubuntu on a VM.
from tdoku.
Thanks for the suggestion! I added generation of a shared library as well as a file example/solve.py
that illustrates one way of using it from Python.
I don't have a Windows dev environment handy for testing, but you might need to change this a little bit to work on Windows. For example, the shared library referenced in example/solve.py
will be a .dll instead of .so.
To build on windows you'll need both cmake, which creates the Makefile, and make which does the build as described by the Makefile. It looks like you have the latter and not the former.
The puzzle generator operates by maintaining a pool of N of the "best" minimal puzzles found so far. With each iteration it randomly selects a puzzle from the pool, randomly drops D clues from it, randomly re-constrains so the solution is unique (but usually no longer minimal), then randomly re-minimizes the puzzle and evaluates how difficult it is. The difficulty evaluation is based on the average guess count when solving E times under random permutation. The puzzle is then scored based on its clue count (C), guess-difficulty (G), and a random factor (R). The puzzle is inserted into the pool along with its score, and the current lowest scoring puzzle is kicked out.
So you can control whether you are searching for low-clue puzzles irrespective of difficulty (-c1 -g0) or hard high-clue puzzles (-c-1 -g1) or some other combination of weightings. If you use -g0 then you should use -e0 because there's no point wasting time evaluating if you won't use the resulting difficulty estimate. You can control the tradeoff between speed and accuracy of difficulty evaluation using the -e parameter. For example, -e100 will evaluate each puzzle under 100 permutations and will give a pretty stable/accurate estimate, but it will be slow. Most of the time you probably want -d1. This drops just one clue, but probably multiple clues will be added to reconstrain, and again multiple clues dropped to reminimize. If you use -d2 or higher the search is a lot less local and usually improves more slowly.
from tdoku.
Yeah, at some point I'll have to set up a windows environment and tidy up instructions for windows users.
The segfault was occurring because example/solve.c
expected a rigid file format and had no checking for comments or other deviations. At some point in the past I added some comments to the top of the data files, but didn't update the sample program, so you would have had to run it like ./solve < <(grep -v "^#" data/puzzles0_kaggle)
to strip out comments. This is fixed now.
If you've mistakenly built with sudo you can just sudo rm -rf ./build
and then build again normally.
To run the generator you can have it use tdoku instead of minisat for evaluation by passing -s0. But if you want to use minisat then you'll have to install it via sudo apt install minisat libz-dev
and then build with -DMINISAT=on
. To use general purpose solvers like minisat, gurobi, or z3 you just want to install the relevant packages following the instructions tucked away under other/README.md
. They are not included as submodules and built from source.
from tdoku.
I am using mingw with Git Bash.
I figured out the make with the help of some research:
https://stackoverflow.com/a/59268508/15046005
jandecaluwe/urubu#52
https://gist.github.com/evanwill/0207876c3243bbb6863e65ec5dc3f058
But now the make just tells me: make: *** No targets specified and no makefile found. Stop.
Even though I can see in BUILD.sh
it says make ${target}
Somewhere I read that I need to call a configure command, but I really have no idea.
from tdoku.
Thank you so much. I saw you put a lot of effort into helping me. I love the python example. It is very illustrative.
The tip that I should just use Linux on a VM instead of worrying about making it work on Windows was also very helpful. Although I accidentally downloaded and installed Ubuntu 14 (instead of 20) and had some problems finding out why my password was always incorrect when I typed it in on the initial login (different keyboard layout), I could finally build tdoku on Linux. I think the issue with Windows is that CMake is not creating a Makefile, or at least I can't find it in the tdoku folder or in the build subfolder.
Your explanation with the weighting helped me a lot to understand how the score is put together, and I think I am now confident in using it, knowing exactly what I am doing.
There are two more things I just found. When I ran:
$ gcc example/solve.c build/libtdoku_static.a -O3 -o solve -lstdc++ -lm
$ ./solve < data/puzzles0_kaggle
I got a Segmentation fault (core dumped)
error. With sudo
I just got a
Segmentation fault
error. I read that this means a wrong memory access. So, I tried it with sudo because I thought it might be an issue with the access rights. Which was a stupid idea because thereafter I had to build with sudo (It almost felt like an addiction) until I thought of just using $ sudo chmod a+rwx ./build --recursive
. How could I fix the Segmentation fault?
The second thing is when I run build/generate -p0 -c0 -g1 -d1 -n100 -e50
it says Must build with -DMINISAT=on to use minisat
. So I ran the build with the flag set. However, then it fails at [ 44%] Building CXX object CMakeFiles/generate.dir/other/other_minisat.cc.o
because it isn't finding minisat/core/Solver.h
. This happens even though I already ran git submodule update --init --recursive
.
from tdoku.
If I am not incorrect, the -s0 is not documented in the README. Because I was searching for exactly that option.
from tdoku.
Yup, that was out of date. Updated. Thanks for the feedback.
from tdoku.
I have an update on the windows stuff. I did get it to run like this.
Maybe someone else is having the same problem.
- As I said above, I had installed
Git Bash
which includesMinGW
. - I installed
CMake
for windows + added it to path - Now if you run the
BUILD.sh
you'll likely get the error:make: *** No targets specified and no makefile found. Stop.
- So in the file, replace
cmake .. $*
withcmake .. $* -G "Unix Makefiles"
to use unix as the generator. - Now you will get an error like
error: 'uint' does not name a type; did you mean 'int'? 83 | constexpr uint OP_X_Y_and_Z_or = 0b11101010;
- In lines
83, 84, 85 and 86
replaceuint
withint
. This should make a difference in the code because the first bit is set to 1. But right now I am just trying to get it to compile. - Finally, on Windows, there is no
sys/mman.h
. So, what I did, was just commenting out these lines in theCMakeLists.txt
Which doesn't build the grid_tools. But I have no clues what that is even for. Instead you could use this on windows from here#add_executable(grid_tools src/grid_tools.cc) #target_include_directories(grid_tools PUBLIC include) #target_link_libraries(grid_tools grid_lib) #target_link_libraries(grid_tools tdoku_static)
generate
, run_tests
and run_benchmark
is working. However, compiling solve.c
with gcc
fails like so
example/solve.c: In function 'int main(int, const char**)':
example/solve.c:13:12: error: 'getline' was not declared in this scope
13 | while (getline(&puzzle, &size, stdin) != -1) {
In the python file, I swapped build/libtdoku_shared.a
with build/libtdoku_shared.dll
in the CDLL
constructor. However, it gives me the following error message.
FileNotFoundError: Could not find module 'correct\path\to\libtdoku_shared.dll' (or one of its dependencies). Try using the full path with constructor syntax.
But giving the full path gives exactly the same error (as expected).
from tdoku.
Thanks for the update. The type problem in simd_vectors.h is fixed.
BTW, I found a windows box and had success compiling with MSYS2. Very simple. Just followed the installation instructions exactly as described at https://www.msys2.org/, and then installed a few more things with pacman -S git gcc cmake python unzip
With that everything works without further modification:
./BUILD.sh
gcc -o solve example/solve.c build/libtdoku_static.a -lstdc++ -lm
python example/solve.py
from tdoku.
Related Issues (6)
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 tdoku.