stockshark 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +35 -0
- data/.rubocop.yml +1 -0
- data/Gemfile +5 -4
- data/README.md +9 -0
- data/lib/stockshark/uci_protocol.rb +11 -6
- data/lib/stockshark/version.rb +1 -1
- data/stockshark.gemspec +3 -3
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a0c9428bd671b4e55a08c4602cae9bc748ee0bb8666364ebde3cabce5b01a5da
|
|
4
|
+
data.tar.gz: 8b36d924fcdfbb6c119309f1426948fbbd42e8b742493df1eb0566a35fc9408a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 58da8ce95cc37a7535fedd667322e71fcde5e557d2b55cc27e9cea7139a5dea1b0729593fcebedaf7d2f630fdcbaa5176253d6373660cd49821ea735f21e4a8b
|
|
7
|
+
data.tar.gz: 59d251e2d4d680ac672683591426225f8db688092e2b4740aeac35bf84bb2c536e7bdea9888abf861fc27a3ca80057ed6ac4536a68fd3cd1f8496cc4b3f66bbf
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
push:
|
|
6
|
+
branches: [ main ]
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
test:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- name: Checkout code
|
|
13
|
+
uses: actions/checkout@v6
|
|
14
|
+
|
|
15
|
+
- name: Set up Ruby
|
|
16
|
+
uses: ruby/setup-ruby@v1
|
|
17
|
+
with:
|
|
18
|
+
bundler-cache: true
|
|
19
|
+
|
|
20
|
+
- name: Run tests
|
|
21
|
+
run: bundle exec rspec
|
|
22
|
+
|
|
23
|
+
lint:
|
|
24
|
+
runs-on: ubuntu-latest
|
|
25
|
+
steps:
|
|
26
|
+
- name: Checkout code
|
|
27
|
+
uses: actions/checkout@v6
|
|
28
|
+
|
|
29
|
+
- name: Set up Ruby
|
|
30
|
+
uses: ruby/setup-ruby@v1
|
|
31
|
+
with:
|
|
32
|
+
bundler-cache: true
|
|
33
|
+
|
|
34
|
+
- name: Lint code for consistent style
|
|
35
|
+
run: bundle exec rubocop -f github
|
data/.rubocop.yml
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
inherit_gem: { rubocop-rails-omakase: rubocop.yml }
|
data/Gemfile
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
source
|
|
1
|
+
source "https://rubygems.org"
|
|
2
2
|
|
|
3
3
|
gemspec
|
|
4
4
|
|
|
5
|
-
gem
|
|
6
|
-
gem
|
|
7
|
-
gem
|
|
5
|
+
gem "rake", "~> 13.4"
|
|
6
|
+
gem "rspec", "~> 3.13"
|
|
7
|
+
gem "rubocop", "~> 1.88"
|
|
8
|
+
gem "rubocop-rails-omakase", require: false
|
data/README.md
CHANGED
|
@@ -87,6 +87,15 @@ apt install stockfish # Debian/Ubuntu
|
|
|
87
87
|
|
|
88
88
|
or download a build from [stockfishchess.org/download](https://stockfishchess.org/download).
|
|
89
89
|
|
|
90
|
+
Lint with:
|
|
91
|
+
|
|
92
|
+
```
|
|
93
|
+
bundle exec rubocop
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
CI (`.github/workflows/ci.yml`) runs both the test suite and RuboCop on
|
|
97
|
+
every push and pull request.
|
|
98
|
+
|
|
90
99
|
Run `bin/console` for an interactive prompt with the gem already loaded.
|
|
91
100
|
|
|
92
101
|
To install this gem onto your local machine, run `bundle exec rake
|
|
@@ -31,22 +31,27 @@ module Stockshark
|
|
|
31
31
|
# => { depth: 20, multipv: 1, score_cp: 34, score_mate: nil, pv: ["e2e4", "e7e5", "g1f3"] }
|
|
32
32
|
# "info depth 12 multipv 2 score mate -3 pv ... "
|
|
33
33
|
# => { depth: 12, multipv: 2, score_cp: nil, score_mate: -3, pv: [...] }
|
|
34
|
-
#
|
|
35
|
-
#
|
|
36
|
-
#
|
|
34
|
+
# "info depth 0 score mate 0" (position has no legal moves — checkmate;
|
|
35
|
+
# stalemate reports "score cp 0" instead — neither carries a pv, since
|
|
36
|
+
# there's no move to report)
|
|
37
|
+
# => { depth: 0, multipv: 1, score_cp: nil, score_mate: 0, pv: [] }
|
|
38
|
+
# Returns nil for info lines that don't carry a score at all (plain
|
|
39
|
+
# "info string ..." diagnostics, "info currmove ...", etc.) — callers
|
|
40
|
+
# should just skip those.
|
|
37
41
|
def parse_info(line)
|
|
38
|
-
return nil unless line.start_with?("info ") && line.
|
|
42
|
+
return nil unless line.start_with?("info ") && line.match?(/\bscore (?:cp|mate) -?\d+/)
|
|
39
43
|
|
|
40
44
|
depth = line[/\bdepth (\d+)/, 1]
|
|
45
|
+
return nil unless depth
|
|
46
|
+
|
|
41
47
|
pv = line[/ pv (.+)\z/, 1]
|
|
42
|
-
return nil unless depth && pv
|
|
43
48
|
|
|
44
49
|
{
|
|
45
50
|
depth: depth.to_i,
|
|
46
51
|
multipv: (line[/\bmultipv (\d+)/, 1] || "1").to_i,
|
|
47
52
|
score_cp: line[/\bscore cp (-?\d+)/, 1]&.to_i,
|
|
48
53
|
score_mate: line[/\bscore mate (-?\d+)/, 1]&.to_i,
|
|
49
|
-
pv: pv.split(" ")
|
|
54
|
+
pv: pv ? pv.split(" ") : []
|
|
50
55
|
}
|
|
51
56
|
end
|
|
52
57
|
end
|
data/lib/stockshark/version.rb
CHANGED
data/stockshark.gemspec
CHANGED
|
@@ -3,8 +3,8 @@ require_relative 'lib/stockshark/version'
|
|
|
3
3
|
Gem::Specification.new do |spec|
|
|
4
4
|
spec.name = 'stockshark'
|
|
5
5
|
spec.version = Stockshark::VERSION
|
|
6
|
-
spec.authors = ['Phil Brockwell']
|
|
7
|
-
spec.email = ['phil@trueflux.agency']
|
|
6
|
+
spec.authors = [ 'Phil Brockwell' ]
|
|
7
|
+
spec.email = [ 'phil@trueflux.agency' ]
|
|
8
8
|
|
|
9
9
|
spec.summary = 'A small, dependency-free Ruby wrapper for talking to a UCI chess engine.'
|
|
10
10
|
spec.description = <<~DESC
|
|
@@ -24,5 +24,5 @@ Gem::Specification.new do |spec|
|
|
|
24
24
|
|
|
25
25
|
spec.files = Dir.chdir(__dir__) { `git ls-files -z`.split("\x0") }
|
|
26
26
|
.reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
|
27
|
-
spec.require_paths = ['lib']
|
|
27
|
+
spec.require_paths = [ 'lib' ]
|
|
28
28
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: stockshark
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Phil Brockwell
|
|
@@ -22,8 +22,10 @@ executables: []
|
|
|
22
22
|
extensions: []
|
|
23
23
|
extra_rdoc_files: []
|
|
24
24
|
files:
|
|
25
|
+
- ".github/workflows/ci.yml"
|
|
25
26
|
- ".gitignore"
|
|
26
27
|
- ".rspec"
|
|
28
|
+
- ".rubocop.yml"
|
|
27
29
|
- ".ruby-version"
|
|
28
30
|
- Gemfile
|
|
29
31
|
- LICENSE.txt
|