Skip to content

quantumOrange/ChessEngine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ChessEngine

A simple chess engine.

Usage:

To create a chessboard in its start position:

   let chessboard = Chessboard.start()
   

You can also create a board in any configuration with a string like this:

    let chessString =
                    """
                            8   ♜  ♞  ♝  ♛  ♚  .  ♞  ♜
                            7   ♟  ♟  ♟  ♟  .  ♟  .  .
                            6   .  .  .  .  .  .  ♟  ♟
                            5   .  .  .  .  ♟  .  .  .
                            4   .  .  ♗  .  ♙  .  .  .
                            3   .  ♙  ♘  .  .  ♕  .  ♘
                            2   ♙  .  ♙  ♔  .  ♙  ♙  ♙
                            1   .  .  .  ♖  ♖  .  .  .

                                a  b  c  d  e  f  g  h
                    
                    """



    let chessboard = Chessboard(string: chessString) 

You can move a piece on the board like this:

let mv = Move(from: .e2, to:.e4)

let newBoard = apply(move: mv, to: chessboard)

To get the chess engine to generate a move, call pickMove, optionally passing in a depth value to tell the engine how many moves to look ahead:

    let move = pickMove(for:chessboard, depth: 5) 

About

A simple chess engine in swift

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages