Kotlin multiplatform chess backend

Last update: Jul 30, 2022

chess.kt

Kotlin multiplatform chess backend
Also contains example of usage as desktop app

Usage

Create a game

Main class that holds all the game state is Game.
Create it with Game#create method providing optional FEN of the starting position.
If no FEN is provided then initial position will be used.

val game = Game.create()

Moves

To make a move one should call Game#move with instance of the Move class.
For easier usage one can use extension String#asMove that parses usual PGN notation move and generates corresponding instance of Move class.
Calling Game#move will return true if move was successful or false otherwise.

val isSuccess = game.move("Nbxd2".asMove())

Getting piece

To get piece on the particular square of the board one should call Game#getPiece providing square to check.
For easier usage one can use extension String#asSquare that generates corresponding instance of Square from file-rank string.
Calling Game#getPiece will return piece if it is on the given square or null otherwise.

val piece = game.getPiece("e4".asSquare())

Getting available moves

To get available moves call Game#availableMoves providing optional starting square.
List of available moves will be returned. If there are no moves empty list will be returned.

val availableMoves = game.availableMoves("d4".asSquare())

Game end

To get notified on game end set up callback via Game#setGameResultCallback.
When game ends callback will be triggered with type of ending.

game.setGameResultCallback { result ->
    if (result is GameResult.Draw) {
        // do sth
    }
}

License

Chess.kt sources
Copyright © Vasya Drobushkov
License GNU AGPLv3

Chess pieces images
Copyright © Colin M.L. Burnett
License GNU GPLv2

GitHub

https://github.com/krossovochkin/chess.kt
You might also like...

Mobile client for official Nextcloud News App written as Kotlin Multiplatform Project

Mobile client for official Nextcloud News App written as Kotlin Multiplatform Project

Newsout Android and iOS mobile client for Nextcloud news App. The Android client is already available to download in the Play Store. F-Droid and Apple

Jul 16, 2022

BuildConfiguration information for use in multi-module, or Kotlin Multiplatform common code

component-build-configuration A small library supporting Kotlin Multiplatform for utilizing BuildConfiguration details from common code and across mod

Mar 6, 2022

A weather app demo made to play around with Kotlin Multiplatform.

A weather app demo made to play around with Kotlin Multiplatform.

A weather app demo made to play around with Kotlin Multiplatform. Running on Desktop, Ios and Android with all of the business logic being shared across all three platforms!

Jan 18, 2022

Advent of Code 2021 in Kotlin Multiplatform!

Advent of Code 2021 in Kotlin Multiplatform Structure Each day comes with two parts for you to solve. You'll find a ready-to go and test templates to

Dec 6, 2021

Clean Architecture Kotlin Multiplatform Mobile (KMM) with Android Instrument Test and Unit Test

Clean Architecture Kotlin Multiplatform Mobile (KMM) with Android Instrument Test and Unit Test

The-Movies: Clean Architecture Kotlin Multiplatform Mobile What're inside? - Jetpack Compose - Hilt - Ktor - Android Instrument Test - Unit Test - SQL

Jul 26, 2022

Multidex - The goal with Multidex is to create a Kotlin multiplatform project that shares code across Android, iOS, Desktop, Web, and JVM

Multidex The goal with Multidex is to create a Kotlin multiplatform project that

Apr 20, 2022

Samples demonstrating the features and use of Koala Plot, a Compose Multiplatform based charting and plotting library written in Kotlin.

Koala Plot Samples This repository houses samples demonstrating the use and features of Koala Plot libraries. How to run Build koalaplot-core with the

Aug 6, 2022

A Multiplatform Compose Theme for your Compose app

A Multiplatform Compose Theme for your Compose app

A Multiplatform Compose Theme for your Compose app

Jun 28, 2022

An simple image gallery app utilizing Unsplash API to showcase modern Android development architecture (MVVM + Kotlin + Retrofit2 + Hilt + Coroutines + Kotlin Flow + mockK + Espresso + Junit)

An simple image gallery app utilizing Unsplash API to showcase modern Android development architecture (MVVM + Kotlin + Retrofit2 + Hilt + Coroutines + Kotlin Flow + mockK + Espresso + Junit)

Imagine App An simple image gallery app utilizing Unsplash API. Built with ❤︎ by Wajahat Karim and contributors Features Popular photos with paginatio

Aug 18, 2022
Related tags
Play casual chess on lichess.org via voice commands

Lichess-by-Voice lichess.org is a cost-free, ad-free chess server. Lichess, as well as this app, is Open Source. The app connects to your Lichess acco

Jul 6, 2022
A full-stack application showing the power 💪 of KOTLIN. Entire android app + backend Apis written in Kotlin 🔥
A full-stack application showing the power 💪 of KOTLIN. Entire android app + backend Apis written in Kotlin 🔥

Gamebaaz ?? A full-stack application showing the power ?? of KOTLIN. Entire android app + backend Apis written in Kotlin ?? Android Backend Jetpack Co

Aug 4, 2022
📒 NotyKT is a complete 💎Kotlin-stack (Backend + Android) 📱 application built to demonstrate the use of Modern development tools with best practices implementation🦸.
📒 NotyKT is a complete 💎Kotlin-stack (Backend + Android) 📱 application built to demonstrate the use of Modern development tools with best practices implementation🦸.

NotyKT ??️ NotyKT is the complete Kotlin-stack note taking ??️ application ?? built to demonstrate a use of Kotlin programming language in server-side

Aug 12, 2022
An android Quiz App in kotlin framework and uses Appwrite as backend
An android Quiz App in kotlin framework and uses Appwrite as backend

Quiz App Intro An android Quiz App in kotlin framework and uses Appwrite as backend How to clone and run the project: Cloning : git clone https://gith

Oct 8, 2021
An E-Commerce android App whose frontend is implemented using Kotlin & XML files and backend/database is implemented using My SQL & PHP files

An E-Commerce android App whose frontend is implemented using Kotlin & XML files and backend/database is implemented using My SQL & PHP files

Jun 7, 2022
Book Parking is a demo application based on MVVM architecture. The app allows users to booking parking slots, the app uses firebase for the backend.
Book Parking is a demo application based on MVVM architecture. The app allows users to booking parking slots, the app uses firebase for the backend.

Book Parking is a demo application based on MVVM architecture. The app allows users to booking parking slots, the app uses firebase for the backend.

Jul 8, 2022
A android plant shop app with firebase backend
A android plant shop app with firebase backend

PlantShop A android plant shop app with firebase backend What i learned: Create a responsive UI with ConstraintLayout Store product and save to user c

Jan 21, 2022
Backend service for mobile/web application for a small cinema playing only movies
Backend service for mobile/web application for a small cinema playing only movies

FFC - Fast & Furious Cinema Backend service for mobile/web application for a small cinema playing only movies from Fast & Furious franchise. Some assu

Dec 12, 2021
UP42 backend coding challenge

UP42 backend coding challenge by Paweł Radecki Build and deploy locally ./gradle

Jan 10, 2022
The backend of HumLib - The Human Library in Computer Science

humlib-be Backend for HumLib - The Human Library in Computer Science Development workflow We use GitHub flow as git branching strategy. It is based on

May 22, 2022