Skip to content

Commit 6c4ae34

Browse files
committed
Swift 6, package and doc updates
1 parent b03a0c6 commit 6c4ae34

5 files changed

Lines changed: 50 additions & 41 deletions

File tree

.github/workflows/ci.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: CI
1+
name: Build
22

33
on:
44
push:
@@ -12,16 +12,16 @@ concurrency:
1212

1313
jobs:
1414
tests:
15-
name: Build and Test
15+
name: Build
16+
runs-on: ${{ matrix.os }}
1617
strategy:
1718
fail-fast: false
1819
matrix:
19-
swift: ["5.10"]
20-
os: [macos-14]
21-
runs-on: ${{ matrix.os }}
20+
os: [macos-14, macos-latest]
21+
swift: ["6.0"]
2222
steps:
2323
- uses: actions/checkout@v4
24-
- uses: swift-actions/setup-swift@v2
24+
- uses: SwiftyLab/setup-swift@latest
2525
with:
2626
swift-version: ${{ matrix.swift }}
2727
- name: Build

Package.resolved

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
// swift-tools-version: 5.10
1+
// swift-tools-version: 6.0
22
// The swift-tools-version declares the minimum version of Swift required to build this package.
33

44
import PackageDescription
55

66
let package = Package(
77
name: "GameGenerator",
8+
defaultLocalization: "en",
89
platforms: [.macOS(.v14)],
910
dependencies: [
10-
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.2.0"),
11-
.package(url: "https://github.com/apple/swift-algorithms", from: "1.2.0"),
11+
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.5.0"),
12+
.package(url: "https://github.com/apple/swift-algorithms.git", from: "1.2.0"),
1213
.package(url: "https://github.com/jkandzi/Progress.swift.git", from: "0.4.0")
1314
],
1415
targets: [
@@ -22,5 +23,6 @@ let package = Package(
2223
.product(name: "Progress", package: "Progress.swift")
2324
]
2425
),
25-
]
26+
],
27+
swiftLanguageModes: [.v6]
2628
)

Sources/GameGenerator.swift

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,34 @@ import ArgumentParser
44
/// Entry point for the command-line tool.
55
@main
66
struct GameGenerator: AsyncParsableCommand {
7-
static let configuration = CommandConfiguration(abstract: "Finds Fourtile games and streams the output as JSON, for use in the Fourtile web game.",
8-
discussion: """
9-
This game attempts to find as many Fourtile games as possible. Games are
10-
streamed in JSON format to stdout or a file. Games are found using a randomized
11-
heuristic, so there is no guarantee that every possible game will be found. This
12-
is why games are streamed to stdout as they are found: Finding each next game
13-
becomes computationally more expensive as more randomizations are required.
14-
15-
It is the intention that the user will abort this script when the time to find
16-
the next game becomes unreasonable, and the user is satisfied with the number
17-
of games found. The only required step is then to clean up the end of the JSON
18-
file.
19-
20-
When writing games to a file, stdout is used to show a progress indicator, which
21-
is normalized to the theoretical maximum number of possible games.
22-
""",
23-
version: "1.0.0")
24-
25-
@Option(name: .shortAndLong, help: "The text file containing dictionary words.", completion: .file(extensions: ["txt"]), transform: { URL(fileURLWithPath: $0) })
7+
static let configuration = CommandConfiguration(
8+
abstract: "Finds Fourtile games and streams the output as JSON, for use in the Fourtile web game.",
9+
discussion: """
10+
This game attempts to find as many Fourtile games as possible. Games are
11+
streamed in JSON format to stdout or a file. Games are found using a randomized
12+
heuristic, so there is no guarantee that every possible game will be found. This
13+
is why games are streamed to stdout as they are found: Finding each next game
14+
becomes computationally more expensive as more randomizations are required.
15+
16+
It is the intention that the user will abort this script when the time to find
17+
the next game becomes unreasonable, and the user is satisfied with the number
18+
of games found. The only required step is then to clean up the end of the JSON
19+
file.
20+
21+
When writing games to a file, stdout is used to show a progress indicator, which
22+
is normalized to the theoretical maximum number of possible games.
23+
""",
24+
version: "1.0.0")
25+
26+
@Option(name: .shortAndLong,
27+
help: "The text file containing dictionary words.",
28+
completion: .file(extensions: ["txt"]),
29+
transform: { URL(filePath: $0, directoryHint: .notDirectory) })
2630
var dictionary: URL
2731

28-
@Option(name: .shortAndLong, help: "The JSON file to write game data to.", transform: { URL(fileURLWithPath: $0) })
32+
@Option(name: .shortAndLong,
33+
help: "The JSON file to write game data to.",
34+
transform: { URL(filePath: $0, directoryHint: .notDirectory) })
2935
var output: URL? = nil
3036

3137
/// Entry point for the command line tool.

Sources/lib/GameFinder.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import Dispatch
1111
- Exactly ``numFourtilesPerGame`` fourtiles are constructible.
1212
- No words are constructible with more than ``numTilesPerFourtile`` tiles.
1313
- Each word is constructible using only one combination of tiles.
14-
- At least ``minWordsPerGame`` are constructible using between ``minTilesPerWord`` and ``numTilesPerFourtile`` tiles.
14+
- At least ``minWordsPerGame`` are constructible using between
15+
``minTilesPerWord`` and ``numTilesPerFourtile`` tiles.
1516

1617
Fourtiles are defined as words constructible with ``numTilesPerFourtile``
1718
tiles, with each tile having between ``minCharactersPerTile`` and
@@ -22,8 +23,8 @@ import Dispatch
2223
streamed to a given file handle in JSON format. The process can be interrupted
2324
at any point, though you will have to add the closing `]` in the output JSON.
2425
*/
25-
class GameFinder {
26-
26+
actor GameFinder {
27+
2728
/// The minimum number of characters to use when splitting a word into tiles.
2829
static let minCharactersPerTile = 2
2930

0 commit comments

Comments
 (0)