Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opening book on blank board #10

Closed
TheTrustedComputer opened this issue Feb 15, 2019 · 5 comments
Closed

Opening book on blank board #10

TheTrustedComputer opened this issue Feb 15, 2019 · 5 comments

Comments

@TheTrustedComputer
Copy link

TheTrustedComputer commented Feb 15, 2019

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.

@PascalPons
Copy link
Owner

PascalPons commented Feb 16, 2019

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?

@TheTrustedComputer
Copy link
Author

TheTrustedComputer commented Feb 16, 2019

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
$

@PascalPons
Copy link
Owner

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 754d3b8

$ 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

@TheTrustedComputer
Copy link
Author

TheTrustedComputer commented Mar 21, 2019

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.

@PascalPons
Copy link
Owner

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: d7acbd6

You can now also stop the input of the generator with an empty line in addition to EOF

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants