Knight is an app that calculates all possible moves for a Knight in a chess board, given a number of turns. It is available under knightapp.ml.
The application was developed in Typescript, using Node and React. A
boilerplate project,
from AE.Studio was used, in order to accelerate
the development process. It has a code structure that splits the entire
app in two core components, called Client
and Api
.
The board of the chess game was represented through a Bitmap (or bitboard). A Bitmap is a representation of an 8x8 chess board using a single UInt64. As this data type has the exact number of bits as the number of houses in an 8x8 chessboard, we can use each bit to represent whether a given piece is present in a specific position.
With that representation, it is possible to simple map patterns of each piece of a chess match (as a knight) and, applying bit shifts and clippings, find the possible movements from a specific position on the board.
Further explanations can be found here.
The project architecture is based on the boilerplate project. Few changes and additions has been made to better fit this project needs.
-
Client
- Api methods:
client/src/api/chess/
- Redux methods:
client/src/redux/ducks/chess.ts
- Components:
client/src/containers/chess/
- Main Container:
client/src/containers/home/
- Custom Assets:
client/src/assets/
- Api methods:
-
Api
- Endpoints:
api/src/api/chess/
- Services:
api/src/services/chess/
- Tests:
api/spec/
- Endpoints:
To run the development server you must have the following resources:
After that, you must be able to execute the following command on the root of the project
yarn dev
Inside the client/
folder
yarn client-test
Inside the api/
folder
yarn api-test-watch
As Knight is an open-source project, all help is welcome. If you are interested in helping growing the project, please read the contribution guidelines as the first step.
As the project was bootstraped by AE.Studio boilerplate, the contribution guidelines are very similar between each other. If you are interested, complementary information can be found here.
This project is licensed under the MIT License.
- Bitmaps
- Knight Movement over Bitmaps
- AE.Studio
- Icons and assets from flaticon