Skip to content

Commit

Permalink
Update checks workflow and add periphery scanning
Browse files Browse the repository at this point in the history
  • Loading branch information
pdil committed Apr 21, 2024
1 parent 6777cbe commit e66386b
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 49 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/test-chesskit-engine.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
name: ChessKitEngine Tests

name: checks

on:
push:
branches: [ master ]
branches: master
pull_request:
branches: [ master ]
branches: master

jobs:
test:
uses: chesskit-app/workflows/.github/workflows/test-swift-package.yml@master
check:
uses: chesskit-app/workflows/.github/workflows/check-swift-package.yaml@master
secrets: inherit
with:
test_bundle: ChessKitEnginePackageTests
test_bundle: ChessKitEnginePackageTests
3 changes: 3 additions & 0 deletions .periphery.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
retain_public: true
targets:
- ChessKitEngine
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ♟️🤖 ChessKitEngine

[![ChessKitEngine Tests](https://github.com/chesskit-app/chesskit-engine/actions/workflows/test-chesskit-engine.yml/badge.svg)](https://github.com/chesskit-app/chesskit-engine/actions/workflows/test-chesskit-engine.yml) [![codecov](https://codecov.io/github/chesskit-app/chesskit-engine/branch/master/graph/badge.svg?token=TDS6QOD25U)](https://codecov.io/gh/chesskit-app/chesskit-engine)
[![checks](https://github.com/chesskit-app/chesskit-engine/actions/workflows/checks.yaml/badge.svg)](https://github.com/chesskit-app/chesskit-engine/actions/workflows/checks.yaml) [![codecov](https://codecov.io/github/chesskit-app/chesskit-engine/branch/master/graph/badge.svg?token=TDS6QOD25U)](https://codecov.io/gh/chesskit-app/chesskit-engine)

A Swift package for the following chess engines:

Expand Down Expand Up @@ -113,7 +113,7 @@ engine.loggingEnabled = true
The following engines are currently supported:
| | Engine | Version | License | Options Reference |
| :---: | --- | :---: | :---: | :---: |
| <img src="https://stockfishchess.org/images/logo/icon_512x512.png" width="25" /> | [Stockfish](https://stockfishchess.org) | [15.1](https://github.com/official-stockfish/Stockfish/tree/sf_15.1) | [GPL v3](https://github.com/official-stockfish/Stockfish/blob/sf_15.1/Copying.txt) | [🔗](https://github.com/official-stockfish/Stockfish/tree/sf_15.1#the-uci-protocol-and-available-options)
| <img src="https://stockfishchess.org/images/logo/icon_512x512.png" width="25" /> | [Stockfish](https://stockfishchess.org) | [16.1](https://github.com/official-stockfish/Stockfish/tree/sf_16.1) | [GPL v3](https://github.com/official-stockfish/Stockfish/blob/sf_16.1/Copying.txt) | [🔗](https://github.com/official-stockfish/Stockfish/tree/sf_16.1#the-uci-protocol-and-available-options)
| <img src="https://lczero.org/images/logo.svg" width="25" /> | [lc0](https://lczero.org) | [0.29](https://github.com/LeelaChessZero/lc0/tree/v0.29.0) | [GPL v3](https://github.com/LeelaChessZero/lc0/blob/v0.29.0/COPYING) | [🔗](https://github.com/LeelaChessZero/lc0/wiki/Lc0-options)

## Author
Expand Down
77 changes: 36 additions & 41 deletions Sources/ChessKitEngine/EngineResponse/EngineResponseInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// MARK: - Info

public extension EngineResponse {

struct Info {
public var depth: Int?
public var seldepth: Int?
Expand All @@ -25,7 +25,7 @@ public extension EngineResponse {
public var string: String?
public var refutation: [String]?
public var currline: CurrLine?

/// Possible arguments for the `<info>` command.
enum Argument: String, CaseIterable {
case depth
Expand All @@ -45,7 +45,7 @@ public extension EngineResponse {
case string
case refutation
case currline

enum ArgType {
/// Single token follows the argument.
case single
Expand All @@ -59,7 +59,7 @@ public extension EngineResponse {
/// The argument is of type `(Int, [String])`
case currentLine
}

var type: ArgType {
switch self {
case .depth: return .single
Expand All @@ -82,18 +82,13 @@ public extension EngineResponse {
}
}
}

subscript(arg: Argument) -> Any? {
get { self[arg.rawValue] }
set { self[arg.rawValue] = newValue }
}


/// Allows subscript access to `Info` properties
/// to allow for easier `String` parsing.
subscript(arg: String) -> Any? {
get {
guard let arg = Argument(rawValue: arg) else { return nil }

switch arg {
case .depth: return depth
case .seldepth: return seldepth
Expand All @@ -116,7 +111,7 @@ public extension EngineResponse {
}
set {
guard let arg = Argument(rawValue: arg) else { return }

switch arg {
case .depth: depth = newValue as? Int
case .seldepth: seldepth = newValue as? Int
Expand All @@ -139,83 +134,83 @@ public extension EngineResponse {
}
}
}

}

extension EngineResponse.Info: Equatable {}

extension EngineResponse.Info: CustomStringConvertible {
public var description: String {
var result = ""

if let depth = depth {
result += " <depth> \(depth)"
}

if let seldepth = seldepth {
result += " <seldepth> \(seldepth)"
}

if let time = time {
result += " <time> \(time)"
}

if let nodes = nodes {
result += " <nodes> \(nodes)"
}

if let pv = pv, !pv.isEmpty {
result += " <pv> \(pv.joined(separator: " "))"
}

if let multipv = multipv {
result += " <multipv> \(multipv)"
}

if let score = score {
result += " <score>\(score)"
}

if let currmove = currmove {
result += " <currmove> \(currmove)"
}

if let currmovenumber = currmovenumber {
result += " <currmovenumber> \(currmovenumber)"
}

if let hashfull = hashfull {
result += " <hashfull> \(hashfull)"
}

if let nps = nps {
result += " <nps> \(nps)"
}

if let tbhits = tbhits {
result += " <tbhits> \(tbhits)"
}

if let sbhits = sbhits {
result += " <sbhits> \(sbhits)"
}

if let cpuload = cpuload {
result += " <cpuload> \(cpuload)"
}

if let string = string {
result += " <string> \(string)"
}

if let refutation = refutation {
result += " <refutation> \(refutation.joined(separator: " "))"
}

if let currline = currline {
result += " <currline>\(currline)"
}

return result
}
}
Expand All @@ -234,7 +229,7 @@ public extension EngineResponse.Info {
public var lowerbound: Bool?
/// The score is just an upper bound.
public var upperbound: Bool?

/// Allows subscript access to `Score` properties
/// to allow for easier `String` parsing.
subscript(member: String) -> Any? {
Expand All @@ -258,29 +253,29 @@ public extension EngineResponse.Info {
}
}
}

}

extension EngineResponse.Info.Score: CustomStringConvertible {
public var description: String {
var result = ""

if let cp = cp {
result += " <cp> \(cp)"
}

if let mate = mate {
result += " <mate> \(mate)"
}

if let lowerbound = lowerbound, lowerbound {
result += " <lowerbound>"
}

if let upperbound = upperbound, upperbound {
result += " <upperbound>"
}

return result
}
}
Expand All @@ -299,15 +294,15 @@ extension EngineResponse.Info {
extension EngineResponse.Info.CurrLine: CustomStringConvertible {
public var description: String {
var result = ""

if let cpunr = cpunr {
result += " \(cpunr)"
}

if !moves.isEmpty {
result += " \(moves.joined(separator: " "))"
}

return result
}
}
Expand Down

0 comments on commit e66386b

Please sign in to comment.