Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

74 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

“SwiftShogi”

Workflow Status Swift Version Platforms Swift Package Manager Twitter: @hedjirog

SwiftShogi is a pure Swift shogi library with game management, bitboard-based board representation, and move generation/validation.

Features

  • Game management
  • Board representation
  • Move generation/validation
  • SFEN parsing
  • KIF parsing
  • Pretty printing

Example

To understand how to develop apps using SwiftShogi, you can refer to the following app.

Usage

Initialize a game with SFEN:

var game = Game(sfen: .default)

To get all valid moves, use the validMoves() method, and to get valid moves for a specified piece, use the validMoves(from:piece:) method:

let moves = game.validMoves()

let pieceMoves = game.validMoves(
    from: .board(.twoG),
    piece: Piece(kind: .pawn(.normal), color: .black)
)

You can perform a move by calling the game's perform(_:) method:

let move = Move(
    source: .board(.twoG),
    destination: .board(.twoF),
    piece: Piece(kind: .pawn(.normal), color: .black)
)
try game.perform(move)

Installation

Add the SwiftShogi package to your target dependencies in Package.swift:

import PackageDescription

let package = Package(
    name: "YourProject",
    dependencies: [
        .package(
            url: "https://github.com/hedjirog/SwiftShogi",
            from: "0.1.0"
        ),
    ]
)

Then run the swift build command to build your project.

License

MIT

Contact

Jiro Nagashima (@hedjirog)

About

👑 A pure Swift shogi library

Topics

Resources

Stars

34 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages