Skip to content

Coding challenge that randomly generates the starting and ending locations for the knight. Users can manually click on the chess board to move the knight to the ending location, or use the help button so that it automatically moves the knight step by step until it reaches the ending location.

Notifications You must be signed in to change notification settings

CodeHunt101/knight-BFS

Repository files navigation

Knight Chess Game coding challenge

Instructions

  1. Clone this repository.

  2. Please make sure you are using Ruby 2.7.4, otherwise go to Gemfile and change the ruby version to the one you currently have. Then please run:

bundle install
  1. To install all the react dependencies, please run:
npm install --prefix client
  1. To call the server run:
rails server
  1. Run the following to start the game in the browser:
npm start --prefix client

Structure (MVC)

Models & Controllers

The Rails server handles the entire logic of game from the Game model (Game.rb). The information is sent to the Client from Api::V1::GamesController (games_controller.rb) as JSON. The manual play mode is handled from the client.

Views

The components structure is the following:

App.js
  |
  |-->GameControl.js
          |
          |-->ChessBoard.js
                  |
                  |-->Tile.js

index.css contains the stylings and layout

Recent major implementations

  • Help button calls a Breadth First Search algorithm to find the shortest path to the final target location.

Improvement Opportunities

  • Add a Rails backend for more features such as, data persistance, and user login.
  • Add more stylings and improve responsiveness.
  • Further code refactoring.
  • Add tests to minimise bug occurrences.

Thank you for your time!

About

Coding challenge that randomly generates the starting and ending locations for the knight. Users can manually click on the chess board to move the knight to the ending location, or use the help button so that it automatically moves the knight step by step until it reaches the ending location.

Topics

Resources

Stars

Watchers

Forks