Closed TheTrustedComputer closed 3 years ago
The opening book class is read-only in normal usage. You can find an example of how to generate the internal TranspositionTable of the opening book in the function generate_opening_book() of generator.cpp.
This generator is fed with lines containing position and score separated by a space. You simply have to send it a line with an empty position (actually 0 characters) followed by a space (delimiter) and its score. for example, if you want to assign score 1 to an empty position send it the line " 1" (note the initial space)
The solver is returning 1 for the 7x6 board using the opening book I provided. When you say that the solver gives a zero score to an empty position, are you using a different board size or a different opening book that the one I provided?
I'm using my own opening book created from generator.cpp, and feeding it to the solver. I renamed 7x6_small.book to 7x6.book which the solver expects it to be loaded as. The board size is at the standard 7x6. I did exactly what you suggested, and it still gave zeroes. I haven't modified any of the code if you're wondering, I just compiled it and ran it on Cygwin64 to experiment additional features you made to your solver.
Text output from Cygwin64: TTC@TTCW7 /cygdrive/c/Users/TTC/Downloads/connect4-master/connect4-master $ g++ -O3 -std=c++11 generator.cpp -oag
TTC@TTCW7 /cygdrive/c/Users/TTC/Downloads/connect4-master/connect4-master $ ./ag 1 A A
TTC@TTCW7 /cygdrive/c/Users/TTC/Downloads/connect4-master/connect4-master $ ./a Loading opening book from file: 7x6.book. done
0 2 0 41
TTC@TTCW7 /cygdrive/c/Users/TTC/Downloads/connect4-master/connect4-master $
I just fixed the generator such that it directly generate a file named "7x6.book"
Unfortunately, I am unable to reproduce your issue. I get the correct score 1 on the empty position using an opening book that only contains the empty position. Here are the 3 exact commands I made from this commit https://github.com/PascalPons/connect4/commit/754d3b8e3cc919b28fda053bcc447f54f6d53266
$ make c4solver generator
g++ --std=c++11 -W -Wall -O3 -DNDEBUG -c -o Solver.o Solver.cpp
g++ --std=c++11 -W -Wall -O3 -DNDEBUG -c -o main.o main.cpp
g++ -o c4solver main.o Solver.o
g++ --std=c++11 -W -Wall -O3 -DNDEBUG -c -o generator.o generator.cpp
g++ -o generator generator.o
$ echo " 1" | ./generator
$ echo "" | ./c4solver Loading opening book from file: 7x6.book. done 1 2 2
Run the opening book generator first. You then input some arbitrary score to the empty position within the generator and then press Enter. After that, type any two non-numeric characters with spaces in between the characters then press the Enter key to create the book. This will produce a zero score on the empty position while it does not when you input a position of played moves.
Using your method above, the problem actually goes away! This is the consequence of me being more familiar with the Windows command prompt than the Unix terminal. However, I still think this minor oversight needs fixing to fulfill with others not so advanced with consoles.
Hi @TheTrustedComputer
I now understand what happened, when you were typing "A A", the parsing of the position "A" identified that the first char is invalid and stopped parsing, leading to the empty position. As well, when parsing invalid score "A", the score 0 was actually taken into account.
I improved robustness of the generator against invalid input in my last commit: https://github.com/PascalPons/connect4/commit/d7acbd640877087dda68452397f9cd7897949074
You can now also stop the input of the generator with an empty line in addition to EOF
Is there a way to assign a score from an empty position to the opening book? I couldn't find any ways to do it. The solver gives a zero score to it, but every other position is fine.