Kotlin multiplatform chess backend

Related tags

App chess.kt
Overview

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

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

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

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!

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

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

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

A Multiplatform Compose Theme for your Compose app
A Multiplatform Compose Theme for your Compose app

A Multiplatform Compose Theme for your Compose app

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

Owner
Vasya Drobushkov
Vasya Drobushkov
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

Ralf Stephan 14 Sep 7, 2022
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

Sarnava Konar 85 Nov 17, 2022
📒 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

Shreyas Patil 1.4k Jan 8, 2023
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

null 2 Oct 22, 2022
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

null 4 Aug 25, 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.

Dheeraj Gupta 5 Dec 24, 2022
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

Nguyen Quoc Hung 2 Oct 4, 2022
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

Łukasz Lipka 0 Dec 12, 2021
UP42 backend coding challenge

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

Paweł Radecki 0 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

null 2 May 22, 2022