mcostalba / scoutfish

Chess Query Engine
GNU General Public License v3.0
156 stars 23 forks source link

Make a python extension for scoutfish #13

Closed sshivaji closed 7 years ago

sshivaji commented 7 years ago

While this is not strictly necessary, it makes it easy to integrate into python apps. I have contributed to a python module of stockfish at https://github.com/jromang/Stockfish/blob/pyfish/src/pyfish.cpp (the work was started by Jean-Francois).

I tried to create one for scoutfish but its turns out starting the multi-threaded scout search with listeners is a little more tricky than I expected. However, I think its quite do-able.

mcostalba commented 7 years ago

I use pexpect, see test.py

On Monday, December 12, 2016, Shivkumar Shivaji notifications@github.com wrote:

While this is not strictly necessary, it makes it easy to integrate into python apps. I have contributed to a python module of stockfish at https://github.com/jromang/Stockfish/blob/pyfish/src/pyfish.cpp (the work was started by Jean-Francois).

I tried to create one for scoutfish but its turns out starting the multi-threaded scout search with listeners is a little more tricky than I expected. However, I think its quite do-able.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mcostalba/scoutfish/issues/13, or mute the thread https://github.com/notifications/unsubscribe-auth/ABDGAaKWYDqzAjqwGJMKNpRxqe-GhTslks5rHI6fgaJpZM4LKFTj .

sshivaji commented 7 years ago

I saw that of course. A full Python extension is a bit more complex, it requires C++ code in an interface file like the pyfish.cpp above. The benefit is that you can import the project easily in regular python via api like:

import scoutfish results = scoutfish.scout('')

This is instead of using the command line. The disadvantage is the complexity of writing the C++ code, the advantage is the more seamless integration.

If this seems a bit hard for now, we can revisit this later.

mcostalba commented 7 years ago

Sorry, I have no experience with this, but I will give it a look.

On Monday, December 12, 2016, Shivkumar Shivaji notifications@github.com wrote:

I saw that of course. A full Python extension is a bit more complex, it requires C++ code in an interface file like the pyfish.cpp above. The benefit is that you can import the project easily in regular python via api like:

import scoutfish results = scoutfish.scout('')

This is instead of using the command line. The disadvantage is the complexity of writing the C++ code, the advantage is the more seamless integration.

If this seems a bit hard for now, we can revisit this later.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/mcostalba/scoutfish/issues/13#issuecomment-266348178, or mute the thread https://github.com/notifications/unsubscribe-auth/ABDGAb8PihRNbv3GCGHJBao6CSC9EbKJks5rHN-pgaJpZM4LKFTj .

mcostalba commented 7 years ago

Maybe we can start with a simple scoutfish.py file and when API is stable we can libify it.

On Monday, December 12, 2016, Marco Costalba mcostalba@gmail.com wrote:

Sorry, I have no experience with this, but I will give it a look.

On Monday, December 12, 2016, Shivkumar Shivaji <notifications@github.com javascript:_e(%7B%7D,'cvml','notifications@github.com');> wrote:

I saw that of course. A full Python extension is a bit more complex, it requires C++ code in an interface file like the pyfish.cpp above. The benefit is that you can import the project easily in regular python via api like:

import scoutfish results = scoutfish.scout('')

This is instead of using the command line. The disadvantage is the complexity of writing the C++ code, the advantage is the more seamless integration.

If this seems a bit hard for now, we can revisit this later.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/mcostalba/scoutfish/issues/13#issuecomment-266348178, or mute the thread https://github.com/notifications/unsubscribe-auth/ABDGAb8PihRNbv3GCGHJBao6CSC9EbKJks5rHN-pgaJpZM4LKFTj .

sshivaji commented 7 years ago

I gave it a try but failed narrowly. I also realized the main reasons for wanting this were:

  1. Wanting to process large Json easily from python
  2. Set multi threads easily without using an input and output Popen buffer.

Maybe for now, can just use popen, pexpect and can support offset for json

sshivaji commented 7 years ago

I mean for now, the popen based scoutfish.py is good enough with max matches support

mcostalba commented 7 years ago

After @gbtami patch to use PopenSpawn now this is incredibly fast, don't know what's happened, but now running test.py is almost immediate...

sshivaji commented 7 years ago

Great to hear! I think I should be able to fully integrate scoutfish on github.com/sshivaji/Chessui soon in light of the module.