Skip to content

Commit

Permalink
Remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
pdil committed Apr 14, 2024
1 parent 9cef5bc commit 257d8a4
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 28 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ♟️ ChessKit

[![Test ChessKit](https://github.com/chesskit-app/chesskit-swift/actions/workflows/test-chesskit.yml/badge.svg)](https://github.com/chesskit-app/chesskit-swift/actions/workflows/test-chesskit.yml) [![codecov](https://codecov.io/gh/chesskit-app/chesskit-swift/branch/master/graph/badge.svg?token=676EP0N8XF)](https://codecov.io/gh/chesskit-app/chesskit-swift)
[![ChessKit Tests](https://github.com/chesskit-app/chesskit-swift/actions/workflows/test-chesskit.yaml/badge.svg)](https://github.com/chesskit-app/chesskit-swift/actions/workflows/test-chesskit.yaml) [![codecov](https://codecov.io/gh/chesskit-app/chesskit-swift/branch/master/graph/badge.svg?token=676EP0N8XF)](https://codecov.io/gh/chesskit-app/chesskit-swift)

A Swift package for efficiently implementing chess logic.

Expand Down
2 changes: 0 additions & 2 deletions Sources/ChessKit/Bitboards/PieceSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ struct PieceSet: Equatable {
/// Bitboard for all the pawn pieces.
var pawns: Bitboard { p | P }

/// Bitboard for all the sliding pieces.
var sliders: Bitboard { Q | q | B | b | R | r }
/// Bitboard for all the diagonal sliding pieces.
var diagonals: Bitboard { Q | q | B | b }
/// Bitboard for all the vertical/horizontal sliding pieces.
Expand Down
4 changes: 0 additions & 4 deletions Sources/ChessKit/Bitboards/Square+BB.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,8 @@ extension [Square] {

extension Square.File {
var bb: Bitboard { .aFile.east(number - 1) }

static var bb: [Bitboard] = allCases.map(\.bb)
}

extension Square.Rank {
var bb: Bitboard { .rank1.north(value - 1) }

static var bb: [Bitboard] = range.map(Square.Rank.init(_:)).map(\.bb)
}
2 changes: 1 addition & 1 deletion Sources/ChessKit/Move.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public struct Move: Equatable, Hashable {
/// Initialize a move with a given SAN string.
///
/// This initializer fails if the provided SAN string is invalid.
public init?(san: String, color: Piece.Color, position: Position) {
public init?(san: String, position: Position) {
guard let move = SANParser.parse(move: san, in: position) else {
return nil
}
Expand Down
1 change: 0 additions & 1 deletion Sources/ChessKit/Parsers/PGNParser+Regex.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ extension PGNParser {
static let tagPair = #"\[([^"]+?)\s"([^"]+)"\]"#

// move pair components
static let number = #"\d{1,}\.{1,3}"#
static let castle = #"[Oo0]-[Oo0](-[Oo0])"#
static let move = #"[KQRBN]?[a-h]?[1-8]?x?[a-h][1-8](\=[QRBN])?[+#]"#
static let annotation = #"\$\d"#
Expand Down
5 changes: 5 additions & 0 deletions Sources/ChessKit/Parsers/PGNParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import Foundation

/// Positional assessments.
// periphery:ignore
enum PositionAnnotation {
// <TBD>
}
Expand Down Expand Up @@ -221,6 +222,10 @@ public class PGNParser {
if let black {
game.make(move: black, from: blackIndex)
}

if let result = move.result {
game.tags.result = result.rawValue
}
}

return game
Expand Down
11 changes: 0 additions & 11 deletions Sources/ChessKit/Piece.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,6 @@ public struct Piece: Equatable, Hashable {
case pawn = ""
case knight = "N", bishop = "B", rook = "R", queen = "Q", king = "K"

/// The relative value of each piece.
var value: Int {
switch self {
case .pawn: return 1
case .bishop, .knight: return 3
case .rook: return 5
case .queen: return 9
case .king: return 0
}
}

/// The notation of the given piece kind.
public var notation: String {
switch self {
Expand Down
4 changes: 2 additions & 2 deletions Tests/ChessKitTests/MoveTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ class MoveTests: XCTestCase {

func testMoveSANInit() {
let move = Move(result: .move, piece: .init(.pawn, color: .white, square: .e4), start: .e2, end: .e4)
let moveFromSAN = Move(san: "e4", color: .white, position: .standard)
let moveFromSAN = Move(san: "e4", position: .standard)

XCTAssertEqual(move, moveFromSAN)
}

func testMoveInvalidSANInit() {
XCTAssertNil(Move(san: "e5", color: .white, position: .standard))
XCTAssertNil(Move(san: "e5", position: .standard))
}

func testMoveNotation() {
Expand Down
6 changes: 0 additions & 6 deletions Tests/ChessKitTests/PieceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,21 @@ class PieceTests: XCTestCase {

func testNotation() {
let pawn = Piece.Kind.pawn
XCTAssertEqual(pawn.value, 1)
XCTAssertEqual(pawn.notation, "")

let bishop = Piece.Kind.bishop
XCTAssertEqual(bishop.value, 3)
XCTAssertEqual(bishop.notation, "B")

let knight = Piece.Kind.knight
XCTAssertEqual(knight.value, 3)
XCTAssertEqual(knight.notation, "N")

let rook = Piece.Kind.rook
XCTAssertEqual(rook.value, 5)
XCTAssertEqual(rook.notation, "R")

let queen = Piece.Kind.queen
XCTAssertEqual(queen.value, 9)
XCTAssertEqual(queen.notation, "Q")

let king = Piece.Kind.king
XCTAssertEqual(king.value, 0)
XCTAssertEqual(king.notation, "K")
}

Expand Down

0 comments on commit 257d8a4

Please sign in to comment.