Skip to content

zbyju/chesso

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Edit in Eraser

Chesso - A scala chess library

Usage

This is a normal sbt project. You can compile code with sbt compile, run it with sbt run, and sbt console will start a Scala 3 REPL, sbt test to run tests. You can also make sbt watch file changes and rerun each time using ~ (sbt ~run, sbt ~test).

For more information on the sbt-dotty plugin, see the scala3-example-project.

Features

This project implements the game of chess with a CLI interface to play the game.

ChessBoard

Tracks the state of the board, including:

  • Piece placement on the board
  • Metadata about the board state
    • Whose turn it is
    • Castling rights
    • En passant availability
  • Analysis methods for:
    • Is the player in check
    • Is the player checkmated
    • What squares are under attack by either player

Methods:

lazy val isInCheck: Boolean
lazy val isCheckmated: Boolean

def sq(coords: Coords): PieceType
def sq2(coords: Coords): (PieceType, Color)
def positions: Seq[Coords]
def positions(color: Color): Seq[Coords]

def move(from: Coords, to: Coords): Option[ChessBoard]
def isLegal(from: Coords, to: Coords): Boolean

def attacked: BitBoard // Attacked by the playing player
def attacked(color: Color): BitBoard

def isAttacked(coords: Coords): Boolean
def isOccupied(coords: Coords): Boolean
def isOccupiedBy(color: Color, coords: Coords): Boolean

def theoreticalMoves(coords: Coords): BitBoard
def legalMoves(coords: Coords): BitBoard

Game

Methods:

lazy val isFinished: Boolean
lazy val result: Result
def move(move: Move): Either[String, Game]

Dependecies

  • Scalatest - for Unit Testing

Documentation

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages