Skip to content

lucaspbordignon/knight

Repository files navigation

Knight Knight

license

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.

Algorithm

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.

Project Structure

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

    • Endpoints: api/src/api/chess/
    • Services: api/src/services/chess/
    • Tests: api/spec/

Screenshot

Screenshot

Running

Development server

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

Running tests

Inside the client/ folder

yarn client-test

Inside the api/ folder

yarn api-test-watch

Contributing

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.

License

This project is licensed under the MIT License.

References and Credits