Skip to content

musayuksel/Chess-move-validator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Live demo => here... ⭐ ⭐ ⭐

Chess-move-validator

The task this week is to create a function which takes the name of a chess piece, its position on a board and an intended destination. The function should return true if the piece can move to the destination, or false if it can't. You can assume that the piece is the only piece on the board and that it is a White piece.

Rewards:

4️⃣ Points are awarded for a working algorithm capable of validating these sample moves.

3️⃣ Further points are awarded for illustrating the movement with a simple user interface.

2️⃣ Further points are awarded for providing at least one unit test.

1️⃣ Further point is awarded for providing support for the Black pieces (your function should accept an additional 'colour' parameter).

Notes:

👉 A standard chess board is arranged with the White pieces occupying rows 1 & 2, Black pieces occupying rows 8 & 7, like here.

👉 Here's a handy guide to how each piece can move in a standard game of chess.

👉 Don't forget that a pawn can move 2 squares when starting from its initial row.

Example:

canMove("Rook", "A8", "D8") //  true,
canMove("Queen", "C4", "D6") //  false.

Install

yarn

Testing

yarn test

To Run the function

node index.js

Good luck :)