Giter Club home page Giter Club logo

uci's Introduction

uci

Build Status Coverage Status

A golang API to interact with UCI chess engines. (should be considered experimental for the time being) A description of how UCI works is available here.

Many chess engines support UCI (Universal Chess Interface). This library is designed for use with Stockfish, but should work with other UCI engines.

Godoc for UCI

minimum viable snippet

package main

import (
	"fmt"
	"log"
	"gopkg.in/freeeve/uci.v1"
)

func main() {
	eng, err := uci.NewEngine("/path/to/stockfish")
	if err != nil {
		log.Fatal(err)
	}
	
	// set some engine options
	eng.SetOptions(uci.Options{
		Hash:128,
		Ponder:false,
		OwnBook:true,
		MultiPV:4,
	})

	// set the starting position
	eng.SetFEN("rnb4r/ppp1k1pp/3bp3/1N3p2/1P2n3/P3BN2/2P1PPPP/R3KB1R b KQ - 4 11")
	
	// set some result filter options
	resultOpts := uci.HighestDepthOnly | uci.IncludeUpperbounds | uci.IncludeLowerbounds
	results, _ := eng.GoDepth(10, resultOpts)

	// print it (String() goes to pretty JSON for now)
	fmt.Println(results)
}

produces this output:

{
  "BestMove": "c8d7",
  "Results": [
    {
      "Time": 136,
      "Depth": 10,
      "SelDepth": 16,
      "Nodes": 183853,
      "NodesPerSecond": 1351860,
      "MultiPV": 1,
      "Lowerbound": false,
      "Upperbound": false,
      "Score": 20,
      "Mate": false,
      "BestMoves": [
        "c8d7",
        "b5d6",
        "c7d6",
        "f3g5",
        "b8c6",
        "g5e4",
        "f5e4",
        "a1d1",
        "h7h6",
        "f2f4",
        "a8f8"
      ]
    },
    {
      "Time": 136,
      "Depth": 10,
      "SelDepth": 16,
      "Nodes": 183853,
      "NodesPerSecond": 1351860,
      "MultiPV": 2,
      "Lowerbound": false,
      "Upperbound": false,
      "Score": 2,
      "Mate": false,
      "BestMoves": [
        "a7a5",
        "b5d6",
        "c7d6",
        "b4b5",
        "b8d7",
        "f3d2",
        "e4d2",
        "e3d2",
        "b7b6",
        "a3a4"
      ]
    },
    {
      "Time": 136,
      "Depth": 10,
      "SelDepth": 16,
      "Nodes": 183853,
      "NodesPerSecond": 1351860,
      "MultiPV": 3,
      "Lowerbound": false,
      "Upperbound": false,
      "Score": -4,
      "Mate": false,
      "BestMoves": [
        "b8c6",
        "c2c4",
        "a7a6",
        "b5d6",
        "c7d6",
        "f3g5",
        "c8d7",
        "c4c5",
        "d6d5",
        "g5e4",
        "f5e4"
      ]
    },
    {
      "Time": 136,
      "Depth": 10,
      "SelDepth": 16,
      "Nodes": 183853,
      "NodesPerSecond": 1351860,
      "MultiPV": 4,
      "Lowerbound": false,
      "Upperbound": false,
      "Score": -18,
      "Mate": false,
      "BestMoves": [
        "e7f7",
        "h2h4",
        "a7a5",
        "b5d6",
        "c7d6",
        "b4a5",
        "b8d7",
        "f3g5",
        "e4g5",
        "h4g5",
        "a8a5",
        "e3d2"
      ]
    }
  ]
}

uci's People

Contributors

domenipavec avatar freeeve avatar isofarro avatar miked-zoe avatar weslleyandrade avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

uci's Issues

Chess Game using freeve/uci

Hi,

I'm writing to extend a huge thanks for this module and to let you know that I've just released a terminal based chess game that makes heavy use of freeve/uci. Your module was hugely helpful in permitting me to focus on the core functionality of the game rather than dealing with all of the idiosyncrasies of UCI communication. Thank you!

https://github.com/tmountain/uchess

PS--my other issue regarding arbitrary commands is still open. I may submit a pull request sometime soon to assist in resolving it.

Feature request: Add Skill Level option

I'm working on a small chess GUI in golang, and I was thinking it could be nice if we could set the skill level for stockfish using this library

ie: setoption name Skill Level value 3

I'm not certain if other options are required for this one option to work however as I haven't really used stockfish a lot in the past.

Compatibility

Hi there! Have you tested this with DroidFish's network engine? Looking to get Lc0 a UCI server with DroidFishgoing. Awesome work!

Ability to Send Arbitrary Commands

Hi,

Some UCI engines will not function properly until they receive the initial "uci" command. Additionally, there are a number of commands that would potentially be useful in various scenarios such as: debug, register, isready, etc.

If you don't feel like implementing all of these manually, you can solve the general issue by providing a way to send arbitrary commands to eng.stdin.WriteStr in a similar way to how you provided an interface for SendOption.

Please consider this request, as I'm building a terminal chess client using your library, and it's currently unable to communicate with some chess programs (i.e., superpawn) because of the aforementioned limitations. Thanks!

Add and opening book

Hi.
I am making a physical chess board based on an unfinished tutorial whose idea is that one "learn to program" among other issues.
(http://chess.fortherapy.co.uk/home/a-wooden-chess-computer/design-ideas-for-easy-to-build-beaglebone-black-chess-computer/)

Turns out, I'd like to be able to add an opening book to Stockfish, but stockfish no longer has this feature.
I currently use the Chessboard 2.05 library
http://www.pygame.org/project-ChessBoard-282-1423.html

Do you know any code that I can incorporate to use an opening book?
This is the base code that whoever created the tutorial shares, so that one can modify it with the electronic part and others (http://chess.fortherapy.co.uk/home/a-wooden-chess-computer/software/python-program-that-runs-stockfish/).
Can you give me a hand, for how add an opening book?

Thanks!

ps. as you can read im a total beginner... and i dont speak english.

License + versioning

Thanks for your awesome work! Could you please add a license and consider using go modules for versioning? This would facilitate usage and contributions (and as a bonus also enable exposing godoc on go.dev :))

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.