Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ on: pull_request
jobs:
tests:
name: Unit-Tests
runs-on: macos-13
runs-on: macos-15
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Run unit tests
run: swift test --enable-code-coverage
- name: Checkout repository
uses: actions/checkout@v4
- name: Print Swift version
run: swift --version
- name: Run unit tests
run: swift test --enable-code-coverage
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
xcuserdata/
DerivedData/
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
build
docs
9 changes: 9 additions & 0 deletions .swiftformat
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
--swiftversion 6.0
--disable blankLinesAroundMark
--disable preferForLoop
--disable wrapMultilineStatementBraces
--commas inline
--ifdef outdent
--importgrouping testable-last
--indent 2
--propertytypes explicit
26 changes: 23 additions & 3 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
disabled_rules:
- comment_spacing
- cyclomatic_complexity
- force_cast
- force_try
- function_body_length
- identifier_name
- trailing_comma
- file_length
- leading_whitespace
- static_over_final_class
- type_name
- unused_enumerated

cyclomatic_complexity: 50
function_body_length: 80
line_length:
warning: 110

nesting:
function_level: 1
type_level: 3

trailing_whitespace:
severity: error

excluded:
- .build
- Package.swift
98 changes: 98 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Build",
"type": "shell",
"command": "swift build",
"problemMatcher": [],
"presentation": {
"echo": false,
"showReuseMessage": false,
"clear": true
}
},
{
"label": "Build all",
"type": "shell",
"command": "swift build --build-tests",
"problemMatcher": [],
"presentation": {
"echo": false,
"showReuseMessage": false,
"clear": true
}
},
{
"label": "Test",
"type": "shell",
"command": "swift test",
"problemMatcher": [],
"presentation": {
"echo": false,
"showReuseMessage": false,
"clear": true
}
},
{
"label": "Format all files",
"type": "shell",
"command": "swiftformat -v .",
"problemMatcher": [],
"presentation": {
"echo": false,
"showReuseMessage": false,
"clear": true
}
},
{
"label": "Lint all files",
"type": "shell",
"command": "swiftlint .",
"problemMatcher": [],
"presentation": {
"echo": false,
"showReuseMessage": false,
}
},
{
"label": "Format and lint all files",
"problemMatcher": [],
"dependsOn": [
"Format all files",
"Lint all files"
],
"dependsOrder": "sequence"
},
{
"label": "Format current file",
"type": "shell",
"command": "swiftformat -v ${file}",
"problemMatcher": [],
"presentation": {
"echo": false,
"showReuseMessage": false,
"clear": true
}
},
{
"label": "Lint current file",
"type": "shell",
"command": "swiftlint ${file}",
"problemMatcher": [],
"presentation": {
"echo": false,
"showReuseMessage": false
}
},
{
"label": "Format and lint current file",
"problemMatcher": [],
"dependsOn": [
"Format current file",
"Lint current file"
],
"dependsOrder": "sequence"
}
]
}
15 changes: 11 additions & 4 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
// swift-tools-version:5.3
// swift-tools-version:6.0
import PackageDescription

let package = Package(
name: "ChessCore",
platforms: [
.iOS(.v13),
.macOS(.v10_15)
],
products: [
.library(
name: "ChessCore",
targets: ["ChessCore"]),
targets: ["ChessCore"]
)
],
targets: [
.target(
name: "ChessCore",
dependencies: []),
dependencies: []
),
.testTarget(
name: "ChessCoreTests",
dependencies: ["ChessCore"]),
dependencies: ["ChessCore"]
)
]
)
102 changes: 8 additions & 94 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,99 +1,13 @@
# Chess
# ChessCore

Chess Swift package
A Swift chess engine.

## Example
## Requirements

### Interactive command line program
```swift
var game = Game()
print(game)
- Swift 6+
- iOS 13+ / macOS 10.15+

while !game.isGameOver {
print("\n?", terminator: " ")
guard let line = readLine() else { continue }
do {
try game.move(line)
print(game)
} catch {
print(error.localizedDescription)
}
}
```
## Examples

#### Output
```
White to move.

8 r n b q k b n r
7 p p p p p p p p
6
5
4
3
2 P P P P P P P P
1 R N B Q K B N R
a b c d e f g h

? f3
1. f3

Black to move.

8 r n b q k b n r
7 p p p p p p p p
6
5
4
3 P
2 P P P P P P P
1 R N B Q K B N R
a b c d e f g h

? e6
1. f3 e6

White to move.

8 r n b q k b n r
7 p p p p p p p
6 p
5
4
3 P
2 P P P P P P P
1 R N B Q K B N R
a b c d e f g h

? g4
1. f3 e6
2. g4

Black to move.

8 r n b q k b n r
7 p p p p p p p
6 p
5
4 P
3 P
2 P P P P P P
1 R N B Q K B N R
a b c d e f g h

? Qh4#
1. f3 e6
2. g4 Qh4#

Black wins.

8 r n b k b n r
7 p p p p p p p
6 p
5
4 P q
3 P
2 P P P P P P
1 R N B Q K B N R
a b c d e f g h
```
- [Chess](https://github.com/iliaskarim/Chess) — command-line demo
- [ChessUI](https://github.com/iliaskarim/chessui) — SwiftUI interface
Loading
Loading