kish

Crates.iokish
lib.rskish
version1.1.6
created_at2025-12-21 10:48:02.810555+00
updated_at2026-01-06 14:21:27.1754+00
descriptionA high-performance Turkish Draughts (Dama) engine with bitboard representation
homepage
repositoryhttps://github.com/Sanavesa/kish
max_upload_size
id1997814
size461,684
Sanavesa (Sanavesa)

documentation

https://docs.rs/kish

README

Kish

Crates.io Documentation License

A high-performance Turkish Draughts (Dama) engine written in Rust.

Table of Contents

Overview

Turkish Draughts (Dama) is a variant of checkers with orthogonal movement (horizontal and vertical) rather than diagonal. This engine implements all official rules and is optimized for speed using bitboard representation.

   A B C D E F G H
8  . . . . . . . .  8   <- Black promotes here
7  b b b b b b b b  7
6  b b b b b b b b  6
5  . . . . . . . .  5
4  . . . . . . . .  4
3  w w w w w w w w  3
2  w w w w w w w w  2
1  . . . . . . . .  1   <- White promotes here
   A B C D E F G H

Features

  • Complete Rules - Movement, captures, promotion, all draw conditions
  • Bitboard Engine - 64-bit representation for efficient computation
  • ~330M nodes/sec - Optimized move generation and perft
  • Draw Detection - Threefold repetition and 50-move rule
  • Algebraic Notation - Standard move notation support

Installation

Add to your Cargo.toml:

[dependencies]
kish = "1.0"

Or via cargo:

cargo add kish

Quick Start

use kish::{Game, GameStatus};

fn main() {
    let mut game = Game::new();

    // Game loop
    while !game.status().is_over() {
        let actions = game.actions();

        // Pick a move (here: first legal move)
        if let Some(action) = actions.first() {
            game.make_move(action);
        }
    }

    match game.status() {
        GameStatus::Won(team) => println!("{} wins!", team),
        GameStatus::Draw => println!("Draw!"),
        _ => {}
    }
}

Examples

The examples/ directory contains runnable examples:

  • basic_game.rs - Simple game loop
  • custom_position.rs - Setting up custom board positions
  • game_with_history.rs - Using undo/redo and move history
  • perft.rs - Performance testing with perft

Run an example with:

cargo run --example basic_game

API Reference

Core Types

Type Description
Board Lightweight board state for AI/search
Game Full game with history and draw detection
Action Compact move (XOR delta representation)
ActionPath Move with full path for notation
Square Board square (A1-H8)
Team White or Black
GameStatus InProgress, Draw, or Won

Board vs Game

Use Case Type
AI search (alpha-beta, MCTS) Board
Perft testing Board
High-speed simulations Board
Full games with draw detection Game
Undo/redo support Game

Move Notation

use kish::{ActionPath, Square};

// Simple move: e3-e4
let mv = ActionPath::new_move(Square::E3, Square::E4, false);

// Capture: d4xd6
let cap = ActionPath::new_capture(Square::D4, &[Square::D6], false);

// Multi-capture: b3xd3xd5
let multi = ActionPath::new_capture(Square::B3, &[Square::D3, Square::D5], false);

// Promotion: c7-c8=K
let promo = ActionPath::new_move(Square::C7, Square::C8, true);

println!("{}", promo.to_notation()); // "c7-c8=K"

Performance

Benchmarks run on AMD Ryzen 9 3900X with RUSTFLAGS="-C target-cpu=native". See PERFORMANCE.md for the full optimization history.

Perft (Move Generation)

Depth Nodes Time Nodes/sec
5 85,090 228 µs 373M
6 931,312 2.7 ms 341M
7 10,782,382 32.5 ms 332M

Scenario Benchmarks

Position Depth Time
Initial (pawns) 6 2.7 ms
King endgame (4v4) 6 12.7 ms
Mixed midgame 6 2.5 ms
Capture-heavy 6 103 µs
King chains 8 13.6 ms

Micro-operations

Operation Time
Generate moves (initial) 37 ns
Generate moves (midgame) 31 ns
Apply action 2.2 ns
Board rotation 2.0 ns
Check status 37 ns

Run benchmarks yourself:

RUSTFLAGS="-C target-cpu=native" cargo bench

Rules Summary

See RULES.md for the complete official rules.

Movement

  • Men: Forward and sideways (not backward), one square
  • Kings: All four orthogonal directions, any distance (flying kings)

Capturing

  • Captures are mandatory when available
  • Must choose the path that captures the maximum pieces
  • No 180° turns during multi-capture sequences
  • Captured pieces are removed immediately

Promotion

  • Men promote to kings on the opponent's back row
  • During multi-capture: continues as man, promotes at end

Draw Conditions

  • One piece each (automatic draw)
  • Threefold repetition (same position 3 times)
  • 50 plies without capture (insufficient progress)

Python Bindings

Python bindings are available via PyPI:

pip install kish

See kish-py/README.md for Python documentation and ML examples.

Contributing

See CONTRIBUTING.md for development setup and release instructions.

License

Apache 2.0 - see LICENSE for details.

Commit count: 25

cargo fmt