GithubHelp home page GithubHelp logo

ikatago-ios-sdk's Introduction

iOS SDK for ikatago

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

IkatagoSDK is available through CocoaPods. To install it, simply add the following line to your Podfile:

platform :ios, '8.0'

target 'your_target_name' do

   pod "IKatagoSDK", :git => "https://github.com/kinfkong/ikatago-ios-sdk.git"

end

Usage

View the example for detail, in the Example/IkatagoSDK/IKATAGOAppDelegate.m

1. Creates a ikatago client and query the server info

    #import <ikatagosdk/ikatagosdk.h>

    IkatagosdkClient* client = [[IkatagosdkClient alloc] init:@"" platform:@"aistudio" username:@"kinfkong" password:@"12345678"];
    // query the server to see what weights, configs this server supports
    NSString* serverInfo = [client queryServer:&error];
    if (error != nil) {
        NSLog(@"error happens: %@", [error description]);
        return;
    }
    // parse the server info to object from json string
    NSLog(@"server info: %@", serverInfo);

Example of the json response of the server info:

{"serverVersion":"1.4.0","supportKataWeights":[{"name":"20b","description":null},{"name":"30b","description":null},{"name":"40b","description":null},{"name":"40b-large","description":null}],"supportKataNames":[{"name":"katago-1.5.0","description":null},{"name":"katago-1.6.0","description":null},{"name":"katago-1.3.4","description":null},{"name":"katago-solve","description":null}],"supportKataConfigs":[{"name":"default_gtp","description":null},{"name":"10spermove","description":null},{"name":"2stones_handicap","description":null},{"name":"3stones_handicap","description":null},{"name":"4stones_handicap","description":null},{"name":"5stones_handicap","description":null},{"name":"6stones_handicap","description":null},{"name":"7+stones_handicap","description":null}],"defaultKataName":"katago-1.6.0","defaultKataWeight":"40b","defaultKataConfig":"default_gtp"}

** Note: queryServer api only supports the ikatago-server since 1.4.0 **

2. Configs the katago (weights, configs, etc.) and run the katago

    katago = [client createKatagoRunner:&error];
    if (error != nil) {
        NSLog(@"error happens: %@", [error description]);
        return;
    }
    // set the 20b weight
    [katago setKataWeight:@"20b"];
    [katago run:callback error:&error];
    if (error != nil) {
        NSLog(@"error happens: %@", [error description]);
        return;
    }

3. sends the gtp commands to the katago

    [katago sendGTPCommand:@"version\n" error:&error];
    if (error != nil) {
        NSLog(@"error happens: %@", [error description]);
    }
    [katago sendGTPCommand:@"kata-analyze B 50\n" error:&error];
    if (error != nil) {
        NSLog(@"error happens: %@", [error description]);
    }

4. example implementation of the data callback

@interface IKATAGODataCallback : NSObject <IkatagosdkDataCallback>

@end

@implementation IKATAGODataCallback
- (void)callback:(NSData* )content {
    // simply output the data
    NSString* contentString = [[NSString alloc] initWithData:content encoding:NSASCIIStringEncoding];
    NSLog(@"%@", contentString);
}
- (void) stderrCallback:(NSData *)content {
    // simply output the data
    NSString* contentString = [[NSString alloc] initWithData:content encoding:NSASCIIStringEncoding];
    NSLog(@"stderr: %@", contentString);
}
@end
@end

Author

kinfkong, [email protected]

QQ Group: 703409387

License

IkatagoSDK is available under the MIT license. See the LICENSE file for more info.

ikatago-ios-sdk's People

Contributors

kinfkong avatar

Watchers

 avatar  avatar

Forkers

amyson5

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.