A Java library for working with a chess game.
ChessBoard is a Java library for determining whether a chess move is valid given a starting location, an ending location, and the state of a chess board. This library could be used to create a chess game, create a chess AI, etc.
Note: ChessBoard does not keep track of the current game, such as whose turn it is or what move has been made. It is designed so that you can build upon the basic functionality it gives you, allowing you to create a customized application.
The ChessBoard dependency can be added from the maven repository.
<dependency>
<groupId>com.jaeheonshim</groupId>
<artifactId>chessboard</artifactId>
<version>0.1.0</version>
</dependency>
The unit test suite is stored under /src/test/java. Tests can be run with the following command:
mvn test
Board board = new Board();
System.out.println(board.toString());
Result:
rnbqkbnr
pppppppp
PPPPPPPP
RNBQKBNR
Board board = new Board();
board.clear();
board.getSpot(4, 2).setPiece(new Pawn(true));
board.getSpot(3, 3).setPiece(new Rook(true));
System.out.println(board.toString());
Result:
R
P
Board board = new Board();
System.out.println(board.canMove(Square.E2, Square.E4));
Result:
true
Board board = new Board();
System.out.println(board.move(Square.E2, Square.E4));
System.out.println(board.toString());
Result:
true
rnbqkbnr
pppppppp
P
PPPP PPP
RNBQKBNR
The ChessBoard library at this current time is by no means complete. It has yet to implement features such as fen notation parsing and output, and en passant. Here is a non-exhaustive list of tasks that must be completed before production release:
Phew! There is a lot of work to be done.
We would love any and all contributions from the community improving our code base. Your help allows ChessBoard
to become even better.
To contribute, fork this repository and make all necessary changes on that fork. A pull request can be made to merge your changes with this repository.
Again, thank you for your consideration on becoming a developer for ChessBoard
.
If you would like to say thank you and support the development of ChessBoard
,
Thank you for all of your support on the active development of ChessBoard
.
ChessBoard
is published under the MIT License. More information about this license can be found in the LICENSE file.
In a nutshell,
You are permitted to:
Under the assumption that:
The copyright notice is included in all copies or substantial portions of ChessBoard.
The ChessBoard library uses semantic versioning to define version numbers.