Code Monkey home page Code Monkey logo

swiftshogi's Introduction

โ€œ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)

swiftshogi's People

Contributors

jiro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

y-ich ishidama

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.