Code Monkey home page Code Monkey logo

Comments (5)

PascalPons avatar PascalPons commented on June 20, 2024

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?

from connect4.

TheTrustedComputer avatar TheTrustedComputer commented on June 20, 2024

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
$

from connect4.

PascalPons avatar PascalPons commented on June 20, 2024

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

from connect4.

TheTrustedComputer avatar TheTrustedComputer commented on June 20, 2024

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.

from connect4.

PascalPons avatar PascalPons commented on June 20, 2024

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

from connect4.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.