How to integrate Stockfish in ios app

giordano.vicoli's Avatar

giordano.vicoli

12 May, 2013 06:16 PM

Dear all,
I am Giordano from Italy and I am developing an application about chess for iPhone/iPad. I would like to integrate Stockfish in my application but I am not able to integrate it. Please, can you help me to do that?

Many thanks in advance and bye,
Giordano

  1. Support Staff 1 Posted by Daylen Yang on 12 May, 2013 06:32 PM

    Daylen Yang's Avatar

    We can't help you with iPhone application development. As an example, we provide the source code for the Stockfish iPhone app: http://cl.ly/1O0v380R3P2a2A04060S

  2. 2 Posted by giordano.vicoli on 12 May, 2013 06:44 PM

    giordano.vicoli's Avatar

    At a first look I should find the solution to my question.

    Many thanks and bye,
    Giordano

  3. 3 Posted by ajdalaziz01 on 27 May, 2013 06:37 AM

    ajdalaziz01's Avatar

    Hello Daylen! The source code for the the stockfish iPhone app provided here is indeed very helpful. There is this one problem though. I compiled this code on Xcode, set the UCI strength to 0 and started playing on my iPad mini. I'm a novice chess player and found it be pretty difficult even at the minimum strength. I then downloaded the stockfish app from the iTunes store and played it on the same device, the strength set to 0 again. There was a huge difference between the two. The GUI is a bit different too. I could easily beat the computer on strength 0 in the stockfish app from the iTunes store but the game from the code provided above was very difficult at the same setting. I was wondering if you could provide me with the source code for that version of the app which is on the store. Looking to hear from you soon!

    Thanks,
    Ajdal

  4. 4 Posted by ajdalaziz01 on 27 May, 2013 06:51 AM

    ajdalaziz01's Avatar

    I see that the version on the iTunes store is 2.4 whereas the code provided here is for version 2.2. Can i please have the source code for version 2.4 of the app?

    Thanks,
    Ajdal

  5. 5 Posted by ajdalaziz01 on 27 May, 2013 12:48 PM

    ajdalaziz01's Avatar

    I found the solution to the problem, i just needed to change a little bit of code..thanks anyways!

  6. 6 Posted by giordano.vicoli on 27 May, 2013 01:07 PM

    giordano.vicoli's Avatar

    Hello ajdalaziz01,

    can you share your solution?
    Many thanks,
    Giordano

  7. 7 Posted by ajdalaziz01 on 28 May, 2013 06:21 AM

    ajdalaziz01's Avatar

    Hello Giordana,

    In the source code provided here(version 2.2 of the app), the UCI strength goes from 500 to 2500 whereas in the current version(2.4) of the app it goes from 0 to 2500. When you run this code in Xcode and go to options->strength you'll see the picker view choose values from 500-2500. So I initially thought if I make picker view start from 0 instead of 500 that should solve the problem. But that was not the case. There is a uci strength parameter in the code which is set to( 2500,500,2500), just replace the 500 with 0 and make necessary changes in the picker view code and you'll be good to go.

    Regards,
    Ajdal

  8. 8 Posted by giordano.vicoli on 28 May, 2013 08:12 AM

    giordano.vicoli's Avatar

    Hello Ajdal,

    thank you for the suggestion. I'll follow that.

    I am trying to integrate the stockfish engine in a my project in
    objective-c but I have some problem. Did you able to do that?

    Thanks and bye,
    Giordano

  9. 9 Posted by dsksaklsaklsd on 31 May, 2013 05:48 AM

    dsksaklsaklsd's Avatar

    What problems do you have? I've integrated Stockfish quite easily. No problem.

  10. 10 Posted by giordano.vicoli on 31 May, 2013 03:23 PM

    giordano.vicoli's Avatar

    Hi dsksak....,

    I created a new iOS project with Xcode, then I added stosckfish classes (engines) but when I try to compile I have a lot of errors. Could you explain me which steps did you follow to create a new project with stockfish?

    Many thanks and bye,
    Giordano

  11. Support Staff 11 Posted by Daylen Yang on 27 Jun, 2013 05:03 AM

    Daylen Yang's Avatar

    You should be able to open the Xcode project in the source code in the link above.

  12. 12 Posted by asasddasdasdasd... on 28 Jun, 2013 01:44 AM

    asasddasdasdasdsdas's Avatar

    What errors you have? Stockfish compiles good on the ARM platform.

  13. Support Staff 13 Posted by Daylen Yang on 29 Aug, 2013 04:29 AM

    Daylen Yang's Avatar

    Closing because this thread is stale.

  14. Daylen Yang closed this discussion on 29 Aug, 2013 04:29 AM.

  15. giordano.vicoli re-opened this discussion on 05 Nov, 2013 02:08 PM

  16. 14 Posted by giordano.vicoli on 05 Nov, 2013 02:08 PM

    giordano.vicoli's Avatar

    Dear friend, (I don't know your name)

    some time ago you answered me to a post of StockFish and you said that you
    have integrated stockfish easily in iOS app. Please, can you explain more
    in detail how did you integrate stockfish because I am trying but I am not
    able to do that.

    Many thanks and regards,
    Giordano

  17. 15 Posted by daskldsakldaskl... on 05 Nov, 2013 11:19 PM

    daskldsakldasklsd's Avatar

    Yeah, it's me again... I'm the developer for a chess puzzle app on the App Store using the Stockfish chess engine (Chess Problems by World Champion).

    There're some tricks, for example, you can't communicate to the Stockfish UCI engine directly by creating a process. You'll need to pass UCI commands and parse commands with some other mechanisms. The Stockfish app hooks some of the engine functions directly with the user interface. We prefer intra-thread communication. It works brilliantly.

    But your problem is more basic. You're unable to compile your sources. I don't know how to help you without any details what compilation errors you have.

    The Stockfish forum is not a good place for this kind of communications. You should head to http://www.talkchess.com and ask your question there. I got some help there for my puzzle app. Post your question and the compilation errors or post your sources there. Someone, possibly myself (if I remember my password) will help you.

  18. 16 Posted by giordano.vicoli on 06 Nov, 2013 07:50 AM

    giordano.vicoli's Avatar

    Dear friend,

    thank you very much for the answer. I signed on talkchess.com and I am
    waiting the authorization. So I explain you more in detail my problems.

    1. I created a new very simple iOS project.
    2. I copied all the files of StockFish engine I downloaded from Costalba
    git.
    3. I tried to compile and all is working.
    4. Now to interface my application to engine I copied the following files
    from stockfish source; iphone.h iphone.mm, Queue.h Queue.mm
    EngineController.h EngineController.mm. As far as I understood these three
    files allows to start the engine and to send command to engine through
    Queue. About the files Queue.h and Queue.mm I don't have problems but I
    have problems with EngineController because my application doesn't
    recognize the following commands:

    pthread_mutex_init(&WaitConditionLock, NULL);

    pthread_cond_init(&WaitCondition, NULL);

    pthread_mutex_lock(&WaitConditionLock);

    pthread_cond_wait(&WaitCondition, &WaitConditionLock);

    pthread_mutex_unlock(&WaitConditionLock);

    execute_command(std::string([command UTF8String]));

    pthread_mutex_lock(&WaitConditionLock);

    pthread_cond_signal(&WaitCondition);

    pthread_mutex_unlock(&WaitConditionLock);

    pthread_cond_destroy(&WaitCondition);

    I also have problems in iPhone.h

    ////

    extern void engine_init();

    extern void engine_exit();

    extern void pv_to_ui(const std::string &pv);

    extern void currmove_to_ui(const std::string currmove, int currmovenum,

                               int movenum, int depth);

    extern void bestmove_to_ui(const std::string &best, const std::string
    &ponder);

    extern void searchstats_to_ui(int64_t nodes, long time);

    extern int get_command(std::string &cmd);

    extern void command_to_engine(const std::string &command);

    extern bool command_is_waiting();

    extern std::string get_command();

    extern std::string kpk_bitbase_filename();

    extern void wake_up_listener();

    //extern void engine_uci_loop();

    extern void execute_command(const std::string &cmd);

    The error is the same: Use of undeclared identifier.

    I hope I was clear in my explanation. Thank you very much for your patience.

    Regards,
    Giordano

  19. giordano.vicoli closed this discussion on 25 Nov, 2013 10:07 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac