Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can I get a java language program for this self-practice on chess moves please? Chess Move Write a computer program to be called Chess Moves

Can I get a java language program for this self-practice on chess moves please?

Chess Move

Write a computer program to be called Chess Moves that will determine the possible moves of a chess piece, given its current position on a chess board. The program should read a file of piece/position records. For each record, it s to print the piece name and starting position, then calculate the new positions that are legal for the chess piece named to move to. Print out the list of those new positions. The board is assumed to be empty other than the piece you are currently analyzing.

The only chess pieces to be evaluated are the Queen (Q), Bishop (B), Rook (R), and Knight (N). Their movement rules appear below.

The input data file consists of lines with the letter of the piece followed by two numbers that represent the starting position. The end of data is signaled by negative one (-1) in the starting position numbers. The test data file appears below.

Summary of Movement Rules:

For our purposes, a chess board is an 8 by 8 two-dimensional matrix in which each piece occupies one cell. Cells can be empty or contain a piece.

Rook (Castle)

The Rook moves any number of cells in the row or column from the starting position, but only in one direction in a single move, limited by the end of the board.

Bishop

The Bishop moves any number of cells on either diagonal from the starting position, but only in one direction in a single move, limited by the end of the board.

Queen

The Queen moves any number of cells in the row, the column, or either diagonal from the starting position, but only in one direction in a single move, limited by the end of the board.

Knight

The Knight makes the most complex move of these chess pieces. Its move is described as two cells away from the starting position in one direction then one cell to the side in either direction at right angle to the first part of the move, limited by the end of the board. (This can also be seen as one cell away then one cell to either side diagonally further away from the starting position.)

Test Data: Test and demonstrate your Chess Moves program with this file of test data:

Q: 2, 3

N: 3, 1

B: 3. 6

R: 5, 3

B: 4, 2

Q: 4, 9

P: 2, 5

N: 4, 4

R: 4, 5

B: -1, -1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data, Mining, And Analytics Components Of Strategic Decision Making

Authors: Stephan Kudyba

1st Edition

1466568704, 9781466568709

More Books

Students also viewed these Databases questions

Question

How can we visually describe our goals?

Answered: 1 week ago

Question

What metaphors might describe how we work together?

Answered: 1 week ago

Question

What are some of the possible scenes from our future?

Answered: 1 week ago